[java-opensaml] branch main updated: IDP-2069 - Null Handling Task
Scott Cantor
cantor.2 at osu.edu
Mon Mar 20 19:37:02 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=ccbac9b12abdefcb12c39955e3751d9e2be58aeb
The following commit(s) were added to refs/heads/main by this push:
new ccbac9b12 IDP-2069 - Null Handling Task
ccbac9b12 is described below
commit ccbac9b12abdefcb12c39955e3751d9e2be58aeb
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Mar 20 15:36:59 2023 -0400
IDP-2069 - Null Handling Task
https://shibboleth.atlassian.net/browse/IDP-2069
Cleaned some of opensaml-saml-api.
---
.../saml/common/AbstractSAMLObjectMarshaller.java | 14 ++-
.../saml/common/SAMLObjectContentReference.java | 14 ++-
.../opensaml/saml/common/SAMLObjectSupport.java | 40 ++++----
.../java/org/opensaml/saml/common/SAMLVersion.java | 4 +-
.../common/assertion/ValidationProcessingData.java | 4 +-
.../common/binding/AbstractEndpointResolver.java | 44 +++++----
.../saml/common/binding/SAMLBindingSupport.java | 15 ++-
.../binding/artifact/AbstractSAMLArtifact.java | 4 +-
.../messaging/context/SAMLArtifactContext.java | 5 +-
.../messaging/context/SAMLMessageInfoContext.java | 55 ++++-------
.../messaging/context/SAMLPeerEntityContext.java | 45 ++++-----
.../context/SAMLSubjectNameIdentifierContext.java | 37 ++++----
.../soap/SAMLSOAPClientContextBuilder.java | 57 +++++------
.../profile/AbstractNameIdentifierGenerator.java | 33 ++-----
.../logic/AbstractNameIDPolicyPredicate.java | 2 +-
.../logic/AffiliationNameIDPolicyPredicate.java | 2 +-
.../profile/logic/DefaultLocalErrorPredicate.java | 17 ++--
.../logic/DefaultNameIDPolicyPredicate.java | 3 +-
.../profile/logic/EntityAttributesPredicate.java | 57 ++++++-----
.../profile/logic/EntityGroupNamePredicate.java | 12 ++-
.../common/profile/logic/EntityIdPredicate.java | 3 +-
.../logic/InboundMessageSignedPredicate.java | 13 ++-
.../MetadataNameIdentifierFormatStrategy.java | 14 +--
.../logic/RegistrationAuthorityPredicate.java | 5 +-
.../profile/logic/RegistrationPolicyPredicate.java | 3 +-
.../opensaml/saml/common/xml/SAMLConstants.java | 105 ++++++++++++++-------
.../saml/common/xml/SAMLSchemaBuilder.java | 11 ++-
.../opensaml/saml/config/SAMLConfiguration.java | 11 +--
.../saml/config/SAMLConfigurationSupport.java | 12 +--
.../opensaml/saml/criterion/BindingCriterion.java | 3 +-
.../opensaml/saml/ext/saml2aslo/Asynchronous.java | 4 +-
.../saml/ext/saml2mdreqinit/RequestInitiator.java | 3 +-
.../opensaml/saml/ext/saml2mdrpi/Publication.java | 17 ++--
.../saml/ext/saml2mdrpi/PublicationInfo.java | 19 ++--
.../saml/ext/saml2mdrpi/PublicationPath.java | 6 +-
.../saml/ext/saml2mdrpi/RegistrationInfo.java | 15 +--
.../java/org/opensaml/saml/ext/samlec/EncType.java | 4 +-
.../org/opensaml/saml/ext/samlec/GeneratedKey.java | 4 +-
.../org/opensaml/saml/ext/samlec/SessionKey.java | 15 +--
.../resolver/ChainingMetadataResolver.java | 64 +++++--------
.../resolver/filter/MetadataFilterChain.java | 2 +-
.../index/SimpleStringMetadataIndexKey.java | 2 +-
.../metadata/support/SAML2MetadataSupport.java | 3 +-
.../binding/artifact/AbstractSAML1Artifact.java | 4 +-
.../binding/artifact/SAML1ArtifactType0001.java | 29 +++---
.../artifact/SAML1ArtifactType0001Builder.java | 6 +-
.../binding/artifact/SAML1ArtifactType0002.java | 32 ++++---
.../artifact/SAML1ArtifactType0002Builder.java | 7 +-
.../org/opensaml/saml/saml1/core/Evidence.java | 11 +--
.../opensaml/saml/saml1/core/NameIdentifier.java | 16 ++--
.../java/org/opensaml/saml/saml1/core/Request.java | 18 ++--
.../org/opensaml/saml/saml1/core/RespondWith.java | 4 +-
.../org/opensaml/saml/saml1/core/Response.java | 4 +-
.../org/opensaml/saml/saml1/core/StatusCode.java | 25 ++---
.../opensaml/saml/saml1/core/SubjectLocality.java | 13 +--
.../org/opensaml/saml/saml1/core/SubjectQuery.java | 5 +-
.../AbstractSAML1NameIdentifierGenerator.java | 3 +-
.../saml/saml1/profile/SAML1ActionSupport.java | 2 +-
.../saml/saml1/profile/SAML1ObjectSupport.java | 5 -
.../saml2/assertion/SAML20AssertionValidator.java | 24 ++---
.../binding/artifact/AbstractSAML2Artifact.java | 17 ++--
.../binding/artifact/SAML2ArtifactType0004.java | 27 ++++--
.../artifact/SAML2ArtifactType0004Builder.java | 2 +-
.../opensaml/saml/saml2/common/SAML2Support.java | 7 +-
.../saml/saml2/core/RequestAbstractType.java | 29 +++---
.../saml/saml2/core/StatusResponseType.java | 37 ++++----
.../org/opensaml/saml/saml2/core/SubjectQuery.java | 5 +-
.../opensaml/saml/saml2/encryption/Decrypter.java | 2 +-
.../EncryptedElementTypeEncryptedKeyResolver.java | 5 +-
.../opensaml/saml/saml2/encryption/Encrypter.java | 99 ++++++++++---------
.../profile/AbstractSAML2NameIDGenerator.java | 2 +-
.../saml/saml2/profile/SAML2ActionSupport.java | 2 +-
opensaml-saml-api/src/main/java/overview.html | 19 ----
.../common/binding/SAMLBindingSupportTest.java | 8 +-
.../messaging/SAMLMessageSecuritySupportTest.java | 5 +-
.../saml/config/SAMLConfigurationTest.java | 4 +-
.../saml/metadata/EntityGroupNameTest.java | 8 +-
.../index/SimpleStringMetadataIndexKeyTest.java | 11 +--
.../AbstractSAML1NameIdentifierGeneratorTest.java | 7 +-
.../impl/AbstractSAML2NameIDGeneratorTest.java | 7 +-
80 files changed, 674 insertions(+), 639 deletions(-)
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/AbstractSAMLObjectMarshaller.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/AbstractSAMLObjectMarshaller.java
index ace0e2b0d..8fa69e4da 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/AbstractSAMLObjectMarshaller.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/AbstractSAMLObjectMarshaller.java
@@ -17,6 +17,8 @@
package org.opensaml.saml.common;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectMarshaller;
import org.opensaml.core.xml.io.MarshallingException;
@@ -35,8 +37,8 @@ public abstract class AbstractSAMLObjectMarshaller extends AbstractXMLObjectMars
*
* {@inheritDoc}
*/
- protected void marshallAttributes(final XMLObject xmlObject, final Element domElement) throws MarshallingException {
-
+ protected void marshallAttributes(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
+ throws MarshallingException {
}
/**
@@ -45,13 +47,14 @@ public abstract class AbstractSAMLObjectMarshaller extends AbstractXMLObjectMars
*
* {@inheritDoc}
*/
- protected void marshallElementContent(final XMLObject xmlObject, final Element domElement)
+ protected void marshallElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
throws MarshallingException {
}
/** {@inheritDoc} */
- public Element marshall(final XMLObject xmlObject, final Document document) throws MarshallingException {
+ @Nonnull public Element marshall(@Nonnull final XMLObject xmlObject, @Nonnull final Document document)
+ throws MarshallingException {
if (xmlObject instanceof SignableSAMLObject) {
SAMLObjectSupport.declareNonVisibleNamespaces((SignableSAMLObject) xmlObject);
}
@@ -59,7 +62,8 @@ public abstract class AbstractSAMLObjectMarshaller extends AbstractXMLObjectMars
}
/** {@inheritDoc} */
- public Element marshall(final XMLObject xmlObject, final Element parentElement) throws MarshallingException {
+ @Nonnull public Element marshall(@Nonnull final XMLObject xmlObject, @Nonnull final Element parentElement)
+ throws MarshallingException {
if (xmlObject instanceof SignableSAMLObject) {
SAMLObjectSupport.declareNonVisibleNamespaces((SignableSAMLObject) xmlObject);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLObjectContentReference.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLObjectContentReference.java
index b335c22c4..d88d44b0f 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLObjectContentReference.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLObjectContentReference.java
@@ -21,13 +21,13 @@ import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import net.shibboleth.shared.annotation.constraint.Live;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.collection.LazyList;
import net.shibboleth.shared.collection.LazySet;
-import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
import org.apache.xml.security.signature.XMLSignature;
@@ -42,7 +42,6 @@ import org.opensaml.xmlsec.signature.support.ConfigurableContentReference;
import org.opensaml.xmlsec.signature.support.SignatureConstants;
import org.opensaml.xmlsec.signature.support.TransformsConfigurableContentReference;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.Strings;
@@ -83,7 +82,7 @@ public class SAMLObjectContentReference implements ConfigurableContentReference,
@Nonnull private final SignableSAMLObject signableObject;
/** Algorithm used to digest the content. */
- @Nonnull @NotEmpty private String digestAlgorithm;
+ @Nullable private String digestAlgorithm;
/** Transforms applied to the content. */
@Nonnull @NonnullElements private List<String> transforms;
@@ -114,14 +113,13 @@ public class SAMLObjectContentReference implements ConfigurableContentReference,
}
/** {@inheritDoc}. */
- @Nonnull @NotEmpty public String getDigestAlgorithm() {
+ @Nullable public String getDigestAlgorithm() {
return digestAlgorithm;
}
/** {@inheritDoc}. */
- public void setDigestAlgorithm(@Nonnull @NotEmpty final String newAlgorithm) {
- digestAlgorithm = Constraint.isNotNull(StringSupport.trimOrNull(newAlgorithm),
- "Digest algorithm cannot be empty or null");
+ public void setDigestAlgorithm(@Nullable final String newAlgorithm) {
+ digestAlgorithm = StringSupport.trimOrNull(newAlgorithm);
}
/** {@inheritDoc} */
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLObjectSupport.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLObjectSupport.java
index 051509f94..165c2bddf 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLObjectSupport.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLObjectSupport.java
@@ -22,10 +22,12 @@ import java.util.List;
import javax.annotation.Nonnull;
import org.opensaml.core.xml.Namespace;
+import org.opensaml.xmlsec.signature.Signature;
import org.opensaml.xmlsec.signature.support.ContentReference;
import org.opensaml.xmlsec.signature.support.SignatureConstants;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* A helper class for working with SAMLObjects.
@@ -54,24 +56,28 @@ public final class SAMLObjectSupport {
* @param signableObject the signable SAML object to evaluate
*/
public static void declareNonVisibleNamespaces(@Nonnull final SignableSAMLObject signableObject) {
- if (signableObject.getDOM() == null && signableObject.getSignature() != null) {
- LOG.debug("Examining signed object for content references with exclusive canonicalization transform");
- boolean sawExclusive = false;
- for (final ContentReference cr : signableObject.getSignature().getContentReferences()) {
- if (cr instanceof SAMLObjectContentReference) {
- final List<String> transforms = ((SAMLObjectContentReference)cr).getTransforms();
- if (transforms.contains(SignatureConstants.TRANSFORM_C14N_EXCL_WITH_COMMENTS)
- || transforms.contains(SignatureConstants.TRANSFORM_C14N_EXCL_OMIT_COMMENTS)) {
- sawExclusive = true;
- break;
+ if (signableObject.getDOM() == null) {
+ final Signature sig = signableObject.getSignature();
+ if (sig != null) {
+ LOG.debug("Examining signed object for content references with exclusive canonicalization transform");
+ boolean sawExclusive = false;
+ for (final ContentReference cr : sig.getContentReferences()) {
+ if (cr instanceof SAMLObjectContentReference) {
+ final List<String> transforms = ((SAMLObjectContentReference)cr).getTransforms();
+ if (transforms.contains(SignatureConstants.TRANSFORM_C14N_EXCL_WITH_COMMENTS)
+ || transforms.contains(SignatureConstants.TRANSFORM_C14N_EXCL_OMIT_COMMENTS)) {
+ sawExclusive = true;
+ break;
+ }
}
}
- }
-
- if (sawExclusive) {
- LOG.debug("Saw exclusive transform, declaring non-visible namespaces on signed object");
- for (final Namespace ns : signableObject.getNamespaceManager().getNonVisibleNamespaces()) {
- signableObject.getNamespaceManager().registerNamespaceDeclaration(ns);
+
+ if (sawExclusive) {
+ LOG.debug("Saw exclusive transform, declaring non-visible namespaces on signed object");
+ for (final Namespace ns : signableObject.getNamespaceManager().getNonVisibleNamespaces()) {
+ assert ns != null;
+ signableObject.getNamespaceManager().registerNamespaceDeclaration(ns);
+ }
}
}
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLVersion.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLVersion.java
index e309eba29..391e53608 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLVersion.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/SAMLVersion.java
@@ -65,7 +65,7 @@ public final class SAMLVersion {
*
* @return the SAMLVersion
*/
- public static final SAMLVersion valueOf(final int majorVersion, final int minorVersion) {
+ @Nonnull public static final SAMLVersion valueOf(final int majorVersion, final int minorVersion) {
if (majorVersion == 1) {
if (minorVersion == 0) {
return SAMLVersion.VERSION_10;
@@ -88,7 +88,7 @@ public final class SAMLVersion {
*
* @return SAMLVersion for the given string
*/
- public static final SAMLVersion valueOf(@Nonnull final String version) {
+ @Nonnull public static final SAMLVersion valueOf(@Nonnull final String version) {
final String[] components = version.split("\\.");
return valueOf(Integer.valueOf(components[0]), Integer.valueOf(components[1]));
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/assertion/ValidationProcessingData.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/assertion/ValidationProcessingData.java
index 21cb371f3..a4bbd160b 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/assertion/ValidationProcessingData.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/assertion/ValidationProcessingData.java
@@ -32,10 +32,10 @@ import net.shibboleth.shared.logic.Constraint;
public class ValidationProcessingData {
/** The validation context. */
- private ValidationContext context;
+ @Nonnull private ValidationContext context;
/** The validation result. */
- private ValidationResult result;
+ @Nonnull private ValidationResult result;
/**
* Constructor.
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/AbstractEndpointResolver.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/AbstractEndpointResolver.java
index b3f929a64..72ff60144 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/AbstractEndpointResolver.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/AbstractEndpointResolver.java
@@ -18,7 +18,6 @@
package org.opensaml.saml.common.binding;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -35,10 +34,11 @@ import org.opensaml.saml.criterion.RoleDescriptorCriterion;
import org.opensaml.saml.saml2.metadata.Endpoint;
import org.opensaml.saml.saml2.metadata.IndexedEndpoint;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.resolver.CriteriaSet;
import net.shibboleth.shared.resolver.ResolverException;
@@ -124,15 +124,16 @@ public abstract class AbstractEndpointResolver<EndpointType extends Endpoint>
/** {@inheritDoc} */
@Nonnull @NonnullElements public Iterable<EndpointType> resolve(@Nullable final CriteriaSet criteria)
throws ResolverException {
- validateCriteria(criteria);
+ final EndpointCriterion<EndpointType> endpointCriterion = validateCriteria(criteria);
+ assert criteria != null;
- if (canUseRequestedEndpoint(criteria)) {
- final EndpointType endpoint = (EndpointType) criteria.get(EndpointCriterion.class).getEndpoint();
+ if (canUseRequestedEndpoint(endpointCriterion)) {
+ final EndpointType endpoint = endpointCriterion.getEndpoint();
if (doCheckEndpoint(criteria, endpoint)) {
- return Collections.singletonList(endpoint);
+ return CollectionSupport.singletonList(endpoint);
}
log.debug("{} Requested endpoint was rejected by extended validation process", getLogPrefix());
- return Collections.emptyList();
+ return CollectionSupport.emptyList();
}
final List<EndpointType> candidates = getCandidatesFromMetadata(criteria);
@@ -150,10 +151,11 @@ public abstract class AbstractEndpointResolver<EndpointType extends Endpoint>
// Checkstyle: CyclomaticComplexity OFF
/** {@inheritDoc} */
@Nullable public EndpointType resolveSingle(@Nullable final CriteriaSet criteria) throws ResolverException {
- validateCriteria(criteria);
+ final EndpointCriterion<EndpointType> endpointCriterion = validateCriteria(criteria);
+ assert criteria != null;
- if (canUseRequestedEndpoint(criteria)) {
- final EndpointType endpoint = (EndpointType) criteria.get(EndpointCriterion.class).getEndpoint();
+ if (canUseRequestedEndpoint(endpointCriterion)) {
+ final EndpointType endpoint = endpointCriterion.getEndpoint();
if (doCheckEndpoint(criteria, endpoint)) {
return endpoint;
}
@@ -168,6 +170,7 @@ public abstract class AbstractEndpointResolver<EndpointType extends Endpoint>
final BestMatchLocationCriterion startsWith = criteria.get(BestMatchLocationCriterion.class);
for (final EndpointType candidate : getCandidatesFromMetadata(criteria)) {
+ assert candidate != null;
if (doCheckEndpoint(criteria, candidate)) {
if (startsWith != null) {
// Evaluate how good a match it is.
@@ -218,17 +221,22 @@ public abstract class AbstractEndpointResolver<EndpointType extends Endpoint>
*
* @param criteria input criteria set
*
+ * @return the {@link EndpointCriterion}
+ *
* @throws ResolverException if the input set is null or no {@link EndpointCriterion} is present
*/
- private void validateCriteria(@Nullable final CriteriaSet criteria) throws ResolverException {
+ @Nonnull private EndpointCriterion<EndpointType> validateCriteria(@Nullable final CriteriaSet criteria)
+ throws ResolverException {
if (criteria == null) {
throw new ResolverException("CriteriaSet cannot be null");
}
+ @SuppressWarnings("unchecked")
final EndpointCriterion<EndpointType> epCriterion = criteria.get(EndpointCriterion.class);
if (epCriterion == null) {
throw new ResolverException("EndpointCriterion not supplied");
}
+ return epCriterion;
}
/**
@@ -237,14 +245,13 @@ public abstract class AbstractEndpointResolver<EndpointType extends Endpoint>
* turn out to be unusable by the caller, but that's immaterial because the requester must have
* dictated the binding and location, so we're not allowed to ignore that.
*
- * @param criteria input criteria set
+ * @param criterion the input {@link EndpointCriterion}
*
* @return true iff the supplied endpoint via {@link EndpointCriterion} should be returned
*/
- private boolean canUseRequestedEndpoint(@Nonnull final CriteriaSet criteria) {
- final EndpointCriterion<EndpointType> epc = criteria.get(EndpointCriterion.class);
- if (epc.isTrusted()) {
- final EndpointType requestedEndpoint = epc.getEndpoint();
+ private boolean canUseRequestedEndpoint(@Nonnull final EndpointCriterion<EndpointType> criterion) {
+ if (criterion.isTrusted()) {
+ final EndpointType requestedEndpoint = criterion.getEndpoint();
if (requestedEndpoint.getBinding() != null && (requestedEndpoint.getLocation() != null
|| requestedEndpoint.getResponseLocation() != null)) {
return true;
@@ -276,7 +283,9 @@ public abstract class AbstractEndpointResolver<EndpointType extends Endpoint>
}
// Determine the QName type of endpoints to extract based on candidate type.
+ @SuppressWarnings("unchecked")
final EndpointCriterion<EndpointType> epCriterion = criteria.get(EndpointCriterion.class);
+ assert epCriterion != null;
QName endpointType = epCriterion.getEndpoint().getSchemaType();
if (endpointType == null) {
endpointType = epCriterion.getEndpoint().getElementQName();
@@ -308,7 +317,7 @@ public abstract class AbstractEndpointResolver<EndpointType extends Endpoint>
sortCandidates(
endpoints.stream()
.filter(ep -> binding.equals(ep.getBinding()))
- .collect(Collectors.toUnmodifiableList())));
+ .collect(CollectionSupport.nonnullCollector(Collectors.toUnmodifiableList())).get()));
}
log.debug("{} Returning {} candidate endpoints of type {}", getLogPrefix(), sortedResults.size(),
endpointType);
@@ -322,6 +331,7 @@ public abstract class AbstractEndpointResolver<EndpointType extends Endpoint>
*
* @return a new list containing the endpoints such that the default is first
*/
+ @SuppressWarnings("unchecked")
// Checkstyle: CyclomaticComplexity OFF
@Nonnull @NonnullElements private List<EndpointType> sortCandidates(
@Nonnull @NonnullElements final List<Endpoint> candidates) {
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java
index 46677fb68..51db2f83d 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java
@@ -36,13 +36,13 @@ import org.opensaml.saml.common.messaging.context.SAMLMessageReceivedEndpointCon
import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
import org.opensaml.saml.saml2.metadata.Endpoint;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.Strings;
import jakarta.servlet.http.HttpServletRequest;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
/** A support class for SAML binding operations. */
@@ -90,6 +90,7 @@ public final class SAMLBindingSupport {
*/
public static boolean checkRelayState(@Nullable final String relayState) {
if (!Strings.isNullOrEmpty(relayState)) {
+ assert relayState != null;
if (relayState.getBytes().length > 80) {
LOG.warn("Relay state exceeds 80 bytes: {}", relayState);
}
@@ -251,8 +252,11 @@ public final class SAMLBindingSupport {
*/
public static boolean isSigningCapableBinding(@Nonnull final MessageContext messageContext) {
final SAMLBindingContext bindingContext = messageContext.getSubcontext(SAMLBindingContext.class);
- if (bindingContext != null && bindingContext.getBindingDescriptor() != null) {
- return bindingContext.getBindingDescriptor().isSignatureCapable();
+ if (bindingContext != null) {
+ final BindingDescriptor bd = bindingContext.getBindingDescriptor();
+ if (bd != null) {
+ return bd.isSignatureCapable();
+ }
}
return false;
}
@@ -335,7 +339,10 @@ public final class SAMLBindingSupport {
final SAMLMessageReceivedEndpointContext receivedEnpointContext =
messageContext.getSubcontext(SAMLMessageReceivedEndpointContext.class);
if (receivedEnpointContext != null) {
- return receivedEnpointContext.getRequestURL();
+ final String url = receivedEnpointContext.getRequestURL();
+ if (url != null) {
+ return url;
+ }
}
return request.getRequestURL().toString();
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/artifact/AbstractSAMLArtifact.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/artifact/AbstractSAMLArtifact.java
index d9974fc3c..c495216ae 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/artifact/AbstractSAMLArtifact.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/artifact/AbstractSAMLArtifact.java
@@ -25,10 +25,10 @@ import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.codec.Base64Support;
import net.shibboleth.shared.codec.EncodingException;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import org.apache.commons.codec.binary.Hex;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Base class for SAML artifacts.
@@ -39,7 +39,7 @@ public abstract class AbstractSAMLArtifact implements SAMLArtifact {
@Nonnull private final Logger log = LoggerFactory.getLogger(AbstractSAMLArtifact.class);
/** 2 byte artifact type code. */
- private byte[] typeCode;
+ @Nonnull private byte[] typeCode;
/**
* Constructor.
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLArtifactContext.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLArtifactContext.java
index f019ec976..7eb1f0db6 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLArtifactContext.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLArtifactContext.java
@@ -66,8 +66,9 @@ public final class SAMLArtifactContext extends BaseContext {
*/
@Nullable @NotEmpty public String getSourceEntityId() {
if (sourceEntityId == null) {
- if (getParent() != null) {
- final SAMLSelfEntityContext self = getParent().getSubcontext(SAMLSelfEntityContext.class);
+ final BaseContext parent = getParent();
+ if (parent != null) {
+ final SAMLSelfEntityContext self = parent.getSubcontext(SAMLSelfEntityContext.class);
if (self != null) {
sourceEntityId = self.getEntityId();
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLMessageInfoContext.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLMessageInfoContext.java
index bc50fdf96..dcc52ffc4 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLMessageInfoContext.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLMessageInfoContext.java
@@ -100,25 +100,17 @@ public final class SAMLMessageInfoContext extends BaseContext {
@Nullable protected String resolveMessageId() {
final SAMLObject samlMessage = resolveSAMLMessage();
//SAML 2 Request
- if (samlMessage instanceof org.opensaml.saml.saml2.core.RequestAbstractType) {
- final org.opensaml.saml.saml2.core.RequestAbstractType request =
- (org.opensaml.saml.saml2.core.RequestAbstractType) samlMessage;
- return request.getID();
+ if (samlMessage instanceof org.opensaml.saml.saml2.core.RequestAbstractType msg) {
+ return msg.getID();
//SAML 2 Response
- } else if (samlMessage instanceof org.opensaml.saml.saml2.core.StatusResponseType) {
- final org.opensaml.saml.saml2.core.StatusResponseType response =
- (org.opensaml.saml.saml2.core.StatusResponseType) samlMessage;
- return response.getID();
+ } else if (samlMessage instanceof org.opensaml.saml.saml2.core.StatusResponseType msg) {
+ return msg.getID();
//SAML 1 Response
- } else if (samlMessage instanceof org.opensaml.saml.saml1.core.ResponseAbstractType) {
- final org.opensaml.saml.saml1.core.ResponseAbstractType response =
- (org.opensaml.saml.saml1.core.ResponseAbstractType) samlMessage;
- return response.getID();
+ } else if (samlMessage instanceof org.opensaml.saml.saml1.core.ResponseAbstractType msg) {
+ return msg.getID();
//SAML 1 Request
- } else if (samlMessage instanceof org.opensaml.saml.saml1.core.RequestAbstractType) {
- final org.opensaml.saml.saml1.core.RequestAbstractType request =
- (org.opensaml.saml.saml1.core.RequestAbstractType) samlMessage;
- return request.getID();
+ } else if (samlMessage instanceof org.opensaml.saml.saml1.core.RequestAbstractType msg) {
+ return msg.getID();
}
return null;
}
@@ -132,25 +124,17 @@ public final class SAMLMessageInfoContext extends BaseContext {
@Nullable protected Instant resolveIssueInstant() {
final SAMLObject samlMessage = resolveSAMLMessage();
//SAML 2 Request
- if (samlMessage instanceof org.opensaml.saml.saml2.core.RequestAbstractType) {
- final org.opensaml.saml.saml2.core.RequestAbstractType request =
- (org.opensaml.saml.saml2.core.RequestAbstractType) samlMessage;
- return request.getIssueInstant();
+ if (samlMessage instanceof org.opensaml.saml.saml2.core.RequestAbstractType msg) {
+ return msg.getIssueInstant();
//SAML 2 Response
- } else if (samlMessage instanceof org.opensaml.saml.saml2.core.StatusResponseType) {
- final org.opensaml.saml.saml2.core.StatusResponseType response =
- (org.opensaml.saml.saml2.core.StatusResponseType) samlMessage;
- return response.getIssueInstant();
+ } else if (samlMessage instanceof org.opensaml.saml.saml2.core.StatusResponseType msg) {
+ return msg.getIssueInstant();
//SAML 1 Response
- } else if (samlMessage instanceof org.opensaml.saml.saml1.core.ResponseAbstractType) {
- final org.opensaml.saml.saml1.core.ResponseAbstractType response =
- (org.opensaml.saml.saml1.core.ResponseAbstractType) samlMessage;
- return response.getIssueInstant();
+ } else if (samlMessage instanceof org.opensaml.saml.saml1.core.ResponseAbstractType msg) {
+ return msg.getIssueInstant();
//SAML 1 Request
- } else if (samlMessage instanceof org.opensaml.saml.saml1.core.RequestAbstractType) {
- final org.opensaml.saml.saml1.core.RequestAbstractType request =
- (org.opensaml.saml.saml1.core.RequestAbstractType) samlMessage;
- return request.getIssueInstant();
+ } else if (samlMessage instanceof org.opensaml.saml.saml1.core.RequestAbstractType msg) {
+ return msg.getIssueInstant();
}
return null;
@@ -162,10 +146,9 @@ public final class SAMLMessageInfoContext extends BaseContext {
* @return the SAML message, or null if it can not be resolved
*/
@Nullable protected SAMLObject resolveSAMLMessage() {
- if (getParent() instanceof MessageContext) {
- final MessageContext parent = (MessageContext) getParent();
- if (parent.getMessage() instanceof SAMLObject) {
- return (SAMLObject) parent.getMessage();
+ if (getParent() instanceof MessageContext p) {
+ if (p.getMessage() instanceof SAMLObject msg) {
+ return msg;
}
}
return null;
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLPeerEntityContext.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLPeerEntityContext.java
index 0ff8d2636..3a65f6ab7 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLPeerEntityContext.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLPeerEntityContext.java
@@ -23,6 +23,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
import org.opensaml.messaging.context.MessageContext;
@@ -32,7 +33,6 @@ import org.opensaml.saml.saml1.core.AuthorizationDecisionQuery;
import org.opensaml.saml.saml2.core.Issuer;
import org.opensaml.saml.saml2.core.NameIDType;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -99,25 +99,17 @@ public final class SAMLPeerEntityContext extends AbstractAuthenticatableSAMLEnti
@Nullable protected String resolveEntityId() {
final SAMLObject samlMessage = resolveSAMLMessage();
//SAML 2 Request
- if (samlMessage instanceof org.opensaml.saml.saml2.core.RequestAbstractType) {
- final org.opensaml.saml.saml2.core.RequestAbstractType request =
- (org.opensaml.saml.saml2.core.RequestAbstractType) samlMessage;
- return processSaml2Request(request);
+ if (samlMessage instanceof org.opensaml.saml.saml2.core.RequestAbstractType msg) {
+ return processSaml2Request(msg);
//SAML 2 Response
- } else if (samlMessage instanceof org.opensaml.saml.saml2.core.StatusResponseType) {
- final org.opensaml.saml.saml2.core.StatusResponseType response =
- (org.opensaml.saml.saml2.core.StatusResponseType) samlMessage;
- return processSaml2Response(response);
+ } else if (samlMessage instanceof org.opensaml.saml.saml2.core.StatusResponseType msg) {
+ return processSaml2Response(msg);
//SAML 1 Response
- } else if (samlMessage instanceof org.opensaml.saml.saml1.core.Response) {
- final org.opensaml.saml.saml1.core.Response response =
- (org.opensaml.saml.saml1.core.Response) samlMessage;
- return processSaml1Response(response);
+ } else if (samlMessage instanceof org.opensaml.saml.saml1.core.Response msg) {
+ return processSaml1Response(msg);
//SAML 1 Request
- } else if (samlMessage instanceof org.opensaml.saml.saml1.core.Request) {
- final org.opensaml.saml.saml1.core.Request request =
- (org.opensaml.saml.saml1.core.Request) samlMessage;
- return processSaml1Request(request);
+ } else if (samlMessage instanceof org.opensaml.saml.saml1.core.Request msg) {
+ return processSaml1Request(msg);
}
return null;
@@ -149,8 +141,8 @@ public final class SAMLPeerEntityContext extends AbstractAuthenticatableSAMLEnti
return processSaml2Issuer(statusResponse.getIssuer());
}
- if (statusResponse instanceof org.opensaml.saml.saml2.core.Response) {
- processSaml2ResponseAssertions((org.opensaml.saml.saml2.core.Response)statusResponse);
+ if (statusResponse instanceof org.opensaml.saml.saml2.core.Response msg) {
+ processSaml2ResponseAssertions(msg);
}
@@ -259,15 +251,15 @@ public final class SAMLPeerEntityContext extends AbstractAuthenticatableSAMLEnti
*/
@Nullable protected String processSaml1Request(@Nonnull final org.opensaml.saml.saml1.core.Request request) {
String entityId = null;
- if (request.getAttributeQuery() != null) {
- entityId = processSaml1AttributeQuery(request.getAttributeQuery());
+ if (request.getAttributeQuery() instanceof AttributeQuery q) {
+ entityId = processSaml1AttributeQuery(q);
if (entityId != null) {
return entityId;
}
}
- if (request.getAuthorizationDecisionQuery() != null) {
- entityId = processSaml1AuthorizationDecisionQuery(request.getAuthorizationDecisionQuery());
+ if (request.getAuthorizationDecisionQuery() instanceof AuthorizationDecisionQuery q) {
+ entityId = processSaml1AuthorizationDecisionQuery(q);
if (entityId != null) {
return entityId;
}
@@ -322,10 +314,9 @@ public final class SAMLPeerEntityContext extends AbstractAuthenticatableSAMLEnti
* @return the SAML message, or null if it can not be resolved
*/
@Nullable protected SAMLObject resolveSAMLMessage() {
- if (getParent() instanceof MessageContext) {
- final MessageContext parent = (MessageContext) getParent();
- if (parent.getMessage() instanceof SAMLObject) {
- return (SAMLObject) parent.getMessage();
+ if (getParent() instanceof MessageContext mc) {
+ if (mc.getMessage() instanceof SAMLObject msg) {
+ return msg;
}
}
return null;
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLSubjectNameIdentifierContext.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLSubjectNameIdentifierContext.java
index 487fdb195..6243f475e 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLSubjectNameIdentifierContext.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLSubjectNameIdentifierContext.java
@@ -17,6 +17,7 @@
package org.opensaml.saml.common.messaging.context;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensaml.messaging.context.BaseContext;
@@ -27,7 +28,8 @@ import org.opensaml.saml.saml1.core.Request;
import org.opensaml.saml.saml2.core.LogoutRequest;
import org.opensaml.saml.saml2.core.NameID;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* A context implementation which represents a SAML 1 {@link NameIdentifier} or a SAML 2 {@link NameID}.
@@ -48,7 +50,7 @@ import org.slf4j.LoggerFactory;
public final class SAMLSubjectNameIdentifierContext extends BaseContext {
/** Logger. */
- @Nullable private Logger log = LoggerFactory.getLogger(SAMLSubjectNameIdentifierContext.class);
+ @Nonnull private Logger log = LoggerFactory.getLogger(SAMLSubjectNameIdentifierContext.class);
/** The SAML name identifier represented by this context. */
@Nullable private SAMLObject nameID;
@@ -132,24 +134,20 @@ public final class SAMLSubjectNameIdentifierContext extends BaseContext {
log.debug("SAML message could not be dynamically resolved from parent context");
return null;
}
- if (samlMessage instanceof org.opensaml.saml.saml2.core.SubjectQuery) {
- final org.opensaml.saml.saml2.core.SubjectQuery query =
- (org.opensaml.saml.saml2.core.SubjectQuery) samlMessage;
- if (query.getSubject() != null) {
- return query.getSubject().getNameID();
+ if (samlMessage instanceof org.opensaml.saml.saml2.core.SubjectQuery msg) {
+ if (msg.getSubject() instanceof org.opensaml.saml.saml2.core.Subject s) {
+ return s.getNameID();
}
return null;
- } else if (samlMessage instanceof org.opensaml.saml.saml2.core.AuthnRequest) {
- final org.opensaml.saml.saml2.core.AuthnRequest request =
- (org.opensaml.saml.saml2.core.AuthnRequest) samlMessage;
- if (request.getSubject() != null) {
- return request.getSubject().getNameID();
+ } else if (samlMessage instanceof org.opensaml.saml.saml2.core.AuthnRequest msg) {
+ if (msg.getSubject() instanceof org.opensaml.saml.saml2.core.Subject s) {
+ return s.getNameID();
}
return null;
- } else if (samlMessage instanceof Request && ((Request) samlMessage).getSubjectQuery() != null) {
- final org.opensaml.saml.saml1.core.SubjectQuery query = ((Request) samlMessage).getSubjectQuery();
- if (query.getSubject() != null) {
- return query.getSubject().getNameIdentifier();
+ } else if (samlMessage instanceof Request msg) {
+ final org.opensaml.saml.saml1.core.SubjectQuery query = msg.getSubjectQuery();
+ if (query != null && query.getSubject() instanceof org.opensaml.saml.saml1.core.Subject s) {
+ return s.getNameIdentifier();
}
return null;
} else if (samlMessage instanceof LogoutRequest) {
@@ -167,10 +165,9 @@ public final class SAMLSubjectNameIdentifierContext extends BaseContext {
* @return the SAML message, or null if it can not be resolved
*/
@Nullable protected SAMLObject resolveSAMLMessage() {
- if (getParent() instanceof MessageContext) {
- final MessageContext parent = (MessageContext) getParent();
- if (parent.getMessage() instanceof SAMLObject) {
- return (SAMLObject) parent.getMessage();
+ if (getParent() instanceof MessageContext mc) {
+ if (mc.getMessage() instanceof SAMLObject msg) {
+ return msg;
}
}
return null;
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/soap/SAMLSOAPClientContextBuilder.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/soap/SAMLSOAPClientContextBuilder.java
index d6fcf61b9..8054c382f 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/soap/SAMLSOAPClientContextBuilder.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/soap/SAMLSOAPClientContextBuilder.java
@@ -61,34 +61,34 @@ public class SAMLSOAPClientContextBuilder<InboundMessageType extends SAMLObject,
OutboundMessageType extends SAMLObject> {
/** The outbound message. **/
- private OutboundMessageType outboundMessage;
+ @Nullable private OutboundMessageType outboundMessage;
/** The SAML protocol in use. */
- private String protocol;
+ @Nullable private String protocol;
/** The SAML self entityID. **/
- private String selfEntityID;
+ @Nullable private String selfEntityID;
/** The SAML peer entityID. **/
- private String peerEntityID;
+ @Nullable private String peerEntityID;
/** The SAML peer entity role. **/
- private QName peerEntityRole;
+ @Nullable private QName peerEntityRole;
/** The SAML peer EntityDescriptor. **/
- private EntityDescriptor peerEntityDescriptor;
+ @Nullable private EntityDescriptor peerEntityDescriptor;
/** The SAML peer RoleDescriptor. **/
- private RoleDescriptor peerRoleDescriptor;
+ @Nullable private RoleDescriptor peerRoleDescriptor;
/** TLS CriteriaSet strategy. */
- private Function<MessageContext,CriteriaSet> tlsCriteriaSetStrategy;
+ @Nullable private Function<MessageContext,CriteriaSet> tlsCriteriaSetStrategy;
/** SOAP client message pipeline name. */
- private String pipelineName;
+ @Nullable private String pipelineName;
/** SOAP client security configuration profile ID. */
- private String securityConfigurationProfileId;
+ @Nullable private String securityConfigurationProfileId;
/**
* Get the outbound message.
@@ -161,8 +161,8 @@ public class SAMLSOAPClientContextBuilder<InboundMessageType extends SAMLObject,
@Nullable public String getPeerEntityID() {
if (peerEntityID != null) {
return peerEntityID;
- } else if (getPeerEntityDescriptor() != null) {
- return getPeerEntityDescriptor().getEntityID();
+ } else if (getPeerEntityDescriptor() instanceof EntityDescriptor ed) {
+ return ed.getEntityID();
} else {
return null;
}
@@ -188,11 +188,11 @@ public class SAMLSOAPClientContextBuilder<InboundMessageType extends SAMLObject,
@Nullable public QName getPeerEntityRole() {
if (peerEntityRole != null) {
return peerEntityRole;
- } else if (getPeerRoleDescriptor() != null) {
- if (getPeerRoleDescriptor().getSchemaType() != null) {
- return getPeerRoleDescriptor().getSchemaType();
+ } else if (getPeerRoleDescriptor() instanceof RoleDescriptor rd) {
+ if (rd.getSchemaType() != null) {
+ return rd.getSchemaType();
}
- return getPeerRoleDescriptor().getElementQName();
+ return rd.getElementQName();
} else {
return null;
}
@@ -218,10 +218,10 @@ public class SAMLSOAPClientContextBuilder<InboundMessageType extends SAMLObject,
@Nullable public EntityDescriptor getPeerEntityDescriptor() {
if (peerEntityDescriptor != null) {
return peerEntityDescriptor;
- } else if (getPeerRoleDescriptor() != null) {
- final XMLObject roleParent = getPeerRoleDescriptor().getParent();
- if (roleParent instanceof EntityDescriptor) {
- return (EntityDescriptor) roleParent;
+ } else if (getPeerRoleDescriptor() instanceof RoleDescriptor rd) {
+ final XMLObject roleParent = rd.getParent();
+ if (roleParent instanceof EntityDescriptor ed) {
+ return ed;
}
}
return null;
@@ -423,21 +423,24 @@ public class SAMLSOAPClientContextBuilder<InboundMessageType extends SAMLObject,
final SAMLProtocolContext protocolContext = parent.getSubcontext(SAMLProtocolContext.class);
if (protocolContext != null && protocolContext.getProtocol() != null) {
- criteria.add(new ProtocolCriterion(protocolContext.getProtocol()));
+ final String protocol = protocolContext.getProtocol();
+ if (protocol != null) {
+ criteria.add(new ProtocolCriterion(protocol));
+ }
}
final SAMLPeerEntityContext peerContext = parent.getSubcontext(SAMLPeerEntityContext.class);
if (peerContext != null) {
- if (peerContext.getEntityId() != null) {
- criteria.add(new EntityIdCriterion(peerContext.getEntityId()));
+ if (peerContext.getEntityId() instanceof String s) {
+ criteria.add(new EntityIdCriterion(s));
}
- if (peerContext.getRole() != null) {
- criteria.add(new EntityRoleCriterion(peerContext.getRole()));
+ if (peerContext.getRole() instanceof QName role) {
+ criteria.add(new EntityRoleCriterion(role));
}
final SAMLMetadataContext metadataContext = peerContext.getSubcontext(SAMLMetadataContext.class);
- if (metadataContext != null && metadataContext.getRoleDescriptor() != null) {
- criteria.add(new RoleDescriptorCriterion(metadataContext.getRoleDescriptor()));
+ if (metadataContext != null && metadataContext.getRoleDescriptor() instanceof RoleDescriptor role) {
+ criteria.add(new RoleDescriptorCriterion(role));
}
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/AbstractNameIdentifierGenerator.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/AbstractNameIdentifierGenerator.java
index 6156bb647..022baa91a 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/AbstractNameIdentifierGenerator.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/AbstractNameIdentifierGenerator.java
@@ -27,14 +27,12 @@ import javax.annotation.Nullable;
import org.opensaml.profile.context.ProfileRequestContext;
import org.opensaml.saml.common.SAMLException;
import org.opensaml.saml.common.SAMLObject;
+import org.opensaml.saml.saml2.core.NameIDType;
-import com.google.common.base.Predicates;
-
-import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
-import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.logic.PredicateSupport;
import net.shibboleth.shared.primitive.StringSupport;
/**
@@ -69,7 +67,7 @@ public abstract class AbstractNameIdentifierGenerator<NameIdType extends SAMLObj
private boolean omitQualifiers;
/** The identifier Format supported. */
- @NonnullAfterInit @NotEmpty private String format;
+ @Nonnull @NotEmpty private String format;
/** Explicit NameQualifier, if any. */
@Nullable private String idpNameQualifier;
@@ -82,7 +80,8 @@ public abstract class AbstractNameIdentifierGenerator<NameIdType extends SAMLObj
/** Constructor. */
protected AbstractNameIdentifierGenerator() {
- activationCondition = Predicates.alwaysTrue();
+ activationCondition = PredicateSupport.alwaysTrue();
+ format = NameIDType.UNSPECIFIED;
}
/**
@@ -161,7 +160,7 @@ public abstract class AbstractNameIdentifierGenerator<NameIdType extends SAMLObj
}
/** {@inheritDoc} */
- @Override @NonnullAfterInit @NotEmpty public String getFormat() {
+ @Nonnull @NotEmpty public String getFormat() {
return format;
}
@@ -245,16 +244,6 @@ public abstract class AbstractNameIdentifierGenerator<NameIdType extends SAMLObj
spProvidedId = id;
}
- /** {@inheritDoc} */
- @Override
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- if (format == null) {
- throw new ComponentInitializationException("Format value cannot be null or empty");
- }
- }
-
/** {@inheritDoc} */
public boolean test(@Nullable final ProfileRequestContext input) {
return activationCondition.test(input);
@@ -309,9 +298,8 @@ public abstract class AbstractNameIdentifierGenerator<NameIdType extends SAMLObj
@Nonnull final ProfileRequestContext profileRequestContext) {
if (idpNameQualifier != null) {
if (omitQualifiers) {
- if (defaultIdPNameQualifierLookupStrategy == null
- || !Objects.equals(idpNameQualifier,
- defaultIdPNameQualifierLookupStrategy.apply(profileRequestContext))) {
+ final Function<ProfileRequestContext,String> strategy = defaultIdPNameQualifierLookupStrategy;
+ if (strategy == null || !Objects.equals(idpNameQualifier, strategy.apply(profileRequestContext))) {
return idpNameQualifier;
}
return null;
@@ -334,9 +322,8 @@ public abstract class AbstractNameIdentifierGenerator<NameIdType extends SAMLObj
@Nullable protected String getEffectiveSPNameQualifier(@Nonnull final ProfileRequestContext profileRequestContext) {
if (spNameQualifier != null) {
if (omitQualifiers) {
- if (defaultSPNameQualifierLookupStrategy == null
- || !Objects.equals(spNameQualifier,
- defaultSPNameQualifierLookupStrategy.apply(profileRequestContext))) {
+ final Function<ProfileRequestContext,String> strategy = defaultSPNameQualifierLookupStrategy;
+ if (strategy == null || !Objects.equals(spNameQualifier, strategy.apply(profileRequestContext))) {
return spNameQualifier;
}
return null;
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AbstractNameIDPolicyPredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AbstractNameIDPolicyPredicate.java
index 9e0d00e46..a1d29a95d 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AbstractNameIDPolicyPredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AbstractNameIDPolicyPredicate.java
@@ -33,13 +33,13 @@ import org.opensaml.saml.saml1.core.NameIdentifier;
import org.opensaml.saml.saml2.core.NameID;
import org.opensaml.saml.saml2.core.NameIDPolicy;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.component.AbstractInitializableComponent;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
/**
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AffiliationNameIDPolicyPredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AffiliationNameIDPolicyPredicate.java
index 31bf0cbf0..313c16214 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AffiliationNameIDPolicyPredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AffiliationNameIDPolicyPredicate.java
@@ -28,11 +28,11 @@ import org.opensaml.saml.saml2.metadata.AffiliateMember;
import org.opensaml.saml.saml2.metadata.AffiliationDescriptor;
import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.resolver.CriteriaSet;
import net.shibboleth.shared.resolver.ResolverException;
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/DefaultLocalErrorPredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/DefaultLocalErrorPredicate.java
index caa6b2c08..1ef9ff409 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/DefaultLocalErrorPredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/DefaultLocalErrorPredicate.java
@@ -18,7 +18,6 @@
package org.opensaml.saml.common.profile.logic;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function;
@@ -35,9 +34,12 @@ import org.opensaml.saml.common.messaging.context.SAMLBindingContext;
import org.opensaml.saml.common.messaging.context.SAMLEndpointContext;
import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
import org.opensaml.saml.saml2.core.AuthnRequest;
+import org.opensaml.saml.saml2.metadata.Endpoint;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
import java.util.function.Predicate;
@@ -45,7 +47,6 @@ import java.util.function.Predicate;
import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.messaging.context.navigate.MessageLookup;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Predicate that decides whether to handle an error by returning a SAML response to a requester
@@ -87,7 +88,7 @@ public class DefaultLocalErrorPredicate implements Predicate<ProfileRequestConte
eventContextLookupStrategy = new CurrentOrPreviousEventLookup();
- localEvents = Collections.emptySet();
+ localEvents = CollectionSupport.emptySet();
}
/**
@@ -145,9 +146,8 @@ public class DefaultLocalErrorPredicate implements Predicate<ProfileRequestConte
}
final SAMLEndpointContext endpointCtx = endpointContextLookupStrategy.apply(input);
- if (endpointCtx == null || endpointCtx.getEndpoint() == null ||
- (endpointCtx.getEndpoint().getLocation() == null
- && endpointCtx.getEndpoint().getResponseLocation() == null)) {
+ final Endpoint endpoint = endpointCtx != null ? endpointCtx.getEndpoint() : null;
+ if (endpoint == null || (endpoint.getLocation() == null && endpoint.getResponseLocation() == null)) {
log.debug("No SAMLEndpointContext or endpoint location available, error must be handled locally");
return true;
}
@@ -160,12 +160,13 @@ public class DefaultLocalErrorPredicate implements Predicate<ProfileRequestConte
}
final EventContext eventCtx = eventContextLookupStrategy.apply(input);
- if (eventCtx == null || eventCtx.getEvent() == null) {
+ final Object eObject = eventCtx != null ? eventCtx.getEvent() : null;
+ if (eObject == null) {
log.debug("No event found, assuming error handled with response");
return false;
}
- final String event = eventCtx.getEvent().toString();
+ final String event = eObject.toString();
if (localEvents.contains(event)) {
log.debug("Error event {} will be handled locally", event);
return true;
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/DefaultNameIDPolicyPredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/DefaultNameIDPolicyPredicate.java
index 9ce93cc70..698120d12 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/DefaultNameIDPolicyPredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/DefaultNameIDPolicyPredicate.java
@@ -21,7 +21,8 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import net.shibboleth.shared.primitive.LoggerFactory;
/** Policy that requires that qualifiers, if set, match the requester and responder. */
public class DefaultNameIDPolicyPredicate extends AbstractNameIDPolicyPredicate {
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java
index b19be39c5..f6266e4d7 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java
@@ -31,6 +31,7 @@ import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.schema.XSAny;
import org.opensaml.core.xml.schema.XSBase64Binary;
import org.opensaml.core.xml.schema.XSBoolean;
+import org.opensaml.core.xml.schema.XSBooleanValue;
import org.opensaml.core.xml.schema.XSDateTime;
import org.opensaml.core.xml.schema.XSInteger;
import org.opensaml.core.xml.schema.XSString;
@@ -41,7 +42,6 @@ import org.opensaml.saml.saml2.metadata.EntitiesDescriptor;
import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.opensaml.saml.saml2.metadata.Extensions;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.collect.Iterables;
@@ -50,7 +50,9 @@ import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.xml.DOMTypeSupport;
@@ -81,11 +83,7 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
*/
public EntityAttributesPredicate(
@Nonnull @NonnullElements @ParameterName(name="candidates") final Collection<Candidate> candidates) {
-
- candidateSet = List.copyOf(Constraint.isNotNull(candidates, "Candidate collection cannot be null"));
-
- trimTags = true;
- matchAll = false;
+ this(candidates, true, false);
}
/**
@@ -97,11 +95,7 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
public EntityAttributesPredicate(
@Nonnull @NonnullElements @ParameterName(name="candidates") final Collection<Candidate> candidates,
@ParameterName(name="trim") final boolean trim) {
-
- candidateSet = List.copyOf(Constraint.isNotNull(candidates, "Candidate collection cannot be null"));
-
- trimTags = trim;
- matchAll = false;
+ this(candidates, trim, false);
}
/**
@@ -116,7 +110,7 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
@ParameterName(name="trim") final boolean trim,
@ParameterName(name="all") final boolean all) {
- candidateSet = List.copyOf(Constraint.isNotNull(candidates, "Candidate collection cannot be null"));
+ candidateSet = CollectionSupport.copyToList(Constraint.isNotNull(candidates, "Candidate collection cannot be null"));
trimTags = trim;
matchAll = all;
@@ -234,8 +228,8 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
nam = Constraint.isNotNull(StringSupport.trimOrNull(name), "Attribute Name cannot be null or empty");
nameFormat = null;
- values = Collections.emptyList();
- regexps = Collections.emptyList();
+ values = CollectionSupport.emptyList();
+ regexps = CollectionSupport.emptyList();
}
/**
@@ -253,8 +247,8 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
nameFormat = StringSupport.trimOrNull(format);
}
- values = Collections.emptyList();
- regexps = Collections.emptyList();
+ values = CollectionSupport.emptyList();
+ regexps = CollectionSupport.emptyList();
}
/**
@@ -290,7 +284,7 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
* @param vals the exact values to match
*/
public void setValues(@Nonnull @NonnullElements final Collection<String> vals) {
- values = List.copyOf(Constraint.isNotNull(vals, "Values collection cannot be null"));
+ values = CollectionSupport.copyToList(Constraint.isNotNull(vals, "Values collection cannot be null"));
}
/**
@@ -308,7 +302,7 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
* @param exps the regular expressions to match
*/
public void setRegexps(@Nonnull @NonnullElements final Collection<Pattern> exps) {
- regexps = List.copyOf(Constraint.isNotNull(exps, "Regular expressions collection cannot be null"));
+ regexps = CollectionSupport.copyToList(Constraint.isNotNull(exps, "Regular expressions collection cannot be null"));
}
}
@@ -332,7 +326,11 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
// Checkstyle: MethodLength OFF
/** {@inheritDoc} */
- public boolean test(@Nonnull final Candidate input) {
+ public boolean test(@Nullable final Candidate input) {
+ if (input == null) {
+ return false;
+ }
+
final List<String> tagvals = input.values;
final List<Pattern> tagexps = input.regexps;
@@ -344,7 +342,7 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
for (final Attribute a : attributes) {
// Compare Name and NameFormat for a matching tag.
if (a.getName() != null && a.getName().equals(input.getName())
- && (input.getNameFormat() == null || input.getNameFormat().equals(a.getNameFormat()))) {
+ && (input.getNameFormat() == null || a.getNameFormat().equals(input.getNameFormat()))) {
final List<String> attributeValues = getPossibleAttributeValuesAsStrings(a);
// Check each tag value's simple content for a value match.
@@ -412,6 +410,7 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
final List<XMLObject> cvals = attribute.getAttributeValues();
final List<String> result = new ArrayList<>(cvals.size()*2);
for (final XMLObject cval : cvals) {
+ assert cval != null;
result.addAll(xmlObjectToStrings(cval));
}
return result;
@@ -426,15 +425,15 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
@Nullable private List<String> xmlObjectToStrings(@Nonnull final XMLObject object) {
String toMatch = null;
String toMatchAlt = null;
- if (object instanceof XSString) {
- toMatch = ((XSString) object).getValue();
- } else if (object instanceof XSURI) {
- toMatch = ((XSURI) object).getURI();
- } else if (object instanceof XSBoolean) {
- toMatch = ((XSBoolean) object).getValue().getValue() ? "1" : "0";
- toMatchAlt = ((XSBoolean) object).getValue().getValue() ? "true" : "false";
- } else if (object instanceof XSInteger) {
- toMatch = ((XSInteger) object).getValue().toString();
+ if (object instanceof XSString xs) {
+ toMatch = xs.getValue();
+ } else if (object instanceof XSURI xs) {
+ toMatch = xs.getURI();
+ } else if (object instanceof XSBoolean xs && xs.getValue() instanceof XSBooleanValue val) {
+ toMatch = val.getValue() ? "1" : "0";
+ toMatchAlt = val.getValue() ? "true" : "false";
+ } else if (object instanceof XSInteger xs && xs.getValue() instanceof Integer val) {
+ toMatch = val.toString();
} else if (object instanceof XSDateTime) {
final Instant dt = ((XSDateTime) object).getValue();
if (dt != null) {
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityGroupNamePredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityGroupNamePredicate.java
index 25399b82c..7511e0744 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityGroupNamePredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityGroupNamePredicate.java
@@ -32,12 +32,13 @@ import org.opensaml.saml.saml2.metadata.AffiliateMember;
import org.opensaml.saml.saml2.metadata.AffiliationDescriptor;
import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import net.shibboleth.shared.annotation.ParameterName;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.resolver.CriteriaSet;
import net.shibboleth.shared.resolver.ResolverException;
@@ -80,12 +81,14 @@ public class EntityGroupNamePredicate implements Predicate<EntityDescriptor> {
public EntityGroupNamePredicate(@Nullable @ParameterName(name="names") final Collection<String> names,
@Nullable @ParameterName(name="resolver") final MetadataResolver resolver) {
- groupNames = Set.copyOf(StringSupport.normalizeStringCollection(names));
+ groupNames = CollectionSupport.copyToSet(StringSupport.normalizeStringCollection(names));
metadataResolver = resolver;
if (resolver != null) {
criteriaSets = new ArrayList<>(groupNames.size());
for (final String name : groupNames) {
+ assert name != null;
+ assert criteriaSets != null;
criteriaSets.add(new CriteriaSet(new EntityIdCriterion(name)));
}
}
@@ -117,12 +120,15 @@ public class EntityGroupNamePredicate implements Predicate<EntityDescriptor> {
}
if (metadataResolver != null) {
+ assert criteriaSets != null;
for (final CriteriaSet criteria : criteriaSets) {
try {
+ assert metadataResolver != null;
final EntityDescriptor affiliation = metadataResolver.resolveSingle(criteria);
if (affiliation != null && affiliation.getAffiliationDescriptor() != null) {
for (final AffiliateMember member : affiliation.getAffiliationDescriptor().getMembers()) {
- if (member.getURI().equals(input.getEntityID())) {
+ final String uri = member.getURI();
+ if (uri != null && uri.equals(input.getEntityID())) {
log.debug("Found AffiliationDescriptor '{}' membership for entity '{}'",
affiliation.getEntityID(), input.getEntityID());
return true;
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityIdPredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityIdPredicate.java
index 117f2f501..3685f0cc3 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityIdPredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityIdPredicate.java
@@ -29,6 +29,7 @@ import net.shibboleth.shared.annotation.ParameterName;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.primitive.StringSupport;
import java.util.function.Predicate;
@@ -46,7 +47,7 @@ public class EntityIdPredicate implements Predicate<EntityDescriptor> {
* @param ids the entityIDs to check for
*/
public EntityIdPredicate(@Nullable @ParameterName(name="ids") final Collection<String> ids) {
- entityIds = Set.copyOf(StringSupport.normalizeStringCollection(ids));
+ entityIds = CollectionSupport.copyToSet(StringSupport.normalizeStringCollection(ids));
}
/**
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/InboundMessageSignedPredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/InboundMessageSignedPredicate.java
index 196b1cf1f..c2169ddb0 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/InboundMessageSignedPredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/InboundMessageSignedPredicate.java
@@ -21,6 +21,7 @@ import java.util.function.Predicate;
import javax.annotation.Nullable;
+import org.opensaml.messaging.context.MessageContext;
import org.opensaml.profile.context.ProfileRequestContext;
import org.opensaml.saml.common.binding.SAMLBindingSupport;
@@ -44,11 +45,13 @@ public class InboundMessageSignedPredicate implements Predicate<ProfileRequestCo
}
/** {@inheritDoc} */
- public boolean test(@Nullable final ProfileRequestContext prc) {
- if (prc == null || prc.getInboundMessageContext() == null) {
- return false;
+ public boolean test(@Nullable final ProfileRequestContext input) {
+
+ if (input != null && input.getInboundMessageContext() instanceof MessageContext mc) {
+ return SAMLBindingSupport.isMessageSigned(mc, presenceSatisfies);
}
- return SAMLBindingSupport.isMessageSigned(prc.getInboundMessageContext(), presenceSatisfies);
+
+ return false;
}
-}
+}
\ No newline at end of file
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/MetadataNameIdentifierFormatStrategy.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/MetadataNameIdentifierFormatStrategy.java
index 5ae176774..053600fef 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/MetadataNameIdentifierFormatStrategy.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/MetadataNameIdentifierFormatStrategy.java
@@ -18,13 +18,13 @@
package org.opensaml.saml.common.profile.logic;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.opensaml.messaging.context.MessageContext;
import org.opensaml.profile.context.ProfileRequestContext;
import org.opensaml.saml.common.messaging.context.SAMLMetadataContext;
import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
@@ -32,10 +32,11 @@ import org.opensaml.saml.saml2.core.NameID;
import org.opensaml.saml.saml2.metadata.NameIDFormat;
import org.opensaml.saml.saml2.metadata.SSODescriptor;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* Function to return a set of candidate NameIdentifier/NameID Format values derived from an entity's
@@ -72,7 +73,7 @@ public class MetadataNameIdentifierFormatStrategy implements Function<ProfileReq
if (nif.getURI() != null) {
if (NameID.UNSPECIFIED.equals(nif.getURI())) {
log.warn("Ignoring NameIDFormat metadata that includes the 'unspecified' format");
- return Collections.emptyList();
+ return CollectionSupport.emptyList();
}
strings.add(nif.getURI());
}
@@ -82,7 +83,7 @@ public class MetadataNameIdentifierFormatStrategy implements Function<ProfileReq
return strings;
}
- return Collections.emptyList();
+ return CollectionSupport.emptyList();
}
/**
@@ -93,9 +94,8 @@ public class MetadataNameIdentifierFormatStrategy implements Function<ProfileReq
/** {@inheritDoc} */
@Override
@Nullable public SSODescriptor apply(@Nullable final ProfileRequestContext input) {
- if (input != null && input.getInboundMessageContext() != null) {
- final SAMLPeerEntityContext peerCtx =
- input.getInboundMessageContext().getSubcontext(SAMLPeerEntityContext.class);
+ if (input != null && input.getInboundMessageContext() instanceof MessageContext mc) {
+ final SAMLPeerEntityContext peerCtx = mc.getSubcontext(SAMLPeerEntityContext.class);
if (peerCtx != null) {
final SAMLMetadataContext mdCtx = peerCtx.getSubcontext(SAMLMetadataContext.class);
if (mdCtx != null && mdCtx.getRoleDescriptor() != null
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationAuthorityPredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationAuthorityPredicate.java
index e24bf5176..cfbcc403d 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationAuthorityPredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationAuthorityPredicate.java
@@ -29,6 +29,7 @@ import net.shibboleth.shared.annotation.ParameterName;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.primitive.StringSupport;
/**
@@ -45,8 +46,8 @@ public class RegistrationAuthorityPredicate extends AbstractRegistrationInfoPre
*
* @param names the authority names to test for
*/
- public RegistrationAuthorityPredicate(@Nullable at ParameterName(name="names") final Collection<String> names) {
- authorities = Set.copyOf(StringSupport.normalizeStringCollection(names));
+ public RegistrationAuthorityPredicate(@Nullable @ParameterName(name="names") final Collection<String> names) {
+ authorities = CollectionSupport.copyToSet(StringSupport.normalizeStringCollection(names));
}
/**
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationPolicyPredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationPolicyPredicate.java
index e3dd898fc..59e9b2934 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationPolicyPredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationPolicyPredicate.java
@@ -30,6 +30,7 @@ import net.shibboleth.shared.annotation.ParameterName;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.primitive.StringSupport;
/**
@@ -47,7 +48,7 @@ public class RegistrationPolicyPredicate extends AbstractRegistrationInfoPredica
* @param policies the policies to test for
*/
public RegistrationPolicyPredicate(@Nullable @ParameterName(name="policies") final Collection<String> policies) {
- policySet = Set.copyOf(StringSupport.normalizeStringCollection(policies));
+ policySet = CollectionSupport.copyToSet(StringSupport.normalizeStringCollection(policies));
}
/**
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLConstants.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLConstants.java
index 5e9c412ff..b4a1de1b6 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLConstants.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLConstants.java
@@ -82,19 +82,23 @@ public final class SAMLConstants {
// SAML 1.X
// ****************************
/** SAML 1.0 Assertion schema system Id. */
- @Nonnull @NotEmpty public static final String SAML10_SCHEMA_LOCATION = SCHEMA_DIR + "oasis-sstc-saml-schema-assertion-1.0.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML10_SCHEMA_LOCATION = SCHEMA_DIR + "oasis-sstc-saml-schema-assertion-1.0.xsd";
/** SAML 1.1 Assertion schema system Id. */
- @Nonnull @NotEmpty public static final String SAML11_SCHEMA_LOCATION = SCHEMA_DIR + "oasis-sstc-saml-schema-assertion-1.1.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML11_SCHEMA_LOCATION = SCHEMA_DIR + "oasis-sstc-saml-schema-assertion-1.1.xsd";
/** SAML 1.X XML namespace. */
@Nonnull @NotEmpty public static final String SAML1_NS = "urn:oasis:names:tc:SAML:1.0:assertion";
/** SAML 1.0 Protocol schema system Id. */
- @Nonnull @NotEmpty public static final String SAML10P_SCHEMA_LOCATION = SCHEMA_DIR + "oasis-sstc-saml-schema-protocol-1.0.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML10P_SCHEMA_LOCATION = SCHEMA_DIR + "oasis-sstc-saml-schema-protocol-1.0.xsd";
/** SAML 1.1 Protocol schema system Id. */
- @Nonnull @NotEmpty public static final String SAML11P_SCHEMA_LOCATION = SCHEMA_DIR + "oasis-sstc-saml-schema-protocol-1.1.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML11P_SCHEMA_LOCATION = SCHEMA_DIR + "oasis-sstc-saml-schema-protocol-1.1.xsd";
/** SAML 1.X protocol XML namespace. */
@Nonnull @NotEmpty public static final String SAML10P_NS = "urn:oasis:names:tc:SAML:1.0:protocol";
@@ -118,13 +122,16 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML1MD_PREFIX = "saml1md";
/** URI for SAML 1 Artifact binding. */
- @Nonnull @NotEmpty public static final String SAML1_ARTIFACT_BINDING_URI = "urn:oasis:names:tc:SAML:1.0:profiles:artifact-01";
+ @Nonnull @NotEmpty
+ public static final String SAML1_ARTIFACT_BINDING_URI = "urn:oasis:names:tc:SAML:1.0:profiles:artifact-01";
/** URI for SAML 1 POST binding. */
- @Nonnull @NotEmpty public static final String SAML1_POST_BINDING_URI = "urn:oasis:names:tc:SAML:1.0:profiles:browser-post";
+ @Nonnull @NotEmpty
+ public static final String SAML1_POST_BINDING_URI = "urn:oasis:names:tc:SAML:1.0:profiles:browser-post";
/** URI for SAML 1 SOAP 1.1 binding. */
- @Nonnull @NotEmpty public static final String SAML1_SOAP11_BINDING_URI = "urn:oasis:names:tc:SAML:1.0:bindings:SOAP-binding";
+ @Nonnull @NotEmpty
+ public static final String SAML1_SOAP11_BINDING_URI = "urn:oasis:names:tc:SAML:1.0:bindings:SOAP-binding";
// ****************************
// SAML 2.0
@@ -133,7 +140,8 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-assertion-2.0.xsd";
/** "Strict" SAML 2.0 Assertion schema Id. */
- @Nonnull @NotEmpty public static final String STRICT_SAML20_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-assertion-2.1.xsd";
+ @Nonnull @NotEmpty
+ public static final String STRICT_SAML20_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-assertion-2.1.xsd";
/** SAML 2.0 Assertion XML Namespace. */
@Nonnull @NotEmpty public static final String SAML20_NS = "urn:oasis:names:tc:SAML:2.0:assertion";
@@ -145,7 +153,8 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20P_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-protocol-2.0.xsd";
/** "Strict" SAML 2.0 Protocol schema Id. */
- @Nonnull @NotEmpty public static final String STRICT_SAML20P_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-protocol-2.1.xsd";
+ @Nonnull @NotEmpty
+ public static final String STRICT_SAML20P_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-protocol-2.1.xsd";
/** SAML 2.0 Protocol XML Namespace. */
@Nonnull @NotEmpty public static final String SAML20P_NS = "urn:oasis:names:tc:SAML:2.0:protocol";
@@ -154,16 +163,19 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20P_PREFIX = "saml2p";
/** SAML 2.0 Metadata schema Id. */
- @Nonnull @NotEmpty public static final String SAML20MD_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-metadata-2.0.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML20MD_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-metadata-2.0.xsd";
/** "Strict" SAML 2.0 Metadata schema Id. */
- @Nonnull @NotEmpty public static final String STRICT_SAML20MD_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-metadata-2.1.xsd";
+ @Nonnull @NotEmpty
+ public static final String STRICT_SAML20MD_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-metadata-2.1.xsd";
/** SAML 2.0 Metadata XML Namespace. */
@Nonnull @NotEmpty public static final String SAML20MD_NS = "urn:oasis:names:tc:SAML:2.0:metadata";
/** SAML 2.0 Protocol Third-party extension schema Id. */
- @Nonnull @NotEmpty public static final String SAML20PTHRPTY_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-protocol-ext-thirdparty.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML20PTHRPTY_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-protocol-ext-thirdparty.xsd";
/** SAML 2.0 Protocol Third-party extension XML Namespace. */
@Nonnull @NotEmpty public static final String SAML20PTHRPTY_NS = "urn:oasis:names:tc:SAML:protocol:ext:third-party";
@@ -190,10 +202,12 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20MDQUERY_NS = "urn:oasis:names:tc:SAML:metadata:ext:query";
/** SAML 2.0 Standalone Query Metadata extension schema system Id. */
- @Nonnull @NotEmpty public static final String SAML20MDQUERY_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-metadata-ext-query.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML20MDQUERY_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-metadata-ext-query.xsd";
/** "Strict" SAML 2.0 Standalone Query Metadata extension schema system Id. */
- @Nonnull @NotEmpty public static final String STRICT_SAML20MDQUERY_SCHEMA_LOCATION =
+ @Nonnull @NotEmpty
+ public static final String STRICT_SAML20MDQUERY_SCHEMA_LOCATION =
SCHEMA_DIR + "strict/sstc-saml-metadata-ext-query.xsd";
/** SAML 2.0 Standalone Query Metadata extension prefix. */
@@ -203,7 +217,8 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20MD_PREFIX = "md";
/** SAML 2.0 Authentication Context schema Id. */
- @Nonnull @NotEmpty public static final String SAML20AC_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-authn-context-2.0.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML20AC_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-authn-context-2.0.xsd";
/** SAML 2.0 Authentication Context XML Namespace. */
@Nonnull @NotEmpty public static final String SAML20AC_NS = "urn:oasis:names:tc:SAML:2.0:ac";
@@ -215,7 +230,8 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20ECP_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-ecp-2.0.xsd";
/** "Strict" SAML 2.0 Enhanced Client/Proxy SSO Profile schema Id. */
- @Nonnull @NotEmpty public static final String STRICT_SAML20ECP_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-ecp-2.1.xsd";
+ @Nonnull @NotEmpty
+ public static final String STRICT_SAML20ECP_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-ecp-2.1.xsd";
/** SAML 2.0 Enhanced Client/Proxy SSO Profile XML Namespace. */
@Nonnull @NotEmpty public static final String SAML20ECP_NS = "urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp";
@@ -242,10 +258,12 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20MDATTR_PREFIX = "mdattr";
/** SAML 2.0 Metadata Extension for Discovery and Login UI schema Id. */
- @Nonnull @NotEmpty public static final String SAML20MDUI_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-metadata-ui-v1.0.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML20MDUI_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-metadata-ui-v1.0.xsd";
/** "Strict" SAML 2.0 Metadata Extension for Discovery and Login UI schema Id. */
- @Nonnull @NotEmpty public static final String STRICT_SAML20MDUI_SCHEMA_LOCATION = SCHEMA_DIR + "strict/sstc-saml-metadata-ui-v1.1.xsd";
+ @Nonnull @NotEmpty
+ public static final String STRICT_SAML20MDUI_SCHEMA_LOCATION = SCHEMA_DIR + "strict/sstc-saml-metadata-ui-v1.1.xsd";
/** SAML 2.0 Metadata Extension for Discovery and Login UI XML Namespace. */
@Nonnull @NotEmpty public static final String SAML20MDUI_NS = "urn:oasis:names:tc:SAML:metadata:ui";
@@ -260,10 +278,12 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20MDRI_PREFIX = "init";
/** SAML 2.0 Metadata Extension for Registration and Publication Information schema Id. */
- @Nonnull @NotEmpty public static final String SAML20MDRPI_SCHEMA_LOCATION = SCHEMA_DIR + "saml-metadata-rpi-v1.0.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML20MDRPI_SCHEMA_LOCATION = SCHEMA_DIR + "saml-metadata-rpi-v1.0.xsd";
/** "Strict" SAML 2.0 Metadata Extension for Registration and Publication Information schema Id. */
- @Nonnull @NotEmpty public static final String STRICT_SAML20MDRPI_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-metadata-rpi-v1.1.xsd";
+ @Nonnull @NotEmpty
+ public static final String STRICT_SAML20MDRPI_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-metadata-rpi-v1.1.xsd";
/** SAML 2.0 Metadata Extension for Registration and Publication Information XML Namespace. */
@Nonnull @NotEmpty public static final String SAML20MDRPI_NS = "urn:oasis:names:tc:SAML:metadata:rpi";
@@ -272,7 +292,8 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20MDRPI_PREFIX = "mdrpi";
/** SAML 2.0 Channel Binding Extensions schema Id. */
- @Nonnull @NotEmpty public static final String SAML20CB_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-channel-binding-ext-v1.0.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML20CB_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-channel-binding-ext-v1.0.xsd";
/** SAML 2.0 Channel Binding Extensions XML Namespace. */
@Nonnull @NotEmpty public static final String SAML20CB_NS = "urn:oasis:names:tc:SAML:protocol:ext:channel-binding";
@@ -284,7 +305,8 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20DCE_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-dce-2.0.xsd";
/** "Strict" SAML 2.0 DCE PAC Attribute Profile schema Id. */
- @Nonnull @NotEmpty public static final String STRICT_SAML20DCE_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-dce-2.1.xsd";
+ @Nonnull @NotEmpty
+ public static final String STRICT_SAML20DCE_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-dce-2.1.xsd";
/** SAML 2.0 DCE PAC Attribute Profile XML Namespace. */
@Nonnull @NotEmpty public static final String SAML20DCE_NS = "urn:oasis:names:tc:SAML:2.0:profiles:attribute:DCE";
@@ -296,7 +318,8 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20X500_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-x500-2.0.xsd";
/** "Strict" SAML 2.0 X.500 Attribute Profile schema Id. */
- @Nonnull @NotEmpty public static final String STRICT_SAML20X500_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-x500-2.1.xsd";
+ @Nonnull @NotEmpty
+ public static final String STRICT_SAML20X500_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-x500-2.1.xsd";
/** SAML 2.0 X.500 Attribute Profile XML Namespace. */
@Nonnull @NotEmpty public static final String SAML20X500_NS = "urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500";
@@ -305,28 +328,34 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAML20X500_PREFIX = "x500";
/** SAML 2.0 XACML Attribute Profile schema Id. */
- @Nonnull @NotEmpty public static final String SAML20XACML_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-xacml-2.0.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML20XACML_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-xacml-2.0.xsd";
/** "Strict" SAML 2.0 XACML Attribute Profile schema Id. */
- @Nonnull @NotEmpty public static final String STRICT_SAML20XACML_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-xacml-2.1.xsd";
+ @Nonnull @NotEmpty
+ public static final String STRICT_SAML20XACML_SCHEMA_LOCATION = SCHEMA_DIR + "strict/saml-schema-xacml-2.1.xsd";
/** SAML 2.0 XACML Attribute Profile XML Namespace. */
- @Nonnull @NotEmpty public static final String SAML20XACML_NS = "urn:oasis:names:tc:SAML:2.0:profiles:attribute:XACML";
+ @Nonnull @NotEmpty
+ public static final String SAML20XACML_NS = "urn:oasis:names:tc:SAML:2.0:profiles:attribute:XACML";
/** SAML 2.0 XACML Attribute Profile QName prefix. */
@Nonnull @NotEmpty public static final String SAML20XACML_PREFIX = "xacmlprof";
/** SAML Identity Provider Discovery Protocol and Profile XML Schema Id. */
- @Nonnull @NotEmpty public static final String SAML_IDP_DISCO_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-idp-discovery.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML_IDP_DISCO_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-idp-discovery.xsd";
/** SAML Identity Provider Discovery Protocol and Profile XML Namespace. */
- @Nonnull @NotEmpty public static final String SAML_IDP_DISCO_NS = "urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol";
+ @Nonnull @NotEmpty
+ public static final String SAML_IDP_DISCO_NS = "urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol";
/** SAML Identity Provider Discovery Protocol and Profile QName prefix. */
@Nonnull @NotEmpty public static final String SAML_IDP_DISCO_PREFIX = "idpdisco";
/** SAML 2.0 Enhanced Client GSS-API schema Id. */
- @Nonnull @NotEmpty public static final String SAMLEC_GSS_SCHEMA_LOCATION = SCHEMA_DIR + "ietf-kitten-sasl-saml-ec.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAMLEC_GSS_SCHEMA_LOCATION = SCHEMA_DIR + "ietf-kitten-sasl-saml-ec.xsd";
/** SAML 2.0 Enhanced Client GSS-API XML Namespace. */
@Nonnull @NotEmpty public static final String SAMLEC_GSS_NS = "urn:ietf:params:xml:ns:samlec";
@@ -335,26 +364,32 @@ public final class SAMLConstants {
@Nonnull @NotEmpty public static final String SAMLEC_GSS_PREFIX = "samlec";
/** URI for SAML 2 Artifact binding. */
- @Nonnull @NotEmpty public static final String SAML2_ARTIFACT_BINDING_URI = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact";
+ @Nonnull @NotEmpty
+ public static final String SAML2_ARTIFACT_BINDING_URI = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact";
/** URI for SAML 2 POST binding. */
- @Nonnull @NotEmpty public static final String SAML2_POST_BINDING_URI = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST";
+ @Nonnull @NotEmpty
+ public static final String SAML2_POST_BINDING_URI = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST";
/** URI for SAML 2 POST-SimpleSign binding. */
- @Nonnull @NotEmpty public static final String SAML2_POST_SIMPLE_SIGN_BINDING_URI =
+ @Nonnull @NotEmpty
+ public static final String SAML2_POST_SIMPLE_SIGN_BINDING_URI =
"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign";
/** URI for SAML 2 HTTP redirect binding. */
- @Nonnull @NotEmpty public static final String SAML2_REDIRECT_BINDING_URI = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect";
+ @Nonnull @NotEmpty
+ public static final String SAML2_REDIRECT_BINDING_URI = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect";
/** URI for SAML 2 SOAP binding. */
- @Nonnull @NotEmpty public static final String SAML2_SOAP11_BINDING_URI = "urn:oasis:names:tc:SAML:2.0:bindings:SOAP";
+ @Nonnull @NotEmpty
+ public static final String SAML2_SOAP11_BINDING_URI = "urn:oasis:names:tc:SAML:2.0:bindings:SOAP";
/** URI for SAML 2 PAOS binding. */
@Nonnull @NotEmpty public static final String SAML2_PAOS_BINDING_URI = "urn:oasis:names:tc:SAML:2.0:bindings:PAOS";
/** SAML 2.0 Metadata Profile for Algorithm Support schema Id. */
- @Nonnull @NotEmpty public static final String SAML20ALG_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-metadata-algsupport-v1.0.xsd";
+ @Nonnull @NotEmpty
+ public static final String SAML20ALG_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml-metadata-algsupport-v1.0.xsd";
/** "Strict" SAML 2.0 Metadata Profile for Algorithm Support schema Id. */
@Nonnull @NotEmpty public static final String STRICT_SAML20ALG_SCHEMA_LOCATION =
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLSchemaBuilder.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLSchemaBuilder.java
index 9e846115b..907cd9316 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLSchemaBuilder.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLSchemaBuilder.java
@@ -31,12 +31,12 @@ import net.shibboleth.shared.annotation.ParameterName;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.xml.ClasspathResolver;
import net.shibboleth.shared.xml.SchemaBuilder;
import org.opensaml.core.xml.XMLRuntimeException;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
import com.google.common.io.ByteStreams;
@@ -167,7 +167,7 @@ public class SAMLSchemaBuilder {
@Nonnull @NonnullElements @NotEmpty private String[] saml2Schemas;
/** The builder to use. */
- @Nonnull private SchemaBuilder schemaBuilder;
+ private SchemaBuilder schemaBuilder;
/** Identifies which SAML 1.x version is in use. */
public enum SAML1Version {
@@ -260,6 +260,7 @@ public class SAMLSchemaBuilder {
}
cachedSchema = schemaBuilder.buildSchema();
}
+ assert cachedSchema != null;
return cachedSchema;
}
@@ -268,26 +269,32 @@ public class SAMLSchemaBuilder {
*/
private void configureBuilder() {
for (final String source : baseXMLSchemas) {
+ assert source != null;
addSchemaToBuilder(source);
}
for (final String source : soapSchemas) {
+ assert source != null;
addSchemaToBuilder(source);
}
for (final String source : saml1xSchemas) {
+ assert source != null;
addSchemaToBuilder(source);
}
for (final String source : saml2Schemas) {
+ assert source != null;
addSchemaToBuilder(source);
}
for (final String source : saml20CommonSchemas) {
+ assert source != null;
addSchemaToBuilder(source);
}
for (final String source : baseExtSchemas) {
+ assert source != null;
addSchemaToBuilder(source);
}
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfiguration.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfiguration.java
index 81f0818db..2764a2b2d 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfiguration.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfiguration.java
@@ -17,7 +17,6 @@
package org.opensaml.saml.config;
-import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -46,7 +45,7 @@ import net.shibboleth.shared.primitive.StringSupport;
public class SAMLConfiguration {
/** Lowercase string function. */
- @Nonnull private static final Function<String, String> lowercaseFunction = new LowercaseFunction();
+ @Nonnull private static final Function<String, String> LOWER = new LowercaseFunction();
/** SAML 1 Artifact factory. */
@Nullable private SAML1ArtifactBuilderFactory saml1ArtifactBuilderFactory;
@@ -64,7 +63,7 @@ public class SAMLConfiguration {
*
*/
public SAMLConfiguration() {
- setAllowedBindingURLSchemes(CollectionSupport.listOf("http", "https"));
+ allowedBindingURLSchemes = CollectionSupport.listOf("http", "https");
}
/**
@@ -136,12 +135,12 @@ public class SAMLConfiguration {
*/
public void setAllowedBindingURLSchemes(@Nullable final List<String> schemes) {
if (schemes == null || schemes.isEmpty()) {
- allowedBindingURLSchemes = Collections.emptyList();
+ allowedBindingURLSchemes = CollectionSupport.emptyList();
} else {
allowedBindingURLSchemes = StringSupport.normalizeStringCollection(schemes)
.stream()
- .map(lowercaseFunction::apply)
- .collect(Collectors.toUnmodifiableList());
+ .map(LOWER::apply)
+ .collect(CollectionSupport.nonnullCollector(Collectors.toUnmodifiableList())).get();
}
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfigurationSupport.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfigurationSupport.java
index 775c9c2b8..5dc1f0dc2 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfigurationSupport.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfigurationSupport.java
@@ -46,7 +46,7 @@ public final class SAMLConfigurationSupport {
* @return artifact factory for the library
*/
@Nullable public static SAML1ArtifactBuilderFactory getSAML1ArtifactBuilderFactory() {
- return ConfigurationService.get(SAMLConfiguration.class).getSAML1ArtifactBuilderFactory();
+ return ConfigurationService.ensure(SAMLConfiguration.class).getSAML1ArtifactBuilderFactory();
}
/**
@@ -55,7 +55,7 @@ public final class SAMLConfigurationSupport {
* @param factory artifact factory for the library
*/
public static void setSAML1ArtifactBuilderFactory(@Nullable final SAML1ArtifactBuilderFactory factory) {
- ConfigurationService.get(SAMLConfiguration.class).setSAML1ArtifactBuilderFactory(factory);
+ ConfigurationService.ensure(SAMLConfiguration.class).setSAML1ArtifactBuilderFactory(factory);
}
/**
@@ -64,7 +64,7 @@ public final class SAMLConfigurationSupport {
* @return artifact factory for the library
*/
@Nullable public static SAML2ArtifactBuilderFactory getSAML2ArtifactBuilderFactory() {
- return ConfigurationService.get(SAMLConfiguration.class).getSAML2ArtifactBuilderFactory();
+ return ConfigurationService.ensure(SAMLConfiguration.class).getSAML2ArtifactBuilderFactory();
}
/**
@@ -73,7 +73,7 @@ public final class SAMLConfigurationSupport {
* @param factory artifact factory for the library
*/
public static void setSAML2ArtifactBuilderFactory(@Nullable final SAML2ArtifactBuilderFactory factory) {
- ConfigurationService.get(SAMLConfiguration.class).setSAML2ArtifactBuilderFactory(factory);
+ ConfigurationService.ensure(SAMLConfiguration.class).setSAML2ArtifactBuilderFactory(factory);
}
/**
@@ -82,7 +82,7 @@ public final class SAMLConfigurationSupport {
* @return the list of allowed URL schemes
*/
@Nonnull @NonnullElements @Unmodifiable @NotLive public static List<String> getAllowedBindingURLSchemes() {
- return ConfigurationService.get(SAMLConfiguration.class).getAllowedBindingURLSchemes();
+ return ConfigurationService.ensure(SAMLConfiguration.class).getAllowedBindingURLSchemes();
}
/**
@@ -91,6 +91,6 @@ public final class SAMLConfigurationSupport {
* @param schemes the new list of allowed URL schemes
*/
public static void setAllowedBindingURLSchemes(@Nullable final List<String>schemes) {
- ConfigurationService.get(SAMLConfiguration.class).setAllowedBindingURLSchemes(schemes);
+ ConfigurationService.ensure(SAMLConfiguration.class).setAllowedBindingURLSchemes(schemes);
}
}
\ No newline at end of file
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/BindingCriterion.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/BindingCriterion.java
index 3f9863efd..0235cdb7d 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/BindingCriterion.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/BindingCriterion.java
@@ -24,6 +24,7 @@ import javax.annotation.Nonnull;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.resolver.Criterion;
@@ -39,7 +40,7 @@ public final class BindingCriterion implements Criterion {
* @param bindingURIs list of SAML binding URIs
*/
public BindingCriterion(@Nonnull @NonnullElements final List<String> bindingURIs) {
- bindings = List.copyOf(StringSupport.normalizeStringCollection(bindingURIs));
+ bindings = CollectionSupport.copyToList(StringSupport.normalizeStringCollection(bindingURIs));
}
/**
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2aslo/Asynchronous.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2aslo/Asynchronous.java
index 66bde8cef..c56aba2b2 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2aslo/Asynchronous.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2aslo/Asynchronous.java
@@ -38,8 +38,8 @@ public interface Asynchronous extends SAMLObject {
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "Asynchronous";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML20PASLO_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAML20PASLO_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAML20PASLO_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20PASLO_PREFIX);
/** Local name of the XSI type. */
@Nonnull @NotEmpty public static final String TYPE_LOCAL_NAME = "AsynchronousType";
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdreqinit/RequestInitiator.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdreqinit/RequestInitiator.java
index f5358d9cd..338d85364 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdreqinit/RequestInitiator.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdreqinit/RequestInitiator.java
@@ -38,6 +38,7 @@ public interface RequestInitiator extends Endpoint {
new QName(SAMLConstants.SAML20MDRI_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MDRI_PREFIX);
/** Per the extension specification, the value of the 'Binding' attribute MUST be set to this fixed value. */
- @Nonnull @NotEmpty public static final String REQUIRED_BINDING_VALUE = "urn:oasis:names:tc:SAML:profiles:SSO:request-init";
+ @Nonnull @NotEmpty
+ public static final String REQUIRED_BINDING_VALUE = "urn:oasis:names:tc:SAML:profiles:SSO:request-init";
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/Publication.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/Publication.java
index 9946895c1..b1164464b 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/Publication.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/Publication.java
@@ -20,6 +20,7 @@ package org.opensaml.saml.ext.saml2mdrpi;
import java.time.Instant;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
@@ -41,8 +42,8 @@ public interface Publication extends SAMLObject {
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "Publication";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML20MDRPI_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAML20MDRPI_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAML20MDRPI_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MDRPI_PREFIX);
/** Local name of the XSI type. */
@Nonnull @NotEmpty public static final String TYPE_LOCAL_NAME = "PublicationType";
@@ -69,41 +70,41 @@ public interface Publication extends SAMLObject {
*
* @return the publisher
*/
- public String getPublisher();
+ @Nullable public String getPublisher();
/**
* Set the publisher.
*
* @param publisher the publisher
*/
- public void setPublisher(String publisher);
+ public void setPublisher(@Nullable final String publisher);
/**
* Get the creation instant.
*
* @return the creation instant
*/
- public Instant getCreationInstant();
+ @Nullable public Instant getCreationInstant();
/**
* Set the creation instant.
*
* @param dateTime the instant
*/
- public void setCreationInstant(Instant dateTime);
+ public void setCreationInstant(@Nullable final Instant dateTime);
/**
* Get the publicationId.
*
* @return the publicationId
*/
- public String getPublicationId();
+ @Nullable public String getPublicationId();
/**
* Set the publicationId.
*
* @param publicationId the publicationIdr
*/
- public void setPublicationId(String publicationId);
+ public void setPublicationId(@Nullable final String publicationId);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/PublicationInfo.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/PublicationInfo.java
index 044c6d853..e5b5ba7b0 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/PublicationInfo.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/PublicationInfo.java
@@ -21,6 +21,7 @@ import java.time.Instant;
import java.util.List;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
@@ -42,8 +43,8 @@ public interface PublicationInfo extends SAMLObject {
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "PublicationInfo";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML20MDRPI_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAML20MDRPI_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAML20MDRPI_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MDRPI_PREFIX);
/** Local name of the XSI type. */
@Nonnull @NotEmpty public static final String TYPE_LOCAL_NAME = "PublicationInfoType";
@@ -70,48 +71,48 @@ public interface PublicationInfo extends SAMLObject {
*
* @return the publisher
*/
- public String getPublisher();
+ @Nullable public String getPublisher();
/**
* Set the publisher.
*
* @param publisher the publisher
*/
- public void setPublisher(String publisher);
+ public void setPublisher(@Nullable final String publisher);
/**
* Get the creation instant.
*
* @return the creation instant
*/
- public Instant getCreationInstant();
+ @Nullable public Instant getCreationInstant();
/**
* Set the creation instant.
*
* @param dateTime the instant
*/
- public void setCreationInstant(Instant dateTime);
+ public void setCreationInstant(@Nullable final Instant dateTime);
/**
* Get the publicationId.
*
* @return the publicationId
*/
- public String getPublicationId();
+ @Nullable public String getPublicationId();
/**
* Set the publicationId.
*
* @param publicationId the publicationIdr
*/
- public void setPublicationId(String publicationId);
+ public void setPublicationId(@Nullable final String publicationId);
/**
* Get the {@link UsagePolicy}s.
*
* @return the list of policies
*/
- public List<UsagePolicy> getUsagePolicies();
+ @Nonnull public List<UsagePolicy> getUsagePolicies();
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/PublicationPath.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/PublicationPath.java
index e8406df73..2125c25d6 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/PublicationPath.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/PublicationPath.java
@@ -40,8 +40,8 @@ public interface PublicationPath extends SAMLObject {
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "PublicationPath";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML20MDRPI_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAML20MDRPI_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAML20MDRPI_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MDRPI_PREFIX);
/** Local name of the XSI type. */
@Nonnull @NotEmpty public static final String TYPE_LOCAL_NAME = "PublicationPathType";
@@ -55,6 +55,6 @@ public interface PublicationPath extends SAMLObject {
*
* @return the list of publications
*/
- public List<Publication> getPublications();
+ @Nonnull public List<Publication> getPublications();
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/RegistrationInfo.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/RegistrationInfo.java
index 1a3833db4..95d450df0 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/RegistrationInfo.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdrpi/RegistrationInfo.java
@@ -21,6 +21,7 @@ import java.time.Instant;
import java.util.List;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
@@ -42,8 +43,8 @@ public interface RegistrationInfo extends SAMLObject {
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "RegistrationInfo";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML20MDRPI_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAML20MDRPI_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAML20MDRPI_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MDRPI_PREFIX);
/** Local name of the XSI type. */
@Nonnull @NotEmpty public static final String TYPE_LOCAL_NAME = "RegistrationInfoType";
@@ -67,34 +68,34 @@ public interface RegistrationInfo extends SAMLObject {
*
* @return the registration authority
*/
- public String getRegistrationAuthority();
+ @Nullable public String getRegistrationAuthority();
/**
* Set the registration authority.
*
* @param authority the registration authority
*/
- public void setRegistrationAuthority(String authority);
+ public void setRegistrationAuthority(@Nullable final String authority);
/**
* Get the registration instant.
*
* @return the registration instant
*/
- public Instant getRegistrationInstant();
+ @Nullable public Instant getRegistrationInstant();
/**
* Set the registration instant.
*
* @param dateTime the instant
*/
- public void setRegistrationInstant(Instant dateTime);
+ public void setRegistrationInstant(@Nullable final Instant dateTime);
/**
* Get the {@link RegistrationPolicy}s.
*
* @return the list of policies
*/
- public List<RegistrationPolicy> getRegistrationPolicies();
+ @Nonnull public List<RegistrationPolicy> getRegistrationPolicies();
}
\ No newline at end of file
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/EncType.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/EncType.java
index fe71621c1..11e0d35e1 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/EncType.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/EncType.java
@@ -40,7 +40,7 @@ public interface EncType extends XSString, SAMLObject {
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "EncType";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAMLEC_GSS_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAMLEC_GSS_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAMLEC_GSS_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAMLEC_GSS_PREFIX);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/GeneratedKey.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/GeneratedKey.java
index 04e14a13b..17ef2b3e9 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/GeneratedKey.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/GeneratedKey.java
@@ -42,8 +42,8 @@ public interface GeneratedKey extends XSBase64Binary, SAMLObject, MustUnderstand
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "GeneratedKey";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAMLEC_GSS_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAMLEC_GSS_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAMLEC_GSS_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAMLEC_GSS_PREFIX);
/** Local name of the XSI type. */
@Nonnull @NotEmpty public static final String TYPE_LOCAL_NAME = "GeneratedKeyType";
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/SessionKey.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/SessionKey.java
index 277997a03..43b55e1d7 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/SessionKey.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/samlec/SessionKey.java
@@ -20,6 +20,7 @@ package org.opensaml.saml.ext.samlec;
import java.util.List;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.namespace.QName;
import org.opensaml.saml.common.SAMLObject;
@@ -40,8 +41,8 @@ public interface SessionKey extends SAMLObject, MustUnderstandBearing, ActorBear
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "SessionKey";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAMLEC_GSS_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAMLEC_GSS_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAMLEC_GSS_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAMLEC_GSS_PREFIX);
/** Local name of the XSI type. */
@Nonnull @NotEmpty public static final String TYPE_LOCAL_NAME = "SessionKeyType";
@@ -58,33 +59,33 @@ public interface SessionKey extends SAMLObject, MustUnderstandBearing, ActorBear
*
* @return the algorithm used to derive the session key
*/
- public String getAlgorithm();
+ @Nullable public String getAlgorithm();
/**
* Set the session key derivation algorithm.
*
* @param newAlgorithm the algorithm used to derive the session key
*/
- public void setAlgorithm(String newAlgorithm);
+ public void setAlgorithm(@Nullable final String newAlgorithm);
/**
* Get the session key encryption typed.
*
* @return the encryption types of the session key
*/
- public List<EncType> getEncTypes();
+ @Nonnull public List<EncType> getEncTypes();
/**
* Get the KeyInfo object that describes the session key.
*
* @return the KeyInfo object that describes the session key
*/
- public KeyInfo getKeyInfo();
+ @Nullable public KeyInfo getKeyInfo();
/**
* Set the KeyInfo object that describes the session key.
*
* @param newKeyInfo the KeyInfo object that describes the session key
*/
- public void setKeyInfo(KeyInfo newKeyInfo);
+ public void setKeyInfo(@Nullable final KeyInfo newKeyInfo);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/ChainingMetadataResolver.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/ChainingMetadataResolver.java
index f064edb60..57a9f7846 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/ChainingMetadataResolver.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/ChainingMetadataResolver.java
@@ -18,7 +18,6 @@
package org.opensaml.saml.metadata.resolver;
import java.time.Instant;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
@@ -36,13 +35,13 @@ import org.opensaml.saml.metadata.criteria.entity.DetectDuplicateEntityIDsCriter
import org.opensaml.saml.metadata.resolver.filter.MetadataFilter;
import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
-import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.resolver.CriteriaSet;
import net.shibboleth.shared.resolver.ResolverException;
@@ -69,7 +68,7 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
/** Constructor. */
public ChainingMetadataResolver() {
- resolvers = Collections.emptyList();
+ resolvers = CollectionSupport.emptyList();
detectDuplicateEntityIDs = DetectDuplicateEntityIDs.Off;
}
@@ -94,11 +93,11 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
checkSetterPreconditions();
if (newResolvers == null || newResolvers.isEmpty()) {
- resolvers = Collections.emptyList();
+ resolvers = CollectionSupport.emptyList();
return;
}
- resolvers = List.copyOf(newResolvers);
+ resolvers = CollectionSupport.copyToList(newResolvers);
}
/**
@@ -132,13 +131,13 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
}
/** {@inheritDoc} */
- @Override public MetadataFilter getMetadataFilter() {
+ @Nullable public MetadataFilter getMetadataFilter() {
log.warn("Attempt to access unsupported MetadataFilter property on ChainingMetadataResolver");
return null;
}
/** {@inheritDoc} */
- @Override public void setMetadataFilter(final MetadataFilter newFilter) {
+ public void setMetadataFilter(@Nullable final MetadataFilter newFilter) {
throw new UnsupportedOperationException("Metadata filters are not supported on ChainingMetadataResolver");
}
@@ -162,7 +161,6 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
}
/** {@inheritDoc} */
- @Override
@Nullable public EntityDescriptor resolveSingle(@Nullable final CriteriaSet criteria) throws ResolverException {
checkComponentActive();
@@ -176,22 +174,25 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
return null;
}
+// Checkstyle: CyclomaticComplexity OFF
/** {@inheritDoc} */
- @Override
@Nonnull public Iterable<EntityDescriptor> resolve(@Nullable final CriteriaSet criteria) throws ResolverException {
checkComponentActive();
- if (activationCondition != null) {
+ if (activationCondition != null && criteria != null) {
final ProfileRequestContextCriterion prc = criteria.get(ProfileRequestContextCriterion.class);
+ assert activationCondition != null;
if (!activationCondition.test(prc != null ? prc.getProfileRequestContext() : null)) {
log.info("Metadata Resolver {}: Bypassed due to failed activation condition", getId());
- return null;
+ return CollectionSupport.emptyList();
}
}
DetectDuplicateEntityIDs detectDuplicates = getDetectDuplicateEntityIDs();
- if (criteria.contains(DetectDuplicateEntityIDsCriterion.class)) {
- detectDuplicates = criteria.get(DetectDuplicateEntityIDsCriterion.class).getValue();
+ final DetectDuplicateEntityIDsCriterion dup =
+ criteria != null ? criteria.get(DetectDuplicateEntityIDsCriterion.class) : null;
+ if (dup != null) {
+ detectDuplicates = dup.getValue();
}
log.trace("Effective DetectDuplicateEntityIDs value is: {}", detectDuplicates);
@@ -200,6 +201,7 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
for (final MetadataResolver resolver : resolvers) {
try {
if (result != null) {
+ assert resolver != null;
detectDuplicateEntityIDs(resolver, criteria, resultEntityIDs, detectDuplicates);
continue;
}
@@ -227,8 +229,9 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
if (result != null) {
return result;
}
- return Collections.emptyList();
+ return CollectionSupport.emptyList();
}
+// Checkstyle: CyclomaticComplexity ON
/**
* Perform duplicate entityID detection.
@@ -238,9 +241,9 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
* @param resultEntityIDs the set of entityIDs contained in the effective results to be returned
* @param detectDuplicates the effective strategy for duplicate detection
*/
- // Checkstyle: CyclomaticComplexity OFF
+// Checkstyle: CyclomaticComplexity OFF
private void detectDuplicateEntityIDs(final @Nonnull MetadataResolver resolver,
- final @Nonnull CriteriaSet criteria,
+ final @Nullable CriteriaSet criteria,
final @Nullable Set<String> resultEntityIDs,
final @Nonnull DetectDuplicateEntityIDs detectDuplicates) {
@@ -291,7 +294,7 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
}
}
- // Checkstyle: CyclomaticComplexity ON
+// Checkstyle: CyclomaticComplexity ON
/**
* Collect the unique entityIDs from the supplied iterable of entity descriptors.
@@ -316,7 +319,7 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
}
/** {@inheritDoc} */
- public void clear(final String entityID) throws ResolverException {
+ public void clear(@Nonnull final String entityID) throws ResolverException {
for (final MetadataResolver resolver : resolvers) {
if (resolver instanceof ClearableMetadataResolver) {
((ClearableMetadataResolver) resolver).clear(entityID);
@@ -335,7 +338,6 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
/** {@inheritDoc}
* We iterate over all the children and return the earliest instant or null if one of them hasn't ever updated. */
- @Override
@Nullable public Instant getLastUpdate() {
Instant ret = null;
for (final MetadataResolver resolver : resolvers) {
@@ -355,7 +357,6 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
/** {@inheritDoc}
* We iterate over all the children and return the earliest instant or null if one of them hasn't ever refreshed. */
- @Override
@Nullable public Instant getLastRefresh() {
Instant ret = null;
for (final MetadataResolver resolver : resolvers) {
@@ -397,9 +398,9 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
* We iterate over all children - a failure of any is a failure. */
public Boolean wasLastRefreshSuccess() {
for (final MetadataResolver resolver : resolvers) {
- if (resolver instanceof RefreshableMetadataResolver) {
- final RefreshableMetadataResolver refreshable = (RefreshableMetadataResolver) resolver;
- if (refreshable.wasLastRefreshSuccess() != null && !refreshable.wasLastRefreshSuccess()) {
+ if (resolver instanceof RefreshableMetadataResolver downcast) {
+ final Boolean flag = downcast.wasLastRefreshSuccess();
+ if (flag != null && !flag) {
return false;
}
}
@@ -423,19 +424,4 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
return null;
}
- /** {@inheritDoc} */
- @Override protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
- if (resolvers == null) {
- log.warn("ChainingMetadataResolver was not configured with any member MetadataResolvers");
- resolvers = Collections.emptyList();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
- super.doDestroy();
- resolvers = Collections.emptyList();
- }
-
}
\ No newline at end of file
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/filter/MetadataFilterChain.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/filter/MetadataFilterChain.java
index 4d4f620e4..f67099b90 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/filter/MetadataFilterChain.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/filter/MetadataFilterChain.java
@@ -26,10 +26,10 @@ import javax.annotation.Nullable;
import net.shibboleth.shared.annotation.constraint.Live;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import org.opensaml.core.xml.XMLObject;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A filter that allows the composition of {@link MetadataFilter}s. Filters will be executed on the given metadata
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/index/SimpleStringMetadataIndexKey.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/index/SimpleStringMetadataIndexKey.java
index cab8bb463..321e6c116 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/index/SimpleStringMetadataIndexKey.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/index/SimpleStringMetadataIndexKey.java
@@ -30,7 +30,7 @@ import net.shibboleth.shared.primitive.StringSupport;
public class SimpleStringMetadataIndexKey implements MetadataIndexKey {
/** The indexed value. */
- private String value;
+ @Nonnull private String value;
/**
* Constructor.
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/support/SAML2MetadataSupport.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/support/SAML2MetadataSupport.java
index f5a994e7a..4fbe5353d 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/support/SAML2MetadataSupport.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/support/SAML2MetadataSupport.java
@@ -23,7 +23,8 @@ import javax.annotation.Nonnull;
import org.opensaml.saml.saml2.metadata.IndexedEndpoint;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* Utility helper class for SAML 2 metadata objects.
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/AbstractSAML1Artifact.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/AbstractSAML1Artifact.java
index 7434156c9..4c72e3398 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/AbstractSAML1Artifact.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/AbstractSAML1Artifact.java
@@ -17,6 +17,8 @@
package org.opensaml.saml.saml1.binding.artifact;
+import javax.annotation.Nonnull;
+
import org.opensaml.saml.common.binding.artifact.AbstractSAMLArtifact;
/**
@@ -29,7 +31,7 @@ public abstract class AbstractSAML1Artifact extends AbstractSAMLArtifact impleme
*
* @param typeCode artifact type code
*/
- protected AbstractSAML1Artifact(final byte[] typeCode) {
+ protected AbstractSAML1Artifact(@Nonnull final byte[] typeCode) {
super(typeCode);
}
}
\ No newline at end of file
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0001.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0001.java
index 47bccd298..cf6da9234 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0001.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0001.java
@@ -33,14 +33,14 @@ public class SAML1ArtifactType0001 extends AbstractSAML1Artifact implements SAML
@Nonnull public static final byte[] TYPE_CODE = { 0, 1 };
/** 20 byte artifact source ID. */
- private byte[] sourceID;
+ @Nonnull private byte[] sourceID;
/** 20 byte assertion handle. */
- private byte[] assertionHandle;
+ @Nonnull private byte[] assertionHandle;
/** Constructor. */
public SAML1ArtifactType0001() {
- super(TYPE_CODE);
+ this(new byte[20], new byte[20]);
}
/**
@@ -52,11 +52,18 @@ public class SAML1ArtifactType0001 extends AbstractSAML1Artifact implements SAML
* @throws IllegalArgumentException thrown if the given source ID or message handle are not of the current length
* (20 bytes)
*/
- public SAML1ArtifactType0001(final byte[] source, final byte[] handle) {
+ public SAML1ArtifactType0001(@Nonnull final byte[] source, @Nonnull final byte[] handle) {
super(TYPE_CODE);
- setSourceID(source);
- setAssertionHandle(handle);
+ if (source.length != 20) {
+ throw new IllegalArgumentException("Artifact source ID must be 20 bytes long");
+ }
+ sourceID = source;
+
+ if (handle.length != 20) {
+ throw new IllegalArgumentException("Artifact assertion handle must be 20 bytes long");
+ }
+ assertionHandle = handle;
}
/**
@@ -93,7 +100,7 @@ public class SAML1ArtifactType0001 extends AbstractSAML1Artifact implements SAML
*
* @return the source ID of the artifact
*/
- public byte[] getSourceID() {
+ @Nonnull public byte[] getSourceID() {
return sourceID;
}
@@ -104,7 +111,7 @@ public class SAML1ArtifactType0001 extends AbstractSAML1Artifact implements SAML
*
* @throws IllegalArgumentException thrown if the given source ID is not 20 bytes
*/
- protected void setSourceID(final byte[] newSourceID) {
+ protected void setSourceID(@Nonnull final byte[] newSourceID) {
if (newSourceID.length != 20) {
throw new IllegalArgumentException("Artifact source ID must be 20 bytes long");
}
@@ -116,7 +123,7 @@ public class SAML1ArtifactType0001 extends AbstractSAML1Artifact implements SAML
*
* @return artifiact's 20 byte assertion handle
*/
- public byte[] getAssertionHandle() {
+ @Nonnull public byte[] getAssertionHandle() {
return assertionHandle;
}
@@ -125,7 +132,7 @@ public class SAML1ArtifactType0001 extends AbstractSAML1Artifact implements SAML
*
* @param handle artifiact's 20 byte assertion handle
*/
- public void setAssertionHandle(final byte[] handle) {
+ public void setAssertionHandle(@Nonnull final byte[] handle) {
if (handle.length != 20) {
throw new IllegalArgumentException("Artifact assertion handle must be 20 bytes long");
}
@@ -133,7 +140,7 @@ public class SAML1ArtifactType0001 extends AbstractSAML1Artifact implements SAML
}
/** {@inheritDoc} */
- public byte[] getRemainingArtifact() {
+ @Nonnull public byte[] getRemainingArtifact() {
final byte[] remainingArtifact = new byte[40];
System.arraycopy(getSourceID(), 0, remainingArtifact, 0, 20);
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0001Builder.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0001Builder.java
index 21e20461b..3881a68ed 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0001Builder.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0001Builder.java
@@ -28,7 +28,8 @@ import org.opensaml.messaging.context.MessageContext;
import org.opensaml.saml.common.messaging.context.SAMLArtifactContext;
import org.opensaml.saml.saml1.core.Assertion;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* Builder of SAML 1, type 0x001, artifacts.
@@ -40,7 +41,7 @@ public class SAML1ArtifactType0001Builder implements SAML1ArtifactBuilder<SAML1A
/** {@inheritDoc} */
@Override
- @Nullable public SAML1ArtifactType0001 buildArtifact(final byte[] artifact) {
+ @Nullable public SAML1ArtifactType0001 buildArtifact(@Nonnull final byte[] artifact) {
try {
return SAML1ArtifactType0001.parseArtifact(artifact);
} catch (final IllegalArgumentException e) {
@@ -66,6 +67,7 @@ public class SAML1ArtifactType0001Builder implements SAML1ArtifactBuilder<SAML1A
final byte[] assertionHandle = new byte[20];
handleGenerator.nextBytes(assertionHandle);
+ assert source != null;
return new SAML1ArtifactType0001(source, assertionHandle);
} catch (final NoSuchAlgorithmException e) {
log.warn("JVM does not support required cryptography algorithms.", e);
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0002.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0002.java
index a8009247f..8dc2f71a3 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0002.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0002.java
@@ -35,14 +35,14 @@ public class SAML1ArtifactType0002 extends AbstractSAML1Artifact implements SAML
@Nonnull public static final byte[] TYPE_CODE = { 0, 2 };
/** 20 byte assertion handle. */
- private byte[] assertionHandle;
+ @Nonnull private byte[] assertionHandle;
/** Artifact source location component. */
- private String sourceLocation;
+ @Nonnull private String sourceLocation;
/** Constructor. */
public SAML1ArtifactType0002() {
- super(TYPE_CODE);
+ this(new byte[20], "unset");
}
/**
@@ -54,11 +54,20 @@ public class SAML1ArtifactType0002 extends AbstractSAML1Artifact implements SAML
* @throws IllegalArgumentException thrown if the given assertion handle is not 20 bytes or the source location is
* null or empty
*/
- public SAML1ArtifactType0002(final byte[] handle, final String location) {
+ public SAML1ArtifactType0002(@Nonnull final byte[] handle, @Nonnull final String location) {
super(TYPE_CODE);
- setAssertionHandle(handle);
- setSourceLocation(location);
+ if (handle.length != 20) {
+ throw new IllegalArgumentException("Artifact assertion handle must be 20 bytes long");
+ }
+ assertionHandle = handle;
+
+ final String loc = StringSupport.trimOrNull(location);
+ if (loc == null) {
+ throw new IllegalArgumentException("Artifact source location may not be a null or empty string");
+ }
+
+ sourceLocation = loc;
}
/**
@@ -90,7 +99,7 @@ public class SAML1ArtifactType0002 extends AbstractSAML1Artifact implements SAML
*
* @return artifiact's 20 byte assertion handle
*/
- public byte[] getAssertionHandle() {
+ @Nonnull public byte[] getAssertionHandle() {
return assertionHandle;
}
@@ -99,7 +108,7 @@ public class SAML1ArtifactType0002 extends AbstractSAML1Artifact implements SAML
*
* @param handle artifiact's 20 byte assertion handle
*/
- public void setAssertionHandle(final byte[] handle) {
+ public void setAssertionHandle(@Nonnull final byte[] handle) {
if (handle.length != 20) {
throw new IllegalArgumentException("Artifact assertion handle must be 20 bytes long");
}
@@ -111,7 +120,7 @@ public class SAML1ArtifactType0002 extends AbstractSAML1Artifact implements SAML
*
* @return source location component of this artifact
*/
- public String getSourceLocation() {
+ @Nonnull public String getSourceLocation() {
return sourceLocation;
}
@@ -122,7 +131,7 @@ public class SAML1ArtifactType0002 extends AbstractSAML1Artifact implements SAML
*
* @throws IllegalArgumentException thrown if the given location is empty or null
*/
- protected void setSourceLocation(final String newLocation) {
+ protected void setSourceLocation(@Nonnull final String newLocation) {
final String location = StringSupport.trimOrNull(newLocation);
if (location == null) {
throw new IllegalArgumentException("Artifact source location may not be a null or empty string");
@@ -132,7 +141,7 @@ public class SAML1ArtifactType0002 extends AbstractSAML1Artifact implements SAML
}
/** {@inheritDoc} */
- public byte[] getRemainingArtifact() {
+ @Nonnull public byte[] getRemainingArtifact() {
final byte[] location = getSourceLocation().getBytes();
final byte[] remainingArtifact = new byte[20 + location.length];
@@ -141,4 +150,5 @@ public class SAML1ArtifactType0002 extends AbstractSAML1Artifact implements SAML
return remainingArtifact;
}
+
}
\ No newline at end of file
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0002Builder.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0002Builder.java
index bda35c25c..2f3a428b8 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0002Builder.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactType0002Builder.java
@@ -27,9 +27,9 @@ import org.opensaml.messaging.context.MessageContext;
import org.opensaml.saml.common.messaging.context.SAMLArtifactContext;
import org.opensaml.saml.saml1.core.Assertion;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* SAML 1, type 0x0002, artifact builder.
@@ -40,7 +40,6 @@ public class SAML1ArtifactType0002Builder implements SAML1ArtifactBuilder<SAML1A
@Nonnull private final Logger log = LoggerFactory.getLogger(SAML1ArtifactType0002Builder.class);
/** {@inheritDoc} */
- @Override
@Nullable public SAML1ArtifactType0002 buildArtifact(@Nonnull @NotEmpty final byte[] artifact) {
try {
return SAML1ArtifactType0002.parseArtifact(artifact);
@@ -51,7 +50,6 @@ public class SAML1ArtifactType0002Builder implements SAML1ArtifactBuilder<SAML1A
}
/** {@inheritDoc} */
- @Override
@Nullable public SAML1ArtifactType0002 buildArtifact(@Nonnull final MessageContext requestContext,
@Nonnull final Assertion assertion) {
try {
@@ -76,8 +74,7 @@ public class SAML1ArtifactType0002Builder implements SAML1ArtifactBuilder<SAML1A
* @param requestContext the current message context
* @return the SAML artifact context, or null
*/
- @Nullable protected SAMLArtifactContext getArtifactContext(
- @Nonnull final MessageContext requestContext) {
+ @Nullable protected SAMLArtifactContext getArtifactContext(@Nonnull final MessageContext requestContext) {
return requestContext.getSubcontext(SAMLArtifactContext.class);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Evidence.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Evidence.java
index 4e30627c6..c49eb3700 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Evidence.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Evidence.java
@@ -1,5 +1,5 @@
/*
-O * Licensed to the University Corporation for Advanced Internet Development,
+ * Licensed to the University Corporation for Advanced Internet Development,
* Inc. (UCAID) under one or more contributor license agreements. See the
* NOTICE file distributed with this work for additional information regarding
* copyright ownership. The UCAID licenses this file to You under the Apache
@@ -15,9 +15,6 @@ O * Licensed to the University Corporation for Advanced Internet Development,
* limitations under the License.
*/
-/**
- *
- */
package org.opensaml.saml.saml1.core;
import java.util.List;
@@ -54,20 +51,20 @@ public interface Evidence extends SAMLObject {
*
* @return list of all {@link Evidentiary} elements
*/
- public List<Evidentiary> getEvidence();
+ @Nonnull public List<Evidentiary> getEvidence();
/**
* Get the list of assertion ID references.
*
* @return list of assertion ID references
*/
- public List<AssertionIDReference> getAssertionIDReferences();
+ @Nonnull public List<AssertionIDReference> getAssertionIDReferences();
/**
* Get the list of Assertions.
*
* @return list of assertions
*/
- public List<Assertion> getAssertions();
+ @Nonnull public List<Assertion> getAssertions();
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/NameIdentifier.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/NameIdentifier.java
index aa61ccab7..7f74683bd 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/NameIdentifier.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/NameIdentifier.java
@@ -18,6 +18,7 @@
package org.opensaml.saml.saml1.core;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.namespace.QName;
import org.opensaml.core.xml.schema.XSString;
@@ -33,8 +34,8 @@ public interface NameIdentifier extends SAMLObject, XSString {
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "NameIdentifier";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML1_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAML1_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAML1_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
/** Local name of the XSI type. */
@Nonnull @NotEmpty public static final String TYPE_LOCAL_NAME = "NameIdentifierType";
@@ -56,7 +57,8 @@ public interface NameIdentifier extends SAMLObject, XSString {
@Nonnull @NotEmpty public static final String EMAIL = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress";
/** URI for X509 subject name format. */
- @Nonnull @NotEmpty public static final String X509_SUBJECT = "urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName";
+ @Nonnull @NotEmpty
+ public static final String X509_SUBJECT = "urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName";
/** URI for windows domain qualified name name format. */
@Nonnull @NotEmpty public static final String WIN_DOMAIN_QUALIFIED =
@@ -67,27 +69,27 @@ public interface NameIdentifier extends SAMLObject, XSString {
*
* @return name qualifier for this identifier
*/
- public String getNameQualifier();
+ @Nullable public String getNameQualifier();
/**
* Sets the name qualifier for this identifier.
*
* @param nameQualifier name qualifier for this identifier
*/
- public void setNameQualifier(String nameQualifier);
+ public void setNameQualifier(@Nullable final String nameQualifier);
/**
* Gets the format of this identifier.
*
* @return format of this identifier
*/
- public String getFormat();
+ @Nullable public String getFormat();
/**
* Sets the format of this identifier.
*
* @param format format of this identifier
*/
- public void setFormat(String format);
+ public void setFormat(@Nullable final String format);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Request.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Request.java
index eaa38bb90..82dab38ae 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Request.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Request.java
@@ -20,10 +20,12 @@ package org.opensaml.saml.saml1.core;
import java.util.List;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.namespace.QName;
import org.opensaml.saml.common.xml.SAMLConstants;
+import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
/**
@@ -54,54 +56,54 @@ public interface Request extends RequestAbstractType {
*
* @return request Query, SubjectQuery, AuthenticationQuery, AttributeQuery, or AuthorizationDecisionQuery
*/
- public Query getQuery();
+ @Nullable public Query getQuery();
/**
* Get the request SubjectQuery, AuthenticationQuery, AttributeQuery, or AuthorizationDecisionQuery.
*
* @return request SubjectQuery, AuthenticationQuery, AttributeQuery, or AuthorizationDecisionQuery
*/
- public SubjectQuery getSubjectQuery();
+ @Nullable public SubjectQuery getSubjectQuery();
/**
* Get the request AuthenticationQuery.
*
* @return request AuthenticationQuery
*/
- public AuthenticationQuery getAuthenticationQuery();
+ @Nullable public AuthenticationQuery getAuthenticationQuery();
/**
* Get the request AttributeQuery.
*
* @return request AttributeQuery
*/
- public AttributeQuery getAttributeQuery();
+ @Nullable public AttributeQuery getAttributeQuery();
/**
* Get the request AuthorizationDecisionQuery.
*
* @return request AuthorizationDecisionQuery
*/
- public AuthorizationDecisionQuery getAuthorizationDecisionQuery();
+ @Nullable public AuthorizationDecisionQuery getAuthorizationDecisionQuery();
/**
* Set the request query (Query, SubjectQuery, AuthenticationQuery, AttributeQuery, AuthorizationDecisioonQuery).
*
* @param query Query, SubjectQuery, AuthenticationQuery, AttributeQuery, AuthorizationDecisioonQuery
*/
- public void setQuery(Query query);
+ public void setQuery(@Nullable Query query);
/**
* Get the list of AssertionIDReferences.
*
* @return list of AssertionIDReferences
*/
- public List <AssertionIDReference> getAssertionIDReferences();
+ @Nonnull @NonnullElements public List <AssertionIDReference> getAssertionIDReferences();
/**
* Get the list of artifacts.
*
* @return list of artifacts
*/
- public List <AssertionArtifact> getAssertionArtifacts();
+ @Nonnull @NonnullElements public List <AssertionArtifact> getAssertionArtifacts();
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/RespondWith.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/RespondWith.java
index 45f987f74..0ff470192 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/RespondWith.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/RespondWith.java
@@ -39,6 +39,6 @@ public interface RespondWith extends SAMLObject, XSQName {
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "RespondWith";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML10P_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAML1P_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAML10P_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1P_PREFIX);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Response.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Response.java
index 8f45fdd7f..709aee1ee 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Response.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/Response.java
@@ -35,8 +35,8 @@ public interface Response extends ResponseAbstractType {
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "Response";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML10P_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAML1P_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAML10P_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1P_PREFIX);
/** Local name of the XSI type. */
@Nonnull @NotEmpty public static final String TYPE_LOCAL_NAME = "ResponseAbstractType";
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/StatusCode.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/StatusCode.java
index 03a9070c5..2d95755a6 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/StatusCode.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/StatusCode.java
@@ -34,8 +34,8 @@ public interface StatusCode extends SAMLObject {
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "StatusCode";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML10P_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAML1P_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAML10P_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1P_PREFIX);
/** Local name of the XSI type. */
@Nonnull @NotEmpty public static final String TYPE_LOCAL_NAME = "StatusCodeType";
@@ -45,25 +45,28 @@ public interface StatusCode extends SAMLObject {
SAMLConstants.SAML1P_PREFIX);
/** Success status value. */
- @Nonnull public static final QName SUCCESS = new QName(SAMLConstants.SAML10P_NS, "Success", SAMLConstants.SAML1P_PREFIX);
+ @Nonnull public static final QName SUCCESS =
+ new QName(SAMLConstants.SAML10P_NS, "Success", SAMLConstants.SAML1P_PREFIX);
/** VersionMismatch status value. */
@Nonnull public static final QName VERSION_MISMATCH = new QName(SAMLConstants.SAML10P_NS, "VersionMismatch",
SAMLConstants.SAML1P_PREFIX);
/** Requester status value. */
- @Nonnull public static final QName REQUESTER = new QName(SAMLConstants.SAML10P_NS, "Requester", SAMLConstants.SAML1P_PREFIX);
+ @Nonnull public static final QName REQUESTER =
+ new QName(SAMLConstants.SAML10P_NS, "Requester", SAMLConstants.SAML1P_PREFIX);
/** Responder status value. */
- @Nonnull public static final QName RESPONDER = new QName(SAMLConstants.SAML10P_NS, "Responder", SAMLConstants.SAML1P_PREFIX);
+ @Nonnull public static final QName RESPONDER =
+ new QName(SAMLConstants.SAML10P_NS, "Responder", SAMLConstants.SAML1P_PREFIX);
/** RequestVersionTooHigh status value. */
- @Nonnull public static final QName REQUEST_VERSION_TOO_HIGH = new QName(SAMLConstants.SAML10P_NS, "RequestVersionTooHigh",
- SAMLConstants.SAML1P_PREFIX);
+ @Nonnull public static final QName REQUEST_VERSION_TOO_HIGH =
+ new QName(SAMLConstants.SAML10P_NS, "RequestVersionTooHigh", SAMLConstants.SAML1P_PREFIX);
/** RequestVersionTooLow status value. */
- @Nonnull public static final QName REQUEST_VERSION_TOO_LOW = new QName(SAMLConstants.SAML10P_NS, "RequestVersionTooLow",
- SAMLConstants.SAML1P_PREFIX);
+ @Nonnull public static final QName REQUEST_VERSION_TOO_LOW =
+ new QName(SAMLConstants.SAML10P_NS, "RequestVersionTooLow", SAMLConstants.SAML1P_PREFIX);
/** RequestVersionDepricated status value. */
@Nonnull public static final QName REQUEST_VERSION_DEPRECATED = new QName(SAMLConstants.SAML10P_NS,
@@ -78,8 +81,8 @@ public interface StatusCode extends SAMLObject {
SAMLConstants.SAML1P_PREFIX);
/** ResourceNotRecognized status value. */
- @Nonnull public static final QName RESOURCE_NOT_RECOGNIZED = new QName(SAMLConstants.SAML10P_NS, "ResourceNotRecognized",
- SAMLConstants.SAML1P_PREFIX);
+ @Nonnull public static final QName RESOURCE_NOT_RECOGNIZED =
+ new QName(SAMLConstants.SAML10P_NS, "ResourceNotRecognized", SAMLConstants.SAML1P_PREFIX);
/** Name for the attribute which defines the Value. */
@Nonnull @NotEmpty public static final String VALUE_ATTRIB_NAME = "Value";
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/SubjectLocality.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/SubjectLocality.java
index fc523f0da..406fef3d1 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/SubjectLocality.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/SubjectLocality.java
@@ -22,6 +22,7 @@
package org.opensaml.saml.saml1.core;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.namespace.QName;
import org.opensaml.saml.common.SAMLObject;
@@ -38,8 +39,8 @@ public interface SubjectLocality extends SAMLObject {
@Nonnull @NotEmpty public static final String DEFAULT_ELEMENT_LOCAL_NAME = "SubjectLocality";
/** Default element name. */
- @Nonnull public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML1_NS, DEFAULT_ELEMENT_LOCAL_NAME,
- SAMLConstants.SAML1_PREFIX);
+ @Nonnull public static final QName DEFAULT_ELEMENT_NAME =
+ new QName(SAMLConstants.SAML1_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
/** Local name of the XSI type. */
@Nonnull @NotEmpty public static final String TYPE_LOCAL_NAME = "SubjectLocalityType";
@@ -59,26 +60,26 @@ public interface SubjectLocality extends SAMLObject {
*
* @return IP address of the locality
*/
- public String getIPAddress();
+ @Nullable public String getIPAddress();
/**
* Sets the IP address of the locality.
*
* @param address IP address of the locality
*/
- public void setIPAddress(String address);
+ public void setIPAddress(@Nullable final String address);
/**
* Gets the DNS name of the locality.
*
* @return DNS name of the locality
*/
- public String getDNSAddress();
+ @Nullable public String getDNSAddress();
/**
* Sets the DNS name of the locality.
*
* @param address DNS name of the locality
*/
- public void setDNSAddress(String address);
+ public void setDNSAddress(@Nullable final String address);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/SubjectQuery.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/SubjectQuery.java
index 7b47c74a3..402d93545 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/SubjectQuery.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/core/SubjectQuery.java
@@ -18,6 +18,7 @@
package org.opensaml.saml.saml1.core;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.namespace.QName;
import org.opensaml.saml.common.xml.SAMLConstants;
@@ -48,12 +49,12 @@ public interface SubjectQuery extends Query {
*
* @return the subject
*/
- public Subject getSubject();
+ @Nullable public Subject getSubject();
/**
* Set the subject.
*
* @param subject the subject
*/
- public void setSubject(Subject subject);
+ public void setSubject(@Nullable Subject subject);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/AbstractSAML1NameIdentifierGenerator.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/AbstractSAML1NameIdentifierGenerator.java
index 7fb26e8ce..a8f888188 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/AbstractSAML1NameIdentifierGenerator.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/AbstractSAML1NameIdentifierGenerator.java
@@ -27,7 +27,8 @@ import org.opensaml.saml.common.SAMLObjectBuilder;
import org.opensaml.saml.common.profile.AbstractNameIdentifierGenerator;
import org.opensaml.saml.saml1.core.NameIdentifier;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* Abstract base class for simple implementations of {@link SAML1NameIdentifierGenerator}.
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/SAML1ActionSupport.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/SAML1ActionSupport.java
index 578b7c15f..bf41f6dd6 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/SAML1ActionSupport.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/SAML1ActionSupport.java
@@ -22,6 +22,7 @@ import java.time.Instant;
import javax.annotation.Nonnull;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.security.IdentifierGenerationStrategy;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
@@ -32,7 +33,6 @@ import org.opensaml.saml.saml1.core.Assertion;
import org.opensaml.saml.saml1.core.Conditions;
import org.opensaml.saml.saml1.core.Response;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/** Helper methods for SAML 1 profile actions. */
public final class SAML1ActionSupport {
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/SAML1ObjectSupport.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/SAML1ObjectSupport.java
index 340f7882c..adb9e0d6f 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/SAML1ObjectSupport.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/profile/SAML1ObjectSupport.java
@@ -23,17 +23,12 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensaml.saml.saml1.core.NameIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A helper class for working with SAMLObjects.
*/
public final class SAML1ObjectSupport {
- /** Logger. */
- @Nonnull private static final Logger LOG = LoggerFactory.getLogger(SAML1ObjectSupport.class);
-
/** Constructor. */
private SAML1ObjectSupport() {
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/assertion/SAML20AssertionValidator.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/assertion/SAML20AssertionValidator.java
index 6fea287b2..b0fe43be8 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/assertion/SAML20AssertionValidator.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/assertion/SAML20AssertionValidator.java
@@ -29,6 +29,7 @@ import javax.xml.namespace.QName;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.collection.LazyMap;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.resolver.CriteriaSet;
import net.shibboleth.shared.xml.SerializeSupport;
@@ -55,7 +56,6 @@ import org.opensaml.xmlsec.signature.support.SignatureException;
import org.opensaml.xmlsec.signature.support.SignaturePrevalidator;
import org.opensaml.xmlsec.signature.support.SignatureTrustEngine;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
/**
@@ -242,10 +242,10 @@ public class SAML20AssertionValidator {
*
* @return the clock skew
*/
- private static Duration getDurationParam(@Nonnull final ValidationContext context, @Nonnull final String paramName,
- @Nonnull final Duration defaultDuration) {
+ @Nonnull private static Duration getDurationParam(@Nonnull final ValidationContext context,
+ @Nonnull final String paramName, @Nonnull final Duration defaultDuration) {
- Duration duration = defaultDuration;
+ @Nonnull Duration duration = defaultDuration;
if (context.getStaticParameters().containsKey(paramName)) {
try {
@@ -396,7 +396,7 @@ public class SAML20AssertionValidator {
*
* @throws AssertionValidationException if there is a problem validating the IssueInstant
*/
- protected ValidationResult validateIssueInstant(@Nonnull final Assertion assertion,
+ @Nonnull protected ValidationResult validateIssueInstant(@Nonnull final Assertion assertion,
@Nonnull final ValidationContext context) throws AssertionValidationException {
if (assertion.getIssueInstant() == null) {
@@ -443,7 +443,7 @@ public class SAML20AssertionValidator {
*
* @throws AssertionValidationException if there is a problem validating the Issuer
*/
- protected ValidationResult validateIssuer(@Nonnull final Assertion assertion,
+ @Nonnull protected ValidationResult validateIssuer(@Nonnull final Assertion assertion,
@Nonnull final ValidationContext context) throws AssertionValidationException {
String issuer = null;
@@ -460,8 +460,8 @@ public class SAML20AssertionValidator {
final Set<String> validIssuers;
try {
- validIssuers = (Set<String>) context.getStaticParameters()
- .get(SAML2AssertionValidationParameters.VALID_ISSUERS);
+ validIssuers = (Set<String>) context.getStaticParameters().get(
+ SAML2AssertionValidationParameters.VALID_ISSUERS);
} catch (final ClassCastException e) {
log.warn("The value of the static validation parameter '{}' was not java.util.Set<String>",
SAML2AssertionValidationParameters.VALID_ISSUERS);
@@ -545,6 +545,7 @@ public class SAML20AssertionValidator {
}
final Signature signature = token.getSignature();
+ assert signature != null;
String tokenIssuer = null;
if (token.getIssuer() != null) {
@@ -599,7 +600,7 @@ public class SAML20AssertionValidator {
* @param context current validation context
* @return the criteria set to use
*/
- @Nonnull protected SignatureTrustEngine getSignatureValidationTrustEngine(@Nonnull final Assertion token,
+ @Nullable protected SignatureTrustEngine getSignatureValidationTrustEngine(@Nonnull final Assertion token,
@Nonnull final ValidationContext context) {
final SignatureTrustEngine contextEngine = (SignatureTrustEngine) context.getStaticParameters()
@@ -619,7 +620,7 @@ public class SAML20AssertionValidator {
* @param context current validation context
* @return the criteria set to use
*/
- @Nonnull protected SignaturePrevalidator getSignatureValidationPrevalidator(@Nonnull final Assertion token,
+ @Nullable protected SignaturePrevalidator getSignatureValidationPrevalidator(@Nonnull final Assertion token,
@Nonnull final ValidationContext context) {
final SignaturePrevalidator contextPrevalidator = (SignaturePrevalidator) context.getStaticParameters()
@@ -735,7 +736,7 @@ public class SAML20AssertionValidator {
*
* @return the result of the validation evaluation
*/
- protected ValidationResult validateRequiredConditions(@Nonnull final Assertion assertion,
+ @Nonnull protected ValidationResult validateRequiredConditions(@Nonnull final Assertion assertion,
@Nonnull final ValidationContext context) {
@SuppressWarnings("unchecked")
@@ -756,6 +757,7 @@ public class SAML20AssertionValidator {
}
for (final QName requiredCondition : requiredConditions) {
+ assert requiredCondition != null;
final List<Condition> found = conditions.getConditions(requiredCondition);
if (found == null || found.isEmpty()) {
String msg = String.format("Condition '%s' was required, but was not found in assertion '%s'",
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/AbstractSAML2Artifact.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/AbstractSAML2Artifact.java
index c360f7d09..ae8c58d97 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/AbstractSAML2Artifact.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/AbstractSAML2Artifact.java
@@ -28,15 +28,15 @@ import org.opensaml.saml.common.binding.artifact.AbstractSAMLArtifact;
public abstract class AbstractSAML2Artifact extends AbstractSAMLArtifact implements SAML2Artifact {
/** 2 byte artifact endpoint index. */
- private byte[] endpointIndex;
+ @Nonnull private byte[] endpointIndex;
/**
* Constructor.
*
* @param artifactType artifact type code
*/
- protected AbstractSAML2Artifact(final byte[] artifactType) {
- super(artifactType);
+ protected AbstractSAML2Artifact(@Nonnull final byte[] artifactType) {
+ this(artifactType, new byte[2]);
}
/**
@@ -48,9 +48,14 @@ public abstract class AbstractSAML2Artifact extends AbstractSAMLArtifact impleme
* @throws IllegalArgumentException thrown if the endpoint index, source ID, or message handle arrays are not of the
* right size
*/
- public AbstractSAML2Artifact(final byte[] artifactType, final byte[] index) {
+ public AbstractSAML2Artifact(@Nonnull final byte[] artifactType, @Nonnull final byte[] index) {
super(artifactType);
- setEndpointIndex(index);
+
+ if (index.length != 2) {
+ throw new IllegalArgumentException("Artifact endpoint index must be two bytes long");
+ }
+
+ endpointIndex = index;
}
/**
@@ -58,7 +63,7 @@ public abstract class AbstractSAML2Artifact extends AbstractSAMLArtifact impleme
*
* @return the bytes for the artifact
*/
- public byte[] getArtifactBytes() {
+ @Nonnull public byte[] getArtifactBytes() {
final byte[] remainingArtifact = getRemainingArtifact();
final byte[] artifact = new byte[4 + remainingArtifact.length];
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactType0004.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactType0004.java
index 98e8bcf10..bb44530c4 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactType0004.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactType0004.java
@@ -33,14 +33,14 @@ public class SAML2ArtifactType0004 extends AbstractSAML2Artifact implements SAML
@Nonnull public static final byte[] TYPE_CODE = { 0, 4 };
/** 20 byte artifact source ID. */
- private byte[] sourceID;
+ @Nonnull private byte[] sourceID;
/** 20 byte message handle. */
- private byte[] messageHandle;
+ @Nonnull private byte[] messageHandle;
/** Constructor. */
public SAML2ArtifactType0004() {
- super(TYPE_CODE);
+ this(TYPE_CODE, new byte[20], new byte[20]);
}
/**
@@ -53,10 +53,19 @@ public class SAML2ArtifactType0004 extends AbstractSAML2Artifact implements SAML
* @throws IllegalArgumentException thrown if the endpoint index, source ID, or message handle arrays are not of the
* right size
*/
- public SAML2ArtifactType0004(final byte[] endpointIndex, final byte[] source, final byte[] handle) {
+ public SAML2ArtifactType0004(@Nonnull final byte[] endpointIndex, @Nonnull final byte[] source,
+ @Nonnull final byte[] handle) {
super(TYPE_CODE, endpointIndex);
- setSourceID(source);
- setMessageHandle(handle);
+
+ if (source.length != 20) {
+ throw new IllegalArgumentException("Artifact source ID must be 20 bytes long");
+ }
+ sourceID = source;
+
+ if (handle.length != 20) {
+ throw new IllegalArgumentException("Artifact message handle must be 20 bytes long");
+ }
+ messageHandle = handle;
}
/**
@@ -94,7 +103,7 @@ public class SAML2ArtifactType0004 extends AbstractSAML2Artifact implements SAML
*
* @return the source ID of the artifact
*/
- public byte[] getSourceID() {
+ @Nonnull public byte[] getSourceID() {
return sourceID;
}
@@ -117,7 +126,7 @@ public class SAML2ArtifactType0004 extends AbstractSAML2Artifact implements SAML
*
* @return 20 byte message handle of the artifact
*/
- public byte[] getMessageHandle() {
+ @Nonnull public byte[] getMessageHandle() {
return messageHandle;
}
@@ -134,7 +143,7 @@ public class SAML2ArtifactType0004 extends AbstractSAML2Artifact implements SAML
}
/** {@inheritDoc} */
- public byte[] getRemainingArtifact() {
+ @Nonnull public byte[] getRemainingArtifact() {
final byte[] remainingArtifact = new byte[40];
System.arraycopy(getSourceID(), 0, remainingArtifact, 0, 20);
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactType0004Builder.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactType0004Builder.java
index dbfc3507f..b214980e9 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactType0004Builder.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactType0004Builder.java
@@ -27,9 +27,9 @@ import javax.annotation.Nullable;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.saml.common.messaging.context.SAMLArtifactContext;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* SAML 2, type 0x0004, artifact builder.
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/common/SAML2Support.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/common/SAML2Support.java
index d1688732e..d76b74a32 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/common/SAML2Support.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/common/SAML2Support.java
@@ -17,6 +17,7 @@
package org.opensaml.saml.saml2.common;
+import java.time.Duration;
import java.time.Instant;
import java.util.List;
@@ -103,7 +104,7 @@ public final class SAML2Support {
if (xmlObject != null) {
final List<XMLObject> children = xmlObject.getOrderedChildren();
if (children != null) {
- for (final XMLObject child : xmlObject.getOrderedChildren()) {
+ for (final XMLObject child : children) {
if (child != null) {
earliestExpiration = getEarliestExpiration(child, earliestExpiration, now);
}
@@ -131,8 +132,8 @@ public final class SAML2Support {
Instant earliestExpiration = candidateTime;
- if (cacheableObject.getCacheDuration() != null && !cacheableObject.getCacheDuration().isNegative()) {
- final Instant elementExpirationTime = now.plus(cacheableObject.getCacheDuration());
+ if (cacheableObject.getCacheDuration() instanceof Duration dur && !dur.isNegative()) {
+ final Instant elementExpirationTime = now.plus(dur);
if (earliestExpiration == null) {
earliestExpiration = elementExpirationTime;
} else {
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/RequestAbstractType.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/RequestAbstractType.java
index fd6504fb6..774859265 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/RequestAbstractType.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/RequestAbstractType.java
@@ -20,6 +20,7 @@ package org.opensaml.saml.saml2.core;
import java.time.Instant;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
@@ -84,21 +85,21 @@ public interface RequestAbstractType extends SignableSAMLObject {
*
* @return the SAML Version of this request.
*/
- SAMLVersion getVersion();
+ @Nullable SAMLVersion getVersion();
/**
* Sets the SAML Version of this request.
*
* @param newVersion the SAML Version of this request
*/
- void setVersion(SAMLVersion newVersion);
+ void setVersion(@Nullable SAMLVersion newVersion);
/**
* Gets the unique identifier of the request.
*
* @return the unique identifier of the request
*/
- String getID();
+ @Nullable String getID();
/**
* Sets the unique identifier of the request.
@@ -106,7 +107,7 @@ public interface RequestAbstractType extends SignableSAMLObject {
* @param newID the unique identifier of the request
*/
- void setID(String newID);
+ void setID(@Nullable String newID);
/**
* Gets the date/time the request was issued.
@@ -114,69 +115,69 @@ public interface RequestAbstractType extends SignableSAMLObject {
* @return the date/time the request was issued
*/
- Instant getIssueInstant();
+ @Nullable Instant getIssueInstant();
/**
* Sets the date/time the request was issued.
*
* @param newIssueInstant the date/time the request was issued
*/
- void setIssueInstant(Instant newIssueInstant);
+ void setIssueInstant(@Nullable Instant newIssueInstant);
/**
* Gets the URI of the destination of the request.
*
* @return the URI of the destination of the request
*/
- String getDestination();
+ @Nullable String getDestination();
/**
* Sets the URI of the destination of the request.
*
* @param newDestination the URI of the destination of the request
*/
- void setDestination(String newDestination);
+ void setDestination(@Nullable String newDestination);
/**
* Gets the consent obtained from the principal for sending this request.
*
* @return the consent obtained from the principal for sending this request
*/
- String getConsent();
+ @Nullable String getConsent();
/**
* Sets the consent obtained from the principal for sending this request.
*
* @param newConsent the new consent obtained from the principal for sending this request
*/
- void setConsent(String newConsent);
+ void setConsent(@Nullable String newConsent);
/**
* Gets the issuer of this request.
*
* @return the issuer of this request
*/
- Issuer getIssuer();
+ @Nullable Issuer getIssuer();
/**
* Sets the issuer of this request.
*
* @param newIssuer the issuer of this request
*/
- void setIssuer(Issuer newIssuer);
+ void setIssuer(@Nullable Issuer newIssuer);
/**
* Gets the Extensions of this request.
*
* @return the Status of this request
*/
- Extensions getExtensions();
+ @Nullable Extensions getExtensions();
/**
* Sets the Extensions of this request.
*
* @param newExtensions the Extensions of this request
*/
- void setExtensions(Extensions newExtensions);
+ void setExtensions(@Nullable Extensions newExtensions);
}
\ No newline at end of file
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/StatusResponseType.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/StatusResponseType.java
index b870b02d2..89fd0aab2 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/StatusResponseType.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/StatusResponseType.java
@@ -24,6 +24,7 @@ package org.opensaml.saml.saml2.core;
import java.time.Instant;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
@@ -91,21 +92,21 @@ public interface StatusResponseType extends SignableSAMLObject {
*
* @return the SAML Version of this response.
*/
- SAMLVersion getVersion();
+ @Nullable SAMLVersion getVersion();
/**
* Sets the SAML Version of this response.
*
* @param newVersion the SAML Version of this response
*/
- void setVersion(SAMLVersion newVersion);
+ void setVersion(@Nullable SAMLVersion newVersion);
/**
* Gets the unique identifier of the response.
*
* @return the unique identifier of the response
*/
- String getID();
+ @Nullable String getID();
/**
* Sets the unique identifier of the response.
@@ -113,14 +114,14 @@ public interface StatusResponseType extends SignableSAMLObject {
* @param newID the unique identifier of the response
*/
- void setID(String newID);
+ void setID(@Nullable String newID);
/**
* Gets the unique request identifier for which this is a response.
*
* @return the unique identifier of the originating request
*/
- String getInResponseTo();
+ @Nullable String getInResponseTo();
/**
* Sets the unique request identifier for which this is a response.
@@ -128,90 +129,90 @@ public interface StatusResponseType extends SignableSAMLObject {
* @param newInResponseTo the unique identifier of the originating request
*/
- void setInResponseTo(String newInResponseTo);
+ void setInResponseTo(@Nullable String newInResponseTo);
/**
* Gets the date/time the response was issued.
*
* @return the date/time the response was issued
*/
- Instant getIssueInstant();
+ @Nullable Instant getIssueInstant();
/**
* Sets the date/time the response was issued.
*
* @param newIssueInstant the date/time the response was issued
*/
- void setIssueInstant(Instant newIssueInstant);
+ void setIssueInstant(@Nullable Instant newIssueInstant);
/**
* Gets the URI of the destination of the response.
*
* @return the URI of the destination of the response
*/
- String getDestination();
+ @Nullable String getDestination();
/**
* Sets the URI of the destination of the response.
*
* @param newDestination the URI of the destination of the response
*/
- void setDestination(String newDestination);
+ void setDestination(@Nullable String newDestination);
/**
* Gets the consent obtained from the principal for sending this response.
*
* @return the consent obtained from the principal for sending this response
*/
- String getConsent();
+ @Nullable String getConsent();
/**
* Sets the consent obtained from the principal for sending this response.
*
* @param newConsent the consent obtained from the principal for sending this response
*/
- void setConsent(String newConsent);
+ void setConsent(@Nullable String newConsent);
/**
* Gets the issuer of this response.
*
* @return the issuer of this response
*/
- Issuer getIssuer();
+ @Nullable Issuer getIssuer();
/**
* Sets the issuer of this response.
*
* @param newIssuer the issuer of this response
*/
- void setIssuer(Issuer newIssuer);
+ void setIssuer(@Nullable Issuer newIssuer);
/**
* Gets the Status of this response.
*
* @return the Status of this response
*/
- Status getStatus();
+ @Nullable Status getStatus();
/**
* Sets the Status of this response.
*
* @param newStatus the Status of this response
*/
- void setStatus(Status newStatus);
+ void setStatus(@Nullable Status newStatus);
/**
* Gets the Extensions of this response.
*
* @return the Status of this response
*/
- Extensions getExtensions();
+ @Nullable Extensions getExtensions();
/**
* Sets the Extensions of this response.
*
* @param newExtensions the Extensions of this response
*/
- void setExtensions(Extensions newExtensions);
+ void setExtensions(@Nullable Extensions newExtensions);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/SubjectQuery.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/SubjectQuery.java
index f030684ab..47c396b4a 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/SubjectQuery.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/SubjectQuery.java
@@ -22,6 +22,7 @@
package org.opensaml.saml.saml2.core;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.namespace.QName;
import org.opensaml.saml.common.xml.SAMLConstants;
@@ -52,13 +53,13 @@ public interface SubjectQuery extends RequestAbstractType {
*
* @return the Subject of this request
*/
- public Subject getSubject();
+ @Nullable public Subject getSubject();
/**
* Sets the Subject of this request.
*
* @param newSubject the Subject of this request
*/
- public void setSubject(Subject newSubject);
+ public void setSubject(@Nullable Subject newSubject);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/Decrypter.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/Decrypter.java
index e0cde8961..4cdae7bf5 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/Decrypter.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/Decrypter.java
@@ -198,7 +198,7 @@ public class Decrypter extends org.opensaml.xmlsec.encryption.support.Decrypter
*
* @param xmlObject the decrypted XMLObject
*/
- private void logPostDecryption(final XMLObject xmlObject) {
+ private void logPostDecryption(@Nonnull final XMLObject xmlObject) {
if (log.isDebugEnabled()) {
try {
final Element dom = XMLObjectSupport.marshall(xmlObject);
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/EncryptedElementTypeEncryptedKeyResolver.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/EncryptedElementTypeEncryptedKeyResolver.java
index 0f335be03..30f67a67c 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/EncryptedElementTypeEncryptedKeyResolver.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/EncryptedElementTypeEncryptedKeyResolver.java
@@ -22,6 +22,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensaml.saml.saml2.core.EncryptedElementType;
@@ -60,7 +61,7 @@ public class EncryptedElementTypeEncryptedKeyResolver extends AbstractEncryptedK
}
/** {@inheritDoc} */
- public Iterable<EncryptedKey> resolve(final EncryptedData encryptedData) {
+ @Nonnull public Iterable<EncryptedKey> resolve(@Nonnull final EncryptedData encryptedData) {
final List<EncryptedKey> resolvedEncKeys = new ArrayList<>();
if (!(encryptedData.getParent() instanceof EncryptedElementType) ) {
@@ -68,7 +69,7 @@ public class EncryptedElementTypeEncryptedKeyResolver extends AbstractEncryptedK
}
final EncryptedElementType encElementType = (EncryptedElementType) encryptedData.getParent();
-
+ assert encElementType != null;
for (final EncryptedKey encKey : encElementType.getEncryptedKeys()) {
if (matchRecipient(encKey.getRecipient())) {
resolvedEncKeys.add(encKey);
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/Encrypter.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/Encrypter.java
index 03c2d2a83..f2991a782 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/Encrypter.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/encryption/Encrypter.java
@@ -24,6 +24,7 @@ import java.util.List;
import javax.annotation.Nonnull;
import javax.xml.namespace.QName;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.security.IdentifierGenerationStrategy;
import net.shibboleth.shared.security.IdentifierGenerationStrategy.ProviderType;
@@ -160,10 +161,8 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @param keyEncParams the key encryption parameters
*/
public Encrypter(final DataEncryptionParameters dataEncParams, final List<KeyEncryptionParameters> keyEncParams) {
- super();
-
- this.encParams = dataEncParams;
- this.kekParamsList = keyEncParams;
+ encParams = dataEncParams;
+ kekParamsList = keyEncParams;
init();
}
@@ -175,13 +174,11 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @param keyEncParam the key encryption parameter
*/
public Encrypter(final DataEncryptionParameters dataEncParams, final KeyEncryptionParameters keyEncParam) {
- super();
-
final List<KeyEncryptionParameters> keks = new ArrayList<>();
keks.add(keyEncParam);
- this.encParams = dataEncParams;
- this.kekParamsList = keks;
+ encParams = dataEncParams;
+ kekParamsList = keks;
init();
}
@@ -192,12 +189,10 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @param dataEncParams the data encryption parameters
*/
public Encrypter(final DataEncryptionParameters dataEncParams) {
- super();
-
final List<KeyEncryptionParameters> keks = new ArrayList<>();
- this.encParams = dataEncParams;
- this.kekParamsList = keks;
+ encParams = dataEncParams;
+ kekParamsList = keks;
init();
}
@@ -244,7 +239,7 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @return returns the key placement option.
*/
public KeyPlacement getKeyPlacement() {
- return this.keyPlacement;
+ return keyPlacement;
}
/**
@@ -253,7 +248,7 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @param newKeyPlacement The new key placement option to set
*/
public void setKeyPlacement(final KeyPlacement newKeyPlacement) {
- this.keyPlacement = newKeyPlacement;
+ keyPlacement = newKeyPlacement;
}
/**
@@ -263,7 +258,7 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @return an EncryptedAssertion
* @throws EncryptionException thrown when encryption generates an error
*/
- public EncryptedAssertion encrypt(final Assertion assertion) throws EncryptionException {
+ public EncryptedAssertion encrypt(@Nonnull final Assertion assertion) throws EncryptionException {
logPreEncryption(assertion, "Assertion");
return (EncryptedAssertion) encrypt(assertion, EncryptedAssertion.DEFAULT_ELEMENT_NAME);
}
@@ -275,7 +270,7 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @return an EncryptedID
* @throws EncryptionException thrown when encryption generates an error
*/
- public EncryptedID encryptAsID(final Assertion assertion) throws EncryptionException {
+ public EncryptedID encryptAsID(@Nonnull final Assertion assertion) throws EncryptionException {
logPreEncryption(assertion, "Assertion (as EncryptedID)");
return (EncryptedID) encrypt(assertion, EncryptedID.DEFAULT_ELEMENT_NAME);
}
@@ -287,7 +282,7 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @return an EncryptedAttribute
* @throws EncryptionException thrown when encryption generates an error
*/
- public EncryptedAttribute encrypt(final Attribute attribute) throws EncryptionException {
+ public EncryptedAttribute encrypt(@Nonnull final Attribute attribute) throws EncryptionException {
logPreEncryption(attribute, "Attribute");
return (EncryptedAttribute) encrypt(attribute, EncryptedAttribute.DEFAULT_ELEMENT_NAME);
}
@@ -299,7 +294,7 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @return an EncryptedID
* @throws EncryptionException thrown when encryption generates an error
*/
- public EncryptedID encrypt(final NameID nameID) throws EncryptionException {
+ public EncryptedID encrypt(@Nonnull final NameID nameID) throws EncryptionException {
logPreEncryption(nameID, "NameID");
return (EncryptedID) encrypt(nameID, EncryptedID.DEFAULT_ELEMENT_NAME);
}
@@ -311,7 +306,7 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @return an EncryptedID
* @throws EncryptionException thrown when encryption generates an error
*/
- public EncryptedID encrypt(final BaseID baseID) throws EncryptionException {
+ public EncryptedID encrypt(@Nonnull final BaseID baseID) throws EncryptionException {
logPreEncryption(baseID, "BaseID");
return (EncryptedID) encrypt(baseID, EncryptedID.DEFAULT_ELEMENT_NAME);
}
@@ -323,7 +318,7 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @return a NewEncryptedID
* @throws EncryptionException thrown when encryption generates an error
*/
- public NewEncryptedID encrypt(final NewID newID) throws EncryptionException {
+ public NewEncryptedID encrypt(@Nonnull final NewID newID) throws EncryptionException {
logPreEncryption(newID, "NewID");
return (NewEncryptedID) encrypt(newID, NewEncryptedID.DEFAULT_ELEMENT_NAME);
}
@@ -334,7 +329,7 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @param xmlObject the XMLObject to encrypt
* @param objectType String description of the type of object to encrypt
*/
- private void logPreEncryption(final XMLObject xmlObject, final String objectType) {
+ private void logPreEncryption(@Nonnull final XMLObject xmlObject, @Nonnull final String objectType) {
if (log.isDebugEnabled()) {
try {
final Element dom = XMLObjectSupport.marshall(xmlObject);
@@ -354,28 +349,31 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
* @return a specialization of {@link org.opensaml.saml.saml2.core.EncryptedElementType}
* @throws EncryptionException thrown when encryption generates an error
*/
- private EncryptedElementType encrypt(final XMLObject xmlObject, final QName encElementName)
+ private EncryptedElementType encrypt(@Nonnull final XMLObject xmlObject, @Nonnull final QName encElementName)
throws EncryptionException {
checkParams(encParams, kekParamsList);
final EncryptedElementType encElement =
- (EncryptedElementType) builderFactory.getBuilder(encElementName).buildObject(encElementName);
+ (EncryptedElementType) builderFactory.ensureBuilder(encElementName).buildObject(encElementName);
// Marshall the containing element, we will need its Document context to pass
// to the key encryption method
checkAndMarshall(encElement);
- final Document ownerDocument = encElement.getDOM().getOwnerDocument();
+ final Element domNode = encElement.getDOM();
+ assert domNode != null;
+ final Document ownerDocument = domNode.getOwnerDocument();
final String encryptionAlgorithmURI = encParams.getAlgorithm();
+ // Checked above.
+ assert encryptionAlgorithmURI != null;
Key encryptionKey = CredentialSupport.extractEncryptionKey(encParams.getEncryptionCredential());
if (encryptionKey == null) {
encryptionKey = generateEncryptionKey(encryptionAlgorithmURI);
}
final EncryptedData encryptedData = encryptElement(xmlObject, encryptionKey, encryptionAlgorithmURI, false);
- if (encParams.getKeyInfoGenerator() != null) {
- final KeyInfoGenerator generator = encParams.getKeyInfoGenerator();
+ if (encParams.getKeyInfoGenerator() instanceof KeyInfoGenerator generator) {
log.debug("Dynamically generating KeyInfo from Credential for EncryptedData using generator: {}", generator
.getClass().getName());
try {
@@ -453,7 +451,9 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
log.debug("Placing EncryptedKey elements inline inside EncryptedData");
- encData.getKeyInfo().getEncryptedKeys().addAll(encKeys);
+ if (encData.getKeyInfo() instanceof KeyInfo keyInfo) {
+ keyInfo.getEncryptedKeys().addAll(encKeys);
+ }
encElement.setEncryptedData(encData);
return encElement;
}
@@ -502,16 +502,21 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
*/
protected void linkSinglePeerKey(final EncryptedData encData, final EncryptedKey encKey) {
log.debug("Linking single peer EncryptedKey with RetrievalMethod and DataReference");
- // Forward reference from EncryptedData to the EncryptedKey
- final RetrievalMethod rm = retrievalMethodBuilder.buildObject();
- rm.setURI("#" + encKey.getID());
- rm.setType(EncryptionConstants.TYPE_ENCRYPTED_KEY);
- encData.getKeyInfo().getRetrievalMethods().add(rm);
+
+ if (encData.getKeyInfo() instanceof KeyInfo keyInfo) {
+ // Forward reference from EncryptedData to the EncryptedKey
+ final RetrievalMethod rm = retrievalMethodBuilder.buildObject();
+ rm.setURI("#" + encKey.getID());
+ rm.setType(EncryptionConstants.TYPE_ENCRYPTED_KEY);
+ keyInfo.getRetrievalMethods().add(rm);
+ }
// Back reference from the EncryptedKey to the EncryptedData
- final DataReference dr = dataReferenceBuilder.buildObject();
- dr.setURI("#" + encData.getID());
- encKey.getReferenceList().getDataReferences().add(dr);
+ if (encKey.getReferenceList() instanceof ReferenceList refList) {
+ final DataReference dr = dataReferenceBuilder.buildObject();
+ dr.setURI("#" + encData.getID());
+ refList.getDataReferences().add(dr);
+ }
}
/**
@@ -523,7 +528,13 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
protected void linkMultiplePeerKeys(final EncryptedData encData, final List<EncryptedKey> encKeys) {
log.debug("Linking multiple peer EncryptedKeys with CarriedKeyName and DataReference");
// Get the name of the data encryption key
- final List<KeyName> dataEncKeyNames = encData.getKeyInfo().getKeyNames();
+ final List<KeyName> dataEncKeyNames;
+ if (encData.getKeyInfo() instanceof KeyInfo keyInfo) {
+ dataEncKeyNames = keyInfo.getKeyNames();
+ } else {
+ dataEncKeyNames = CollectionSupport.emptyList();
+ }
+
final String carriedKeyNameValue;
if (dataEncKeyNames.size() == 0 || Strings.isNullOrEmpty(dataEncKeyNames.get(0).getValue())) {
// If there isn't one, autogenerate a random key name.
@@ -544,15 +555,19 @@ public class Encrypter extends org.opensaml.xmlsec.encryption.support.Encrypter
// Set carried key name of the multicast key in each EncryptedKey
for (final EncryptedKey encKey : encKeys) {
- if (encKey.getCarriedKeyName() == null) {
- encKey.setCarriedKeyName(carriedKeyNameBuilder.buildObject());
+ CarriedKeyName carriedName = encKey.getCarriedKeyName();
+ if (carriedName == null) {
+ carriedName = carriedKeyNameBuilder.buildObject();
+ encKey.setCarriedKeyName(carriedName);
}
- encKey.getCarriedKeyName().setValue(carriedKeyNameValue);
+ carriedName.setValue(carriedKeyNameValue);
// Back reference from the EncryptedKeys to the EncryptedData
- final DataReference dr = dataReferenceBuilder.buildObject();
- dr.setURI("#" + encData.getID());
- encKey.getReferenceList().getDataReferences().add(dr);
+ if (encKey.getReferenceList() instanceof ReferenceList refList) {
+ final DataReference dr = dataReferenceBuilder.buildObject();
+ dr.setURI("#" + encData.getID());
+ refList.getDataReferences().add(dr);
+ }
}
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/AbstractSAML2NameIDGenerator.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/AbstractSAML2NameIDGenerator.java
index 5d3773410..09e05b89d 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/AbstractSAML2NameIDGenerator.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/AbstractSAML2NameIDGenerator.java
@@ -32,11 +32,11 @@ import org.opensaml.saml.common.profile.AbstractNameIdentifierGenerator;
import org.opensaml.saml.saml2.core.AuthnRequest;
import org.opensaml.saml.saml2.core.NameID;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.Strings;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* Abstract base class for simple implementations of {@link SAML2NameIDGenerator}.
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/SAML2ActionSupport.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/SAML2ActionSupport.java
index c80bb18fa..7fd4dc367 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/SAML2ActionSupport.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/SAML2ActionSupport.java
@@ -32,8 +32,8 @@ import org.opensaml.saml.saml2.core.Conditions;
import org.opensaml.saml.saml2.core.Issuer;
import org.opensaml.saml.saml2.core.Response;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.security.IdentifierGenerationStrategy;
/** Helper methods for SAML 2 IdP actions. */
diff --git a/opensaml-saml-api/src/main/java/overview.html b/opensaml-saml-api/src/main/java/overview.html
deleted file mode 100644
index 113af6897..000000000
--- a/opensaml-saml-api/src/main/java/overview.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<HTML>
-<BODY>
-<p>The OpenSAML library allows developers to work with SAML messages as Java bean objects. This library supports the
-SAML 1.0, 1.1, and 2.0 specification.</p>
-<p>The OpenWS library, contained within OpenSAML, provides a growing set of tools to work with web services at a low
-level. These tools include classes for creating and reading SOAP messages, transport-independent clients for connecting
-to web services, and various transports for use with those clients.</p>
-<p>The XMLTooling library, contained within OpenSAML, provides the ability to work with XML as regular Java beans.
-This is similar to the <a href="http://java.sun.com/webservices/jaxb/">Java Architecture for XML Binding (JAXB)</a> , <a
- href="http://xmlbeans.apache.org/">XMLBeans</a> , and <a href="http://xstream.codehaus.org/">XStream</a> libraries.
-It differs from these libraries in three main ways:
-<ul>
- <li>Much finer control to developer for what happens during the marshalling and unmarshalling processes</li>
- <li>Much more extensible, allowing various implementations of all of it's XMLObjects</li>
- <li>Support for XML Digital Signatures and Encryption</li>
-</ul>
-</p>
-</BODY>
-</HTML>
diff --git a/opensaml-saml-api/src/test/java/org/opensaml/saml/common/binding/SAMLBindingSupportTest.java b/opensaml-saml-api/src/test/java/org/opensaml/saml/common/binding/SAMLBindingSupportTest.java
index 41d11c071..3c160bd8a 100644
--- a/opensaml-saml-api/src/test/java/org/opensaml/saml/common/binding/SAMLBindingSupportTest.java
+++ b/opensaml-saml-api/src/test/java/org/opensaml/saml/common/binding/SAMLBindingSupportTest.java
@@ -22,6 +22,7 @@ import org.testng.annotations.Test;
import net.shibboleth.shared.logic.ConstraintViolationException;
+ at SuppressWarnings("javadoc")
public class SAMLBindingSupportTest {
@Test
@@ -45,13 +46,6 @@ public class SAMLBindingSupportTest {
// expected
}
- try {
- SAMLBindingSupport.convertSAML2ArtifactEndpointIndex(null);
- Assert.fail("Should have failed on null input");
- } catch (ConstraintViolationException e) {
- // expected
- }
-
try {
SAMLBindingSupport.convertSAML2ArtifactEndpointIndex(new byte[] {0x02});
Assert.fail("Should have failed on too short input");
diff --git a/opensaml-saml-api/src/test/java/org/opensaml/saml/common/messaging/SAMLMessageSecuritySupportTest.java b/opensaml-saml-api/src/test/java/org/opensaml/saml/common/messaging/SAMLMessageSecuritySupportTest.java
index 2977c79ac..d861d857a 100644
--- a/opensaml-saml-api/src/test/java/org/opensaml/saml/common/messaging/SAMLMessageSecuritySupportTest.java
+++ b/opensaml-saml-api/src/test/java/org/opensaml/saml/common/messaging/SAMLMessageSecuritySupportTest.java
@@ -22,9 +22,7 @@ import org.opensaml.saml.config.SAMLConfiguration;
import org.testng.Assert;
import org.testng.annotations.Test;
-/**
- *
- */
+ at SuppressWarnings("javadoc")
public class SAMLMessageSecuritySupportTest {
@Test
@@ -44,7 +42,6 @@ public class SAMLMessageSecuritySupportTest {
// check normalization
Assert.assertTrue(SAMLMessageSecuritySupport.checkURLScheme(" HTTPS "));
Assert.assertFalse(SAMLMessageSecuritySupport.checkURLScheme(" "));
- Assert.assertFalse(SAMLMessageSecuritySupport.checkURLScheme(null));
}
}
diff --git a/opensaml-saml-api/src/test/java/org/opensaml/saml/config/SAMLConfigurationTest.java b/opensaml-saml-api/src/test/java/org/opensaml/saml/config/SAMLConfigurationTest.java
index 9cc27ad2e..5cd3b7756 100644
--- a/opensaml-saml-api/src/test/java/org/opensaml/saml/config/SAMLConfigurationTest.java
+++ b/opensaml-saml-api/src/test/java/org/opensaml/saml/config/SAMLConfigurationTest.java
@@ -24,9 +24,7 @@ import org.testng.annotations.Test;
import com.google.common.collect.Lists;
-/**
- *
- */
+ at SuppressWarnings("javadoc")
public class SAMLConfigurationTest {
@Test
diff --git a/opensaml-saml-api/src/test/java/org/opensaml/saml/metadata/EntityGroupNameTest.java b/opensaml-saml-api/src/test/java/org/opensaml/saml/metadata/EntityGroupNameTest.java
index 84e1b88e1..5cdd7d300 100644
--- a/opensaml-saml-api/src/test/java/org/opensaml/saml/metadata/EntityGroupNameTest.java
+++ b/opensaml-saml-api/src/test/java/org/opensaml/saml/metadata/EntityGroupNameTest.java
@@ -17,13 +17,12 @@
package org.opensaml.saml.metadata;
-
-
import org.testng.Assert;
import org.testng.annotations.Test;
import net.shibboleth.shared.logic.ConstraintViolationException;
+ at SuppressWarnings("javadoc")
public class EntityGroupNameTest {
@Test
@@ -35,11 +34,6 @@ public class EntityGroupNameTest {
Assert.assertEquals(groupName.getName(), "foo");
}
- @Test(expectedExceptions=ConstraintViolationException.class)
- public void testConstructorOnNull() {
- new EntityGroupName(null);
- }
-
@Test(expectedExceptions=ConstraintViolationException.class)
public void testConstructorOnEmpty() {
new EntityGroupName(" ");
diff --git a/opensaml-saml-api/src/test/java/org/opensaml/saml/metadata/resolver/index/SimpleStringMetadataIndexKeyTest.java b/opensaml-saml-api/src/test/java/org/opensaml/saml/metadata/resolver/index/SimpleStringMetadataIndexKeyTest.java
index b86b6462c..1899e2aa7 100644
--- a/opensaml-saml-api/src/test/java/org/opensaml/saml/metadata/resolver/index/SimpleStringMetadataIndexKeyTest.java
+++ b/opensaml-saml-api/src/test/java/org/opensaml/saml/metadata/resolver/index/SimpleStringMetadataIndexKeyTest.java
@@ -22,9 +22,7 @@ import org.testng.annotations.Test;
import net.shibboleth.shared.logic.ConstraintViolationException;
-/**
- *
- */
+ at SuppressWarnings("javadoc")
public class SimpleStringMetadataIndexKeyTest {
@Test
@@ -46,13 +44,6 @@ public class SimpleStringMetadataIndexKeyTest {
} catch (ConstraintViolationException e) {
// expected
}
-
- try {
- key = new SimpleStringMetadataIndexKey(null);
- Assert.fail("Constructor should have failed on null input");
- } catch (ConstraintViolationException e) {
- // expected
- }
}
@Test
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml1/profile/impl/AbstractSAML1NameIdentifierGeneratorTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml1/profile/impl/AbstractSAML1NameIdentifierGeneratorTest.java
index b76053265..223953cd6 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml1/profile/impl/AbstractSAML1NameIdentifierGeneratorTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml1/profile/impl/AbstractSAML1NameIdentifierGeneratorTest.java
@@ -29,16 +29,11 @@ import org.testng.Assert;
import org.testng.annotations.Test;
/** Test for {@link AbstractSAML1NameIdentifierGenerator}. */
+ at SuppressWarnings("javadoc")
public class AbstractSAML1NameIdentifierGeneratorTest extends OpenSAMLInitBaseTestCase {
private static final String NAME_QUALIFIER = "https://idp.example.org";
- @Test(expectedExceptions = ComponentInitializationException.class)
- public void testNoFormat() throws ComponentInitializationException {
- final MockSAML1NameIdentifierGenerator mock = new MockSAML1NameIdentifierGenerator();
- mock.initialize();
- }
-
@Test
public void testFull() throws ComponentInitializationException, SAMLException {
final MockSAML1NameIdentifierGenerator mock = new MockSAML1NameIdentifierGenerator();
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/profile/impl/AbstractSAML2NameIDGeneratorTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/profile/impl/AbstractSAML2NameIDGeneratorTest.java
index 324154aae..668c086d0 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/profile/impl/AbstractSAML2NameIDGeneratorTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/profile/impl/AbstractSAML2NameIDGeneratorTest.java
@@ -31,18 +31,13 @@ import org.testng.Assert;
import org.testng.annotations.Test;
/** Test for {@link AbstractSAML2NameIDGenerator}. */
+ at SuppressWarnings("javadoc")
public class AbstractSAML2NameIDGeneratorTest extends OpenSAMLInitBaseTestCase {
@Nonnull private static final String NAME_QUALIFIER = "https://idp.example.org";
@Nonnull private static final String SP_NAME_QUALIFIER = "https://sp.example.org";
- @Test(expectedExceptions = ComponentInitializationException.class)
- public void testNoFormat() throws ComponentInitializationException {
- final MockSAML2NameIDGenerator mock = new MockSAML2NameIDGenerator();
- mock.initialize();
- }
-
@Test
public void testFull() throws ComponentInitializationException, SAMLException {
final MockSAML2NameIDGenerator mock = new MockSAML2NameIDGenerator();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list