[java-identity-provider COMMIT] in /trunk: idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter...

noreply at shibboleth.net noreply at shibboleth.net
Tue Aug 6 11:00:05 EDT 2013


Author: rdw
Date: Tue Aug  6 11:00:05 2013
New Revision: 4667

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4667&view=rev
Log:
IDP-264 Some minor changes as a result of conversations in shib-dev. Most notable are
 - use a default setting for brevity in the beans file
 - The id is no longer the primary attribute id.  Rather all attribute Ids are now contained in the array formaly known as aliases and now known as attributeIds

Modified:
    trunk/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/attributemapper/AbstractSAMLAttributeMapper.java
    trunk/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/impl/policyrule/saml/attributemapper/RequestedAttributeMapperTest.java
    trunk/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/impl/policyrule/saml/attributemapper/RequestedAttributesMapperTest.java

Modified: trunk/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/attributemapper/AbstractSAMLAttributeMapper.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/attributemapper/AbstractSAMLAttributeMapper.java?rev=4667&r1=4666&r2=4667&view=diff
==============================================================================
--- trunk/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/attributemapper/AbstractSAMLAttributeMapper.java (original)
+++ trunk/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/attributemapper/AbstractSAMLAttributeMapper.java Tue Aug  6 11:00:05 2013
@@ -17,7 +17,6 @@
 
 package net.shibboleth.idp.attribute.filter.attributemapper;
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -42,21 +41,25 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Predicates;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableList;
+
 /**
  * Basis of all classes which map SAML2 {@link org.opensaml.saml.saml2.core.Attribute} into an IdP {@link Attribute}.
  * 
  * @param <InType> the input (SAML2 attribute) type
  * @param <OutType> the output (IdP Attribute) type
  */
-public abstract class AbstractSAMLAttributeMapper 
-        <InType extends org.opensaml.saml.saml2.core.Attribute, OutType extends Attribute>
+public abstract class AbstractSAMLAttributeMapper<InType extends org.opensaml.saml.saml2.core.Attribute, 
+                                                  OutType extends Attribute>
         extends AbstractIdentifiableInitializableComponent implements AttributeMapper<InType, OutType> {
 
     /** log. */
     private final Logger log = LoggerFactory.getLogger(AbstractSAMLAttributeMapper.class);
 
     /** The internal names to generate. */
-    private List<String> attributeAliases = Collections.EMPTY_LIST;
+    private List<String> attributeIds = Collections.EMPTY_LIST;
 
     /** The attribute format. */
     private String attributeFormat;
@@ -73,23 +76,15 @@
     /**
      * Sets the list of internal identifiers.
      * 
-     * @param aliases the list
-     */
-    public void setAliases(@Nullable @NullableElements final List<String> aliases) {
+     * @param theIds the list
+     */
+    public void setAttributeIds(@Nullable @NullableElements final List<String> theIds) {
         ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-        if (null == aliases) {
+        if (null == theIds) {
             return;
         }
 
-        final ArrayList<String> newList = new ArrayList<String>(aliases.size());
-
-        for (String s : aliases) {
-            final String trimmed = StringSupport.trimOrNull(s);
-            if (null != trimmed) {
-                newList.add(trimmed);
-            }
-        }
-        attributeAliases = Collections.unmodifiableList(newList);
+        attributeIds = ImmutableList.copyOf(Collections2.filter(theIds, Predicates.notNull()));
     }
 
     /**
@@ -97,8 +92,8 @@
      * 
      * @return the identifiers
      */
-    @Nonnull @NonnullElements @Unmodifiable public List<String> getAliases() {
-        return attributeAliases;
+    @Nonnull @NonnullElements @Unmodifiable public List<String> getAttributeIds() {
+        return attributeIds;
     }
 
     /**
@@ -170,6 +165,10 @@
         if (null == valueMapper) {
             throw new ComponentInitializationException(getLogPrefix() + " No value mapper present");
         }
+        if (attributeIds.isEmpty()) {
+            throw new ComponentInitializationException(getLogPrefix() + 
+                    " At least one attribute Id should be provided");
+        }
         logPrefix = null;
         valueMapper.setLogPrefix(getLogPrefix());
     }
@@ -193,7 +192,7 @@
         if (org.opensaml.saml.saml2.core.Attribute.UNSPECIFIED.equals(format)) {
             format = null;
         }
-        
+

[... 127 lines stripped ...]


More information about the commits mailing list