[java-identity-provider COMMIT] in /trunk/idp-attribute-resolver-impl/src: main/java/net/shibboleth/idp/attribute/res...

noreply at shibboleth.net noreply at shibboleth.net
Sat Aug 20 13:20:18 BST 2011


Author: rdw
Date: Sat Aug 20 13:20:18 2011
New Revision: 4025

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4025&view=rev
Log:
Mapped, Prescoped, Regex, Scoped, Scripted & template attribute definition become Initializable, Unmodifiable Components.

Modified:
    trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/MappedAttributeDefinition.java
    trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/PrescopedAttributeDefinition.java
    trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/RegexSplitAttributeDefinition.java
    trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ScopedAttributeDefinition.java
    trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ScriptedAttributeDefinition.java
    trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/TemplateAttributeDefinition.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/MappedAttributeTester.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/PrecscopedAtributeTest.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/RegexAtributeTest.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ScopedAttributeTest.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ScriptedAttributeTest.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/TemplateAttributeTest.java

Modified: trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/MappedAttributeDefinition.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/MappedAttributeDefinition.java?rev=4025&r1=4024&r2=4025&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/MappedAttributeDefinition.java (original)
+++ trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/MappedAttributeDefinition.java Sat Aug 20 13:20:18 2011
@@ -31,6 +31,8 @@
 import org.opensaml.util.StringSupport;
 import org.opensaml.util.collections.CollectionSupport;
 import org.opensaml.util.collections.LazySet;
+import org.opensaml.util.component.ComponentInitializationException;
+import org.opensaml.util.component.UnmodifiableComponentException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,67 +51,103 @@
     private final Logger log = LoggerFactory.getLogger(MappedAttributeDefinition.class);
 
     /** Default return value. */
-    private final String defaultValue;
+    private String defaultValue;
 
     /** Whether the definition passes thru unmatched values. */
-    private final boolean passThru;
+    private boolean passThru;
 
     /** Value maps. */
-    private final Collection<ValueMap> valueMaps;
-
-    /**
-     * Constructor.
-     * 
-     * @param id the name
+    private Collection<ValueMap> valueMaps;
+
+    /**
+     * Set the value maps. Cannot be called after initialization.
+     * 
      * @param maps the value maps to apply
+     */
+
+    public synchronized void setValueMaps(final Collection<ValueMap> maps) {
+        if (isInitialized()) {
+            throw new UnmodifiableComponentException("Mapped Attribute definition " + getId()
+                    + " has already been initialized, Value maps can not be changed.");
+        }
+
+        final Set<ValueMap> working = CollectionSupport.addNonNull(maps, new LazySet<ValueMap>());
+
+        if (working.isEmpty()) {
+            log.info("Mapped Attribute definition " + getId() + " empty map supplied");
+            valueMaps = Collections.EMPTY_SET;
+        } else {
+            valueMaps = Collections.unmodifiableSet(working);
+        }
+    }
+
+    /**
+     * Access to our value maps.
+     * 
+     * @return the value maps we were initialised with (never null after initialization, always normalized and
+     *         unmodifiable).
+     */
+    public Collection<ValueMap> getValueMaps() {
+        return valueMaps;
+    }
+
+    /**
+     * Set the default value. Cannot be called after initialization.
+     * 
      * @param defaultVal the default value to apply (if any)
+     */
+    public synchronized void setDefaultValue(final String defaultVal) {
+        if (isInitialized()) {
+            throw new UnmodifiableComponentException("Mapped Attribute definition " + getId()
+                    + " has already been initialized, default value can not be changed.");
+        }
+        defaultValue = StringSupport.trimOrNull(defaultVal);
+    }
+
+    /**
+     * Gets the default return value.
+     * 

[... 1619 lines stripped ...]


More information about the commits mailing list