[java-identity-provider] branch master updated: Improve transcoder rule config a bit.

Scott Cantor cantor.2 at osu.edu
Wed Jun 5 11:57:16 EDT 2019


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=f941c5111e247fb04e44c5031653dfab9a56bd1c

The following commit(s) were added to refs/heads/master by this push:
       new  f941c51   Improve transcoder rule config a bit.
f941c51 is described below

commit f941c5111e247fb04e44c5031653dfab9a56bd1c
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jun 5 11:57:12 2019 -0400

    Improve transcoder rule config a bit.
---
 .../transcoding/impl/TranscodingRuleLoader.java    |  24 +++++
 .../main/resources/attributes/default-rules.xml    | 102 ++++++++++-----------
 2 files changed, 71 insertions(+), 55 deletions(-)

diff --git a/idp-attribute-impl/src/main/java/net/shibboleth/idp/attribute/transcoding/impl/TranscodingRuleLoader.java b/idp-attribute-impl/src/main/java/net/shibboleth/idp/attribute/transcoding/impl/TranscodingRuleLoader.java
index 844e40c..fc2644a 100644
--- a/idp-attribute-impl/src/main/java/net/shibboleth/idp/attribute/transcoding/impl/TranscodingRuleLoader.java
+++ b/idp-attribute-impl/src/main/java/net/shibboleth/idp/attribute/transcoding/impl/TranscodingRuleLoader.java
@@ -25,6 +25,7 @@ import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import javax.annotation.Nonnull;
 
@@ -32,9 +33,12 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.io.FileSystemResource;
 
+import com.google.common.base.Predicates;
+
 import net.shibboleth.idp.attribute.transcoding.TranscodingRule;
 import net.shibboleth.utilities.java.support.annotation.ParameterName;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.logic.Constraint;
 
 /**
  * Wrapper around a {@link Map} representing a rule for transcoding, used to
@@ -51,6 +55,8 @@ public class TranscodingRuleLoader {
     /**
      * Load rules from all files found below a directory root.
      * 
+     * <p>Files are assumed to be Java property files in text format.</p>
+     * 
      * <p>Individual rules that fail to load will be skipped.</p>
      * 
      * @param dir root to search
@@ -82,6 +88,24 @@ public class TranscodingRuleLoader {
             }
         }
     }
+    
+    /**
+     * Constructor.
+     *
+     * @param maps a collection of maps to build rules around directly.
+     */
+    public TranscodingRuleLoader(
+            @Nonnull @NonnullElements @ParameterName(name="maps") final Collection<Map<String,Object>> maps) {
+        Constraint.isNotNull(maps, "Input collection cannot be null");
+        
+        rules = maps
+                .stream()
+                .filter(Predicates.notNull())
+                .map(m -> {
+                    return new TranscodingRule(m);
+                    })
+                .collect(Collectors.toList());
+    }
 
     /**
      * Get the rules loaded by this object.
diff --git a/idp-conf/src/main/resources/attributes/default-rules.xml b/idp-conf/src/main/resources/attributes/default-rules.xml
index 38cc30b..657a83d 100644
--- a/idp-conf/src/main/resources/attributes/default-rules.xml
+++ b/idp-conf/src/main/resources/attributes/default-rules.xml
@@ -13,65 +13,57 @@
        default-destroy-method="destroy">
 
     <!-- Default Attribute transcoding rules. -->
+    
+    <bean parent="shibboleth.TranscodingRuleLoader">
+    <constructor-arg>
+    <list>
+    
+        <bean parent="shibboleth.TranscodingProperties">
+            <property name="sourceMap">
+                <map merge="true">
+                    <entry key="id" value="uid" />
+                    <entry key="transcoder" value="SAML2StringTranscoder SAML1StringTranscoder" />
+                    <entry key="saml2.name" value="urn:oid:0.9.2342.19200300.100.1.1" />
+                    <entry key="saml1.name" value="urn:mace:dir:attribute-def:uid" />
+                </map>
+            </property>
+        </bean>
 
-    <bean parent="shibboleth.TranscodingRule">
-        <constructor-arg>
-            <bean parent="shibboleth.TranscodingProperties">
-                <property name="sourceMap">
-                    <map merge="true">
-                        <entry key="id" value="uid" />
-                        <entry key="transcoder" value="SAML2StringTranscoder SAML1StringTranscoder" />
-                        <entry key="saml2.name" value="urn:oid:0.9.2342.19200300.100.1.1" />
-                        <entry key="saml1.name" value="urn:mace:dir:attribute-def:uid" />
-                    </map>
-                </property>
-            </bean>
-        </constructor-arg>
-    </bean>
+        <bean parent="shibboleth.TranscodingProperties">
+            <property name="sourceMap">
+                <map merge="true">
+                    <entry key="id" value="mail" />
+                    <entry key="transcoder" value="SAML2StringTranscoder SAML1StringTranscoder" />
+                    <entry key="saml2.name" value="urn:oid:0.9.2342.19200300.100.1.3" />
+                    <entry key="saml1.name" value="urn:mace:dir:attribute-def:mail" />
+                </map>
+            </property>
+        </bean>
 
-    <bean parent="shibboleth.TranscodingRule">
-        <constructor-arg>
-            <bean parent="shibboleth.TranscodingProperties">
-                <property name="sourceMap">
-                    <map merge="true">
-                        <entry key="id" value="mail" />
-                        <entry key="transcoder" value="SAML2StringTranscoder SAML1StringTranscoder" />
-                        <entry key="saml2.name" value="urn:oid:0.9.2342.19200300.100.1.3" />
-                        <entry key="saml1.name" value="urn:mace:dir:attribute-def:mail" />
-                    </map>
-                </property>
-            </bean>
-        </constructor-arg>
-    </bean>
+        <bean parent="shibboleth.TranscodingProperties">
+            <property name="sourceMap">
+                <map merge="true">
+                    <entry key="id" value="eduPersonPrincipalName" />
+                    <entry key="transcoder" value="SAML2ScopedStringTranscoder SAML1ScopedStringTranscoder" />
+                    <entry key="saml2.name" value="urn:oid:1.3.6.1.4.1.5923.1.1.1.6" />
+                    <entry key="saml1.name" value="urn:mace:dir:attribute-def:eduPersonPrincipalName" />
+                </map>
+            </property>
+        </bean>
 
-    <bean parent="shibboleth.TranscodingRule">
-        <constructor-arg>
-            <bean parent="shibboleth.TranscodingProperties">
-                <property name="sourceMap">
-                    <map merge="true">
-                        <entry key="id" value="eduPersonPrincipalName" />
-                        <entry key="transcoder" value="SAML2ScopedStringTranscoder SAML1ScopedStringTranscoder" />
-                        <entry key="saml2.name" value="urn:oid:1.3.6.1.4.1.5923.1.1.1.6" />
-                        <entry key="saml1.name" value="urn:mace:dir:attribute-def:eduPersonPrincipalName" />
-                    </map>
-                </property>
-            </bean>
-        </constructor-arg>
-    </bean>
+        <bean parent="shibboleth.TranscodingProperties">
+            <property name="sourceMap">
+                <map merge="true">
+                    <entry key="id" value="eduPersonScopedAffiliation" />
+                    <entry key="transcoder" value="SAML2ScopedStringTranscoder SAML1ScopedStringTranscoder" />
+                    <entry key="saml2.name" value="urn:oid:1.3.6.1.4.1.5923.1.1.1.9" />
+                    <entry key="saml1.name" value="urn:mace:dir:attribute-def:eduPersonScopedAffiliation" />
+                </map>
+            </property>
+        </bean>
 
-    <bean parent="shibboleth.TranscodingRule">
-        <constructor-arg>
-            <bean parent="shibboleth.TranscodingProperties">
-                <property name="sourceMap">
-                    <map merge="true">
-                        <entry key="id" value="eduPersonScopedAffiliation" />
-                        <entry key="transcoder" value="SAML2ScopedStringTranscoder SAML1ScopedStringTranscoder" />
-                        <entry key="saml2.name" value="urn:oid:1.3.6.1.4.1.5923.1.1.1.9" />
-                        <entry key="saml1.name" value="urn:mace:dir:attribute-def:eduPersonScopedAffiliation" />
-                    </map>
-                </property>
-            </bean>
-        </constructor-arg>
+    </list>
+    </constructor-arg>
     </bean>
     
 </beans>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list