[java-opensaml COMMIT] in /trunk: opensaml-saml-api/src/test/java/org/opensaml/saml/saml1/profile/SAML1ActionTestingS...

noreply at shibboleth.net noreply at shibboleth.net
Mon Jan 27 21:43:09 EST 2014


Author: scantor
Date: Mon Jan 27 21:43:09 2014
New Revision: 3577

URL: http://svn.shibboleth.net/view/java-opensaml?rev=3577&view=rev
Log:
IDP-127 / IDP-128: Unit tests and fixes for AddNameID actions.

Added:
    trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml1/profile/impl/AddNameIdentifierToSubjectsTest.java   (with props)
    trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/profile/impl/AddNameIDToSubjectsTest.java   (with props)
Modified:
    trunk/opensaml-saml-api/src/test/java/org/opensaml/saml/saml1/profile/SAML1ActionTestingSupport.java
    trunk/opensaml-saml-api/src/test/java/org/opensaml/saml/saml2/profile/SAML2ActionTestingSupport.java
    trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/profile/impl/AddNameIdentifierToSubjects.java
    trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/AddNameIDToSubjects.java

Modified: trunk/opensaml-saml-api/src/test/java/org/opensaml/saml/saml1/profile/SAML1ActionTestingSupport.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-api/src/test/java/org/opensaml/saml/saml1/profile/SAML1ActionTestingSupport.java?rev=3577&r1=3576&r2=3577&view=diff
==============================================================================
--- trunk/opensaml-saml-api/src/test/java/org/opensaml/saml/saml1/profile/SAML1ActionTestingSupport.java (original)
+++ trunk/opensaml-saml-api/src/test/java/org/opensaml/saml/saml1/profile/SAML1ActionTestingSupport.java Mon Jan 27 21:43:09 2014
@@ -27,6 +27,8 @@
 import org.opensaml.saml.common.SAMLVersion;
 import org.opensaml.saml.saml1.core.Assertion;
 import org.opensaml.saml.saml1.core.AttributeQuery;
+import org.opensaml.saml.saml1.core.AttributeStatement;
+import org.opensaml.saml.saml1.core.AuthenticationStatement;
 import org.opensaml.saml.saml1.core.NameIdentifier;
 import org.opensaml.saml.saml1.core.Request;
 import org.opensaml.saml.saml1.core.Response;
@@ -54,8 +56,8 @@
      * @return the constructed response
      */
     @Nonnull public static Response buildResponse() {
-        final SAMLObjectBuilder<Response> responseBuilder =
-                (SAMLObjectBuilder<Response>) XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(
+        final SAMLObjectBuilder<Response> responseBuilder = (SAMLObjectBuilder<Response>)
+                XMLObjectProviderRegistrySupport.getBuilderFactory().<Response>getBuilderOrThrow(
                         Response.DEFAULT_ELEMENT_NAME);
 
         final Response response = responseBuilder.buildObject();
@@ -73,9 +75,9 @@
      * @return the constructed assertion
      */
     @Nonnull public static Assertion buildAssertion() {
-        final SAMLObjectBuilder<Assertion> assertionBuilder =
-                (SAMLObjectBuilder<Assertion>) XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(
-                        Assertion.TYPE_NAME);
+        final SAMLObjectBuilder<Assertion> assertionBuilder = (SAMLObjectBuilder<Assertion>)
+                XMLObjectProviderRegistrySupport.getBuilderFactory().<Assertion>getBuilderOrThrow(
+                        Assertion.DEFAULT_ELEMENT_NAME);
 
         final Assertion assertion = assertionBuilder.buildObject();
         assertion.setID(ASSERTION_ID);
@@ -86,6 +88,39 @@
     }
 
     /**
+     * Builds an authentication statement. The authn instant is set to 1970-01-01T00:00:00Z and the
+     * method is set to password.
+     * 
+     * @return the constructed statement
+     */
+    @Nonnull public static AuthenticationStatement buildAuthenticationStatement() {
+        final SAMLObjectBuilder<AuthenticationStatement> statementBuilder = (SAMLObjectBuilder<AuthenticationStatement>)
+                XMLObjectProviderRegistrySupport.getBuilderFactory().<AuthenticationStatement>getBuilderOrThrow(
+                        AuthenticationStatement.DEFAULT_ELEMENT_NAME);
+
+        final AuthenticationStatement statement = statementBuilder.buildObject();
+        statement.setAuthenticationInstant(new DateTime(0));
+        statement.setAuthenticationMethod(AuthenticationStatement.PASSWORD_AUTHN_METHOD);
+
+        return statement;
+    }
+
+    /**
+     * Builds an empty attribute statement.
+     * 
+     * @return the constructed statement
+     */
+    @Nonnull public static AttributeStatement buildAttributeStatement() {
+        final SAMLObjectBuilder<AttributeStatement> statementBuilder = (SAMLObjectBuilder<AttributeStatement>)
+                XMLObjectProviderRegistrySupport.getBuilderFactory().<AttributeStatement>getBuilderOrThrow(
+                        AttributeStatement.DEFAULT_ELEMENT_NAME);
+
+        final AttributeStatement statement = statementBuilder.buildObject();
+
+        return statement;
+    }
+    
+    /**
      * Builds a {@link Subject}. If a principal name is given a {@link NameIdentifier}, whose value is the given
      * principal name, will be created and added to the {@link Subject}.
      * 
@@ -94,15 +129,15 @@
      * @return the built subject
      */

[... 263 lines stripped ...]


More information about the commits mailing list