[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
Wed Jan 22 19:26:56 EST 2014


Author: scantor
Date: Wed Jan 22 19:26:56 2014
New Revision: 3565

URL: http://svn.shibboleth.net/view/java-opensaml?rev=3565&view=rev
Log:
Add activation predicate to NameIDGenerator interface/class.

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

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=3565&r1=3564&r2=3565&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 Wed Jan 22 19:26:56 2014
@@ -33,6 +33,8 @@
 import org.opensaml.saml.common.SAMLObject;
 
 import com.google.common.base.Objects;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
 
 /**
  * Abstract base class for simple implementations of {@link NameIdentifierGenerator}.
@@ -48,6 +50,9 @@
 public abstract class AbstractNameIdentifierGenerator<NameIdType extends SAMLObject>
         extends AbstractIdentifiableInitializableComponent implements NameIdentifierGenerator<NameIdType> {
 
+    /** A predicate indicating whether the component applies to a request. */
+    @Nonnull private Predicate<ProfileRequestContext> activationCondition;
+    
     /** Flag allowing qualifier(s) to be ommitted when they would match defaults or are not set. */
     private boolean omitQualifiers; 
     
@@ -66,6 +71,19 @@
     /** Constructor. */
     protected AbstractNameIdentifierGenerator() {
         super.setId(getClass().getName());
+        
+        activationCondition = Predicates.alwaysTrue();
+    }
+    
+    /**
+     * Set an activation condition that determines whether to run or not.
+     * 
+     * @param condition an activation condition
+     */
+    public void setActivationCondition(@Nonnull final Predicate<ProfileRequestContext> condition) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        
+        activationCondition = Constraint.isNotNull(condition, "Predicate cannot be null");
     }
     
     /**
@@ -87,6 +105,8 @@
      * @param flag flag to set
      */
     public void setOmitQualifiers(final boolean flag) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        
         omitQualifiers = flag;
     }
 
@@ -186,6 +206,12 @@
         }
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public boolean apply(@Nullable final ProfileRequestContext input) {
+        return activationCondition.apply(input);
+    }
+    
     /** {@inheritDoc} */
     @Override
     @Nonnull public NameIdType generate(@Nonnull final ProfileRequestContext 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=3565&r1=3564&r2=3565&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 Wed Jan 22 19:26:56 2014
@@ -23,21 +23,26 @@
 import org.opensaml.profile.context.ProfileRequestContext;
 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.
  * 
  * <p>Such a component typically consumes attribute information produced about the subject and
  * transforms it (possibly via identity function) into use as a subject identifier. This operation
- * is essentially the inverse of a subject canonicalication flow that operates on SAML identifiers
+ * is essentially the inverse of a subject canonicalization flow that operates on SAML identifiers
  * and turns them back into principal names.</p>
  * 
- * <p>A component may be self-contained and need not depend on any attributes, depending on the
- * nature of the identifier.</p>
+ * <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
  */

[... 6 lines stripped ...]


More information about the commits mailing list