You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by "dmatej (via GitHub)" <gi...@apache.org> on 2023/06/21 17:17:04 UTC
[GitHub] [santuario-xml-security-java] dmatej opened a new pull request, #181: Using enhanced loops where possible
dmatej opened a new pull request, #181:
URL: https://github.com/apache/santuario-xml-security-java/pull/181
- Cleanup made by Eclipse IDE and revisited manually
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@santuario.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [santuario-xml-security-java] coheigea merged pull request #181: Using enhanced loops where possible
Posted by "coheigea (via GitHub)" <gi...@apache.org>.
coheigea merged PR #181:
URL: https://github.com/apache/santuario-xml-security-java/pull/181
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@santuario.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [santuario-xml-security-java] dmatej commented on a diff in pull request #181: Using enhanced loops where possible
Posted by "dmatej (via GitHub)" <gi...@apache.org>.
dmatej commented on code in PR #181:
URL: https://github.com/apache/santuario-xml-security-java/pull/181#discussion_r1238510485
##########
src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMSignedInfo.java:
##########
@@ -100,17 +100,13 @@ public DOMSignedInfo(CanonicalizationMethod cm, SignatureMethod sm,
}
this.canonicalizationMethod = cm;
this.signatureMethod = sm;
- this.references = Collections.unmodifiableList(
- new ArrayList<>(references));
+ this.references = Collections.unmodifiableList(new ArrayList<>(references));
if (this.references.isEmpty()) {
- throw new IllegalArgumentException("list of references must " +
- "contain at least one entry");
+ throw new IllegalArgumentException("list of references must contain at least one entry");
}
- for (int i = 0, size = this.references.size(); i < size; i++) {
- Object obj = this.references.get(i);
- if (!(obj instanceof Reference)) {
- throw new ClassCastException("list of references contains " +
- "an illegal type");
+ for (Object obj : this.references) {
+ if (!Reference.class.isInstance(obj)) {
Review Comment:
This is a bit complicated, first I removed the for loop as it should not be possible to have an incompatible element IF user would keep rules (generics). But there is an unit test which proves that it is possible to pass incompatible type. Maybe it should be refactored later - at least I will comply with rules and bring back the `instanceof`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@santuario.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [santuario-xml-security-java] coheigea commented on a diff in pull request #181: Using enhanced loops where possible
Posted by "coheigea (via GitHub)" <gi...@apache.org>.
coheigea commented on code in PR #181:
URL: https://github.com/apache/santuario-xml-security-java/pull/181#discussion_r1238086926
##########
src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractEncryptOutputProcessor.java:
##########
@@ -160,7 +160,7 @@ public void init(OutputProcessorChain outputProcessorChain) throws XMLSecurityEx
String encryptionSymAlgorithm = securityProperties.getEncryptionSymAlgorithm();
try {
//initialize the cipher
- String jceAlgorithm = JCEAlgorithmMapper.translateURItoJCEID(encryptionSymAlgorithm);
+ String jceAlgorithm = JCEMapper.translateURItoJCEID(encryptionSymAlgorithm);
Review Comment:
Was this change intended?
##########
src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMSignedInfo.java:
##########
@@ -100,17 +100,13 @@ public DOMSignedInfo(CanonicalizationMethod cm, SignatureMethod sm,
}
this.canonicalizationMethod = cm;
this.signatureMethod = sm;
- this.references = Collections.unmodifiableList(
- new ArrayList<>(references));
+ this.references = Collections.unmodifiableList(new ArrayList<>(references));
if (this.references.isEmpty()) {
- throw new IllegalArgumentException("list of references must " +
- "contain at least one entry");
+ throw new IllegalArgumentException("list of references must contain at least one entry");
}
- for (int i = 0, size = this.references.size(); i < size; i++) {
- Object obj = this.references.get(i);
- if (!(obj instanceof Reference)) {
- throw new ClassCastException("list of references contains " +
- "an illegal type");
+ for (Object obj : this.references) {
+ if (!Reference.class.isInstance(obj)) {
Review Comment:
According to https://rules.sonarsource.com/java/RSPEC-6202, the isInstance operator is preferred when the class name is known at compile time.
##########
src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureOutputProcessor.java:
##########
@@ -181,8 +182,8 @@ protected void setActiveInternalSignatureOutputProcessor(
protected DigestOutputStream createMessageDigestOutputStream(String digestAlgorithm)
throws XMLSecurityException {
- String jceName = JCEAlgorithmMapper.translateURItoJCEID(digestAlgorithm);
- String jceProvider = JCEAlgorithmMapper.getJCEProviderFromURI(digestAlgorithm);
+ String jceName = JCEMapper.translateURItoJCEID(digestAlgorithm);
+ String jceProvider = JCEMapper.getJCEProviderFromURI(digestAlgorithm);
Review Comment:
Why this change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@santuario.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [santuario-xml-security-java] dmatej commented on a diff in pull request #181: Using enhanced loops where possible
Posted by "dmatej (via GitHub)" <gi...@apache.org>.
dmatej commented on code in PR #181:
URL: https://github.com/apache/santuario-xml-security-java/pull/181#discussion_r1238525882
##########
src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureOutputProcessor.java:
##########
@@ -181,8 +182,8 @@ protected void setActiveInternalSignatureOutputProcessor(
protected DigestOutputStream createMessageDigestOutputStream(String digestAlgorithm)
throws XMLSecurityException {
- String jceName = JCEAlgorithmMapper.translateURItoJCEID(digestAlgorithm);
- String jceProvider = JCEAlgorithmMapper.getJCEProviderFromURI(digestAlgorithm);
+ String jceName = JCEMapper.translateURItoJCEID(digestAlgorithm);
+ String jceProvider = JCEMapper.getJCEProviderFromURI(digestAlgorithm);
Review Comment:
Automatic change made by Eclipse - the method is defined in the parent class, but it is static. There is no such method in `JCEAlgorithMapper`. In fact the `JCEAlgorithmMapper` should NOT "inherit" from `JCEMapper`, both contain just static methods and both should be final. But that would be a breaking change, however I don't think anyone "extended" these classes.
I would keep it there as it is here, because it is the right direction. In "sanct4" branch we can continue with breaking changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@santuario.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [santuario-xml-security-java] dmatej commented on a diff in pull request #181: Using enhanced loops where possible
Posted by "dmatej (via GitHub)" <gi...@apache.org>.
dmatej commented on code in PR #181:
URL: https://github.com/apache/santuario-xml-security-java/pull/181#discussion_r1238525882
##########
src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureOutputProcessor.java:
##########
@@ -181,8 +182,8 @@ protected void setActiveInternalSignatureOutputProcessor(
protected DigestOutputStream createMessageDigestOutputStream(String digestAlgorithm)
throws XMLSecurityException {
- String jceName = JCEAlgorithmMapper.translateURItoJCEID(digestAlgorithm);
- String jceProvider = JCEAlgorithmMapper.getJCEProviderFromURI(digestAlgorithm);
+ String jceName = JCEMapper.translateURItoJCEID(digestAlgorithm);
+ String jceProvider = JCEMapper.getJCEProviderFromURI(digestAlgorithm);
Review Comment:
Automatic change made by Eclipse - the method is defined in the parent class, but it is static. There is no such method in `JCEAlgorithMapper`. In fact the `JCEAlgorithmMapper` should NOT inherit from `JCEMapper`, both contain just static methods and both should be final. But that would be a breaking change, however I don't think anyone "extended" these classes.
I would keep it there as it is here, because it is the right direction. In "sanct4" branch we can continue with breaking changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@santuario.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org