[java-opensaml COMMIT] in /trunk: opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/AbstractNameIdenti...
noreply at shibboleth.net
noreply at shibboleth.net
Thu May 1 21:22:52 EDT 2014
Author: scantor
Date: Thu May 1 21:22:52 2014
New Revision: 3836
URL: http://svn.shibboleth.net/view/java-opensaml?rev=3836&view=rev
Log:
Move predicate inside NameID generators to simplify service abstraction.
Modified:
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/AbstractNameIdentifierGenerator.java
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/NameIdentifierGenerator.java
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/profile/impl/ChainingNameIdentifierGenerator.java
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/profile/impl/AddNameIdentifierToSubjects.java
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/AddNameIDToSubjects.java
Modified: trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/AbstractNameIdentifierGenerator.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/AbstractNameIdentifierGenerator.java?rev=3836&r1=3835&r2=3836&view=diff
==============================================================================
--- trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/AbstractNameIdentifierGenerator.java (original)
+++ trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/AbstractNameIdentifierGenerator.java Thu May 1 21:22:52 2014
@@ -52,8 +52,9 @@
*
* @param <NameIdType> type of object produced
*/
-public abstract class AbstractNameIdentifierGenerator<NameIdType extends SAMLObject> extends
- AbstractIdentifiableInitializableComponent implements FormatSpecificNameIdentifierGenerator<NameIdType> {
+public abstract class AbstractNameIdentifierGenerator<NameIdType extends SAMLObject>
+ extends AbstractIdentifiableInitializableComponent
+ implements FormatSpecificNameIdentifierGenerator<NameIdType>, Predicate<ProfileRequestContext> {
/** A predicate indicating whether the component applies to a request. */
@Nonnull private Predicate<ProfileRequestContext> activationCondition;
@@ -245,7 +246,8 @@
}
/** {@inheritDoc} */
- @Override protected void doInitialize() throws ComponentInitializationException {
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
if (format == null) {
@@ -254,17 +256,21 @@
}
/** {@inheritDoc} */
- @Override public boolean apply(@Nullable final ProfileRequestContext input) {
+ @Override
+ public boolean apply(@Nullable final ProfileRequestContext input) {
return activationCondition.apply(input);
}
/** {@inheritDoc} */
- @Override @Nullable public NameIdType generate(@Nonnull final ProfileRequestContext profileRequestContext,
+ @Override
+ @Nullable public NameIdType generate(@Nonnull final ProfileRequestContext profileRequestContext,
@Nonnull @NotEmpty final String theFormat) throws SAMLException {
ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
if (!Objects.equal(format, theFormat)) {
throw new SAMLException("The format to generate does not match the value configured");
+ } else if (!apply(profileRequestContext)) {
+ return null;
}
return doGenerate(profileRequestContext);
}
Modified: trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/NameIdentifierGenerator.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/NameIdentifierGenerator.java?rev=3836&r1=3835&r2=3836&view=diff
==============================================================================
--- trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/NameIdentifierGenerator.java (original)
+++ trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/NameIdentifierGenerator.java Thu May 1 21:22:52 2014
@@ -26,8 +26,6 @@
import org.opensaml.saml.common.SAMLException;
import org.opensaml.saml.common.SAMLObject;
-import com.google.common.base.Predicate;
-
/**
* Interface for a component that produces SAML {@link org.opensaml.saml.saml1.core.NameIdentifier}
* and/or {@link org.opensaml.saml.saml2.NameID} objects for inclusion in assertion subjects.
@@ -40,12 +38,9 @@
* <p>A component may be self-contained and need not depend on any other subject information,
* depending on the nature of the identifier.</p>
*
- * <p>All such components support a predicate interface to evaluate whether or not they apply
- * to a request.</p>
- *
* @param <NameIdType> type of object produced
*/
-public interface NameIdentifierGenerator<NameIdType extends SAMLObject> extends Predicate<ProfileRequestContext> {
+public interface NameIdentifierGenerator<NameIdType extends SAMLObject> {
/**
* Generate an identifier object.
Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/profile/impl/ChainingNameIdentifierGenerator.java
[... 104 lines stripped ...]
More information about the commits
mailing list