[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
Wed Mar 6 09:48:15 EST 2013


Author: rdw
Date: Wed Mar  6 09:48:15 2013
New Revision: 4304

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4304&view=rev
Log:
IDP-272  Port CryptoTransientIdAttributeDefinition to V3 APIs.  Test coverage for the resolver and for the Data Sealer.  Some exception paths not tested.

Modified:
    trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/DataSealer.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/CryptoTransientIdAttributeDefinitionTest.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/DataSealerTest.java

Modified: trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/DataSealer.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/DataSealer.java?rev=4304&r1=4303&r2=4304&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/DataSealer.java (original)
+++ trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/DataSealer.java Wed Mar  6 09:48:15 2013
@@ -550,7 +550,7 @@
      * @param exp timestamp to prefix the data with
      * @return the resulting MAC
      */
-    private static byte[] getMAC(Mac mac, String data, long exp) {
+    protected static byte[] getMAC(Mac mac, String data, long exp) {
         mac.update(getLongBytes(exp));
         mac.update(data.getBytes());
         return mac.doFinal();
@@ -562,7 +562,7 @@
      * @param longValue value to convert
      * @return a byte array
      */
-    private static byte[] getLongBytes(long longValue) {
+    protected static byte[] getLongBytes(long longValue) {
         try {
             ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
             DataOutputStream dataStream = new DataOutputStream(byteStream);

Modified: trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/CryptoTransientIdAttributeDefinitionTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/CryptoTransientIdAttributeDefinitionTest.java?rev=4304&r1=4303&r2=4304&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/CryptoTransientIdAttributeDefinitionTest.java (original)
+++ trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/CryptoTransientIdAttributeDefinitionTest.java Wed Mar  6 09:48:15 2013
@@ -108,7 +108,41 @@
         Assert.assertEquals(defn.getIdLifetime(), TIMEOUT);
         Assert.assertEquals(defn.getDataSealer(), dataSealer);
     }
+    
+    @Test public void testBadVals() throws ComponentInitializationException {
+        final CryptoTransientIdAttributeDefinition defn = new CryptoTransientIdAttributeDefinition();
+        defn.setId(ID);
+        defn.setDataSealer(dataSealer);
+        defn.setIdLifetime(TIMEOUT);
+        defn.initialize();
+        
+        try {
+            defn.resolve(new AttributeResolutionContext());
+            Assert.fail("No SP");
+        } catch (ResolutionException e) {
+            // OK
+        }
 
+        try {
+            defn.resolve(TestSources.createResolutionContext(TestSources.PRINCIPAL_ID, TestSources.IDP_ENTITY_ID, null));
+            Assert.fail("No SP");
+        } catch (ResolutionException e) {
+            // OK
+        }
+        try {
+            defn.resolve(TestSources.createResolutionContext(TestSources.PRINCIPAL_ID, null, TestSources.SP_ENTITY_ID));
+            Assert.fail("No IdP");
+        } catch (ResolutionException e) {
+            // OK
+        }
+        try {
+            defn.resolve(TestSources.createResolutionContext(null, TestSources.IDP_ENTITY_ID, TestSources.SP_ENTITY_ID));
+            Assert.fail("No IdP");
+        } catch (ResolutionException e) {
+            // OK
+        }
+    }
+        
     @Test public void testEncode() throws ComponentInitializationException, ResolutionException, DataSealerException,
             InterruptedException {
         final CryptoTransientIdAttributeDefinition defn = new CryptoTransientIdAttributeDefinition();

Modified: trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/DataSealerTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/DataSealerTest.java?rev=4304&r1=4303&r2=4304&view=diff
==============================================================================

[... 357 lines stripped ...]


More information about the commits mailing list