[java-opensaml] branch main updated: Missing annotations and some null checks.
Scott Cantor
cantor.2 at osu.edu
Tue Mar 7 18:25:25 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=e98f29f3923a823016cc7f99e47790f74559075e
The following commit(s) were added to refs/heads/main by this push:
new e98f29f39 Missing annotations and some null checks.
e98f29f39 is described below
commit e98f29f3923a823016cc7f99e47790f74559075e
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Mar 7 13:25:21 2023 -0500
Missing annotations and some null checks.
---
.../opensaml/core/xml/config/XMLConfigurator.java | 11 +++++++--
.../core/impl/AuthorityBindingUnmarshaller.java | 5 +++-
.../saml1/core/impl/StatusCodeUnmarshaller.java | 9 +++++---
.../impl/SecurityTokenReferenceUnmarshaller.java | 8 ++++---
.../support/impl/SignatureAlgorithmValidator.java | 27 +++++++++++++---------
5 files changed, 40 insertions(+), 20 deletions(-)
diff --git a/opensaml-core-api/src/main/java/org/opensaml/core/xml/config/XMLConfigurator.java b/opensaml-core-api/src/main/java/org/opensaml/core/xml/config/XMLConfigurator.java
index b8cec90d7..50cb8a32f 100644
--- a/opensaml-core-api/src/main/java/org/opensaml/core/xml/config/XMLConfigurator.java
+++ b/opensaml-core-api/src/main/java/org/opensaml/core/xml/config/XMLConfigurator.java
@@ -233,11 +233,16 @@ public class XMLConfigurator {
// Get the element name of type this object provider is for
final Attr qNameAttrib = objectProvider.getAttributeNodeNS(null, "qualifiedName");
- final QName objectProviderName = AttributeSupport.getAttributeValueAsQName(qNameAttrib);
+ final QName objectProviderName = qNameAttrib != null ?
+ AttributeSupport.getAttributeValueAsQName(qNameAttrib) : null;
log.debug("Initializing object provider {}", objectProviderName);
try {
+ if (objectProviderName == null) {
+ throw new XMLConfigurationException("qualifiedName attribute was missing");
+ }
+
Element configuration =
(Element) objectProvider.getElementsByTagNameNS(XMLTOOLING_CONFIG_NS, "BuilderClass").item(0);
final XMLObjectBuilder<?> builder = (XMLObjectBuilder<?>) createClassInstance(configuration);
@@ -256,7 +261,9 @@ public class XMLConfigurator {
} catch (final XMLConfigurationException e) {
log.error("Error initializing object provier {}: {}", objectProvider, e.getMessage());
// clean up any parts of the object provider that might have been registered before the failure
- getRegistry().deregisterObjectProvider(objectProviderName);
+ if (objectProviderName != null) {
+ getRegistry().deregisterObjectProvider(objectProviderName);
+ }
throw e;
}
}
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/core/impl/AuthorityBindingUnmarshaller.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/core/impl/AuthorityBindingUnmarshaller.java
index a50f43fee..f7e521bfa 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/core/impl/AuthorityBindingUnmarshaller.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/core/impl/AuthorityBindingUnmarshaller.java
@@ -17,6 +17,8 @@
package org.opensaml.saml.saml1.core.impl;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.UnmarshallingException;
import org.opensaml.saml.common.AbstractSAMLObjectUnmarshaller;
@@ -32,7 +34,8 @@ import net.shibboleth.shared.xml.AttributeSupport;
public class AuthorityBindingUnmarshaller extends AbstractSAMLObjectUnmarshaller {
/** {@inheritDoc} */
- protected void processAttribute(final XMLObject samlObject, final Attr attribute) throws UnmarshallingException {
+ protected void processAttribute(@Nonnull final XMLObject samlObject, @Nonnull final Attr attribute)
+ throws UnmarshallingException {
final AuthorityBinding authorityBinding = (AuthorityBinding) samlObject;
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/core/impl/StatusCodeUnmarshaller.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/core/impl/StatusCodeUnmarshaller.java
index 2861f0592..f07521ca2 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/core/impl/StatusCodeUnmarshaller.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/core/impl/StatusCodeUnmarshaller.java
@@ -17,6 +17,8 @@
package org.opensaml.saml.saml1.core.impl;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.UnmarshallingException;
import org.opensaml.saml.common.AbstractSAMLObjectUnmarshaller;
@@ -31,8 +33,8 @@ import net.shibboleth.shared.xml.AttributeSupport;
public class StatusCodeUnmarshaller extends AbstractSAMLObjectUnmarshaller {
/** {@inheritDoc} */
- protected void processChildElement(final XMLObject parentSAMLObject, final XMLObject childSAMLObject)
- throws UnmarshallingException {
+ protected void processChildElement(@Nonnull final XMLObject parentSAMLObject,
+ @Nonnull final XMLObject childSAMLObject) throws UnmarshallingException {
final StatusCode statusCode = (StatusCode) parentSAMLObject;
@@ -45,7 +47,8 @@ public class StatusCodeUnmarshaller extends AbstractSAMLObjectUnmarshaller {
}
/** {@inheritDoc} */
- protected void processAttribute(final XMLObject samlObject, final Attr attribute) throws UnmarshallingException {
+ protected void processAttribute(@Nonnull final XMLObject samlObject, @Nonnull final Attr attribute)
+ throws UnmarshallingException {
final StatusCode statusCode = (StatusCode) samlObject;
diff --git a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wssecurity/impl/SecurityTokenReferenceUnmarshaller.java b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wssecurity/impl/SecurityTokenReferenceUnmarshaller.java
index b0fbf574e..708d6b950 100644
--- a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wssecurity/impl/SecurityTokenReferenceUnmarshaller.java
+++ b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wssecurity/impl/SecurityTokenReferenceUnmarshaller.java
@@ -17,6 +17,7 @@
package org.opensaml.soap.wssecurity.impl;
+import javax.annotation.Nonnull;
import javax.xml.namespace.QName;
import org.opensaml.core.xml.XMLObject;
@@ -34,15 +35,16 @@ import net.shibboleth.shared.xml.QNameSupport;
public class SecurityTokenReferenceUnmarshaller extends AbstractWSSecurityObjectUnmarshaller {
/** {@inheritDoc} */
- protected void processChildElement(final XMLObject parentXMLObject, final XMLObject childXMLObject)
- throws UnmarshallingException {
+ protected void processChildElement(@Nonnull final XMLObject parentXMLObject,
+ @Nonnull final XMLObject childXMLObject) throws UnmarshallingException {
final SecurityTokenReference str = (SecurityTokenReference) parentXMLObject;
str.getUnknownXMLObjects().add(childXMLObject);
}
/** {@inheritDoc} */
- protected void processAttribute(final XMLObject xmlObject, final Attr attribute) throws UnmarshallingException {
+ protected void processAttribute(@Nonnull final XMLObject xmlObject, @Nonnull final Attr attribute)
+ throws UnmarshallingException {
final SecurityTokenReference str = (SecurityTokenReference) xmlObject;
final QName attribQName =
diff --git a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/signature/support/impl/SignatureAlgorithmValidator.java b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/signature/support/impl/SignatureAlgorithmValidator.java
index feace20ec..5d35ca2da 100644
--- a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/signature/support/impl/SignatureAlgorithmValidator.java
+++ b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/signature/support/impl/SignatureAlgorithmValidator.java
@@ -148,12 +148,15 @@ public class SignatureAlgorithmValidator {
final Element signature = signatureXMLObject.getDOM();
final Element signedInfo = ElementSupport.getFirstChildElement(signature, ELEMENT_NAME_SIGNED_INFO);
final Element signatureMethod = ElementSupport.getFirstChildElement(signedInfo, ELEMENT_NAME_SIGNATURE_METHOD);
- final String signatureMethodAlgorithm = StringSupport.trimOrNull(
- AttributeSupport.getAttributeValue(signatureMethod, null, ATTR_NAME_ALGORTHM));
- if (signatureMethodAlgorithm != null) {
- return signatureMethodAlgorithm;
+
+ if (signatureMethod != null) {
+ final String signatureMethodAlgorithm = StringSupport.trimOrNull(
+ AttributeSupport.getAttributeValue(signatureMethod, null, ATTR_NAME_ALGORTHM));
+ if (signatureMethodAlgorithm != null) {
+ return signatureMethodAlgorithm;
+ }
}
- throw new SignatureException("SignatureMethod Algorithm was null");
+ throw new SignatureException("SignatureMethod element or Algorithm was null");
}
@@ -174,12 +177,14 @@ public class SignatureAlgorithmValidator {
for (final Element reference : ElementSupport.getChildElements(signedInfo, ELEMENT_NAME_REFERENCE)) {
final Element digestMethod = ElementSupport.getFirstChildElement(reference, ELEMENT_NAME_DIGEST_METHOD);
- final String digestMethodAlgorithm = StringSupport.trimOrNull(
- AttributeSupport.getAttributeValue(digestMethod, null, ATTR_NAME_ALGORTHM));
- if (digestMethodAlgorithm != null) {
- digestMethodAlgorithms.add(digestMethodAlgorithm);
- } else {
- throw new SignatureException("Saw null DigestMethod Algorithm");
+ if (digestMethod != null) {
+ final String digestMethodAlgorithm = StringSupport.trimOrNull(
+ AttributeSupport.getAttributeValue(digestMethod, null, ATTR_NAME_ALGORTHM));
+ if (digestMethodAlgorithm != null) {
+ digestMethodAlgorithms.add(digestMethodAlgorithm);
+ } else {
+ throw new SignatureException("DigestMethod Algorithm was null");
+ }
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list