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

noreply at shibboleth.net noreply at shibboleth.net
Thu Aug 1 09:44:58 EDT 2013


Author: scantor
Date: Thu Aug  1 09:44:57 2013
New Revision: 4646

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4646&view=rev
Log:
Simplify subject handling in authn results.

Modified:
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult.java
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/SubjectContext.java
    trunk/idp-authn-api/src/test/java/net/shibboleth/idp/authn/AuthenticationResultTest.java
    trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUserAgentAddressTest.java

Modified: trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult.java?rev=4646&r1=4645&r2=4646&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult.java (original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult.java Thu Aug  1 09:44:57 2013
@@ -18,27 +18,21 @@
 package net.shibboleth.idp.authn;
 
 import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
-import java.util.List;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.ThreadSafe;
 import javax.security.auth.Subject;
 
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
-import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
 import org.joda.time.DateTime;
 
 import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 
 /**
@@ -48,8 +42,8 @@
 @ThreadSafe
 public final class AuthenticationResult {
 
-    /** The Subjects established by the authentication result. */
-    @Nonnull @NonnullElements @NotEmpty private final List<Subject> subjects;
+    /** The Subject established by the authentication result. */
+    @Nonnull private final Subject subject;
 
     /** The identifier of the flow used to produce this result. */
     @Nonnull @NotEmpty private final String authenticationFlowId;
@@ -61,29 +55,20 @@
     @Positive private long lastActivityInstant;
     
     /**
-     * Constructor. <p>Sets the authentication instant to the current time.</p>
+     * Constructor.
+     * 
+     * <p>Sets the authentication instant to the current time.</p>
      * 
      * @param flowId the workflow used to authenticate the subject
-     * @param newSubjects a Subject collection identifying the authenticated entity
+     * @param newSubject a Subject identifying the authenticated entity
      */
-    public AuthenticationResult(@Nonnull @NotEmpty final String flowId,
-            @Nonnull @NotEmpty @NonnullElements final Collection<Subject> newSubjects) {
+    public AuthenticationResult(@Nonnull @NotEmpty final String flowId, @Nonnull final Subject newSubject) {
 
         authenticationFlowId = Constraint.isNotNull(StringSupport.trimOrNull(flowId),
                 "Authentication flow ID cannot be null nor empty");
-        subjects = new ArrayList(Constraint.isNotEmpty(newSubjects, "Subject list cannot be null or empty"));
+        subject = Constraint.isNotNull(newSubject, "Subject list cannot be null or empty");
         authenticationInstant = System.currentTimeMillis();
         lastActivityInstant = authenticationInstant;
-    }
-
-    /**
-     * Constructor. <p>Sets the authentication instant to the current time.</p>
-     * 
-     * @param flowId the workflow used to authenticate the subject
-     * @param subject a Subject identifying the authenticated entity
-     */
-    public AuthenticationResult(@Nonnull @NotEmpty final String flowId, @Nonnull final Subject subject) {
-        this(flowId, ImmutableList.of(Constraint.isNotNull(subject, "Subject cannot be null")));
     }
 
     /**
@@ -93,9 +78,8 @@
      * @param principal a Principal identifying the authenticated entity
      */
     public AuthenticationResult(@Nonnull @NotEmpty final String flowId, @Nonnull final Principal principal) {
-        this(flowId, ImmutableList.of(
-                new Subject(false, ImmutableSet.of(Constraint.isNotNull(principal, "Principal cannot be null")),
-                        Collections.EMPTY_SET, Collections.EMPTY_SET)));
+        this(flowId, new Subject(false, ImmutableSet.of(Constraint.isNotNull(principal, "Principal cannot be null")),
+                Collections.EMPTY_SET, Collections.EMPTY_SET));
     }
     
     /**
@@ -103,8 +87,8 @@
      * 
      * @return a Subject collection
      */

[... 68 lines stripped ...]


More information about the commits mailing list