[java-identity-provider COMMIT] in /trunk/idp-saml-impl/src: main/java/net/shibboleth/idp/saml/nameid/impl/ComputedPe...

noreply at shibboleth.net noreply at shibboleth.net
Wed Aug 31 17:41:04 EDT 2016


Author: scantor
Date: Wed Aug 31 17:41:04 2016
New Revision: 8362

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8362&view=rev
Log:
IDP-1019 - Deprecation of various nameid properties in favor of String beans

https://issues.shibboleth.net/jira/browse/IDP-1019

Initial impetus for this issue was an inability to easily escape characters
in properties, so this implements Rod's suggestion to add a setter that
takes a Base64 string.

Modified:
    trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ComputedPersistentIdGenerationStrategy.java
    trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/nameid/impl/PersistentSAML2NameIDGeneratorTest.java

Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ComputedPersistentIdGenerationStrategy.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ComputedPersistentIdGenerationStrategy.java?rev=8362&r1=8361&r2=8362&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ComputedPersistentIdGenerationStrategy.java	(original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ComputedPersistentIdGenerationStrategy.java	Wed Aug 31 17:41:04 2016
@@ -75,6 +75,18 @@
         
         salt = Constraint.isNotEmpty(newValue, "Salt cannot be null or empty");
     }
+    
+    /**
+     * Set the base64-encoded salt used when computing the ID.
+     * 
+     * @param newValue used when computing the ID
+     */
+    public void setEncodedSalt(@Nonnull @NotEmpty final String newValue) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        
+        Constraint.isNotEmpty(newValue, "Salt cannot be null or empty");
+        salt = Base64Support.decode(newValue);
+    }
 
     /**
      * Set the JCE algorithm name of the digest algorithm to use (default is SHA).

Modified: trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/nameid/impl/PersistentSAML2NameIDGeneratorTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/nameid/impl/PersistentSAML2NameIDGeneratorTest.java?rev=8362&r1=8361&r2=8362&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/nameid/impl/PersistentSAML2NameIDGeneratorTest.java	(original)
+++ trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/nameid/impl/PersistentSAML2NameIDGeneratorTest.java	Wed Aug 31 17:41:04 2016
@@ -29,6 +29,7 @@
 import net.shibboleth.idp.profile.context.RelyingPartyContext;
 import net.shibboleth.idp.saml.impl.TestSources;
 import net.shibboleth.idp.testing.DatabaseTestingSupport;
+import net.shibboleth.utilities.java.support.codec.Base64Support;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 
 import org.opensaml.core.OpenSAMLInitBaseTestCase;
@@ -89,7 +90,17 @@
         generator.setPersistentIdGenerator(strategy);
         generator.initialize();
     }
-    
+
+    @Test
+    public void testSaltSetters() throws ComponentInitializationException {
+        final ComputedPersistentIdGenerationStrategy strategy = new ComputedPersistentIdGenerationStrategy();
+        strategy.setSalt(salt);
+        Assert.assertEquals(salt, strategy.getSalt());
+        
+        strategy.setEncodedSalt(Base64Support.encode(salt, false));
+        Assert.assertEquals(salt, strategy.getSalt());
+    }
+
     @Test
     public void testNoResponderId() throws Exception {
         generator.setPersistentIdGenerator(new ComputedPersistentIdGenerationStrategy());



More information about the commits mailing list