[java-identity-provider COMMIT] /trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction....
noreply at shibboleth.net
noreply at shibboleth.net
Mon Aug 26 21:44:47 EDT 2013
Author: scantor
Date: Mon Aug 26 21:44:46 2013
New Revision: 4728
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4728&view=rev
Log:
Default to adding custom principals from underlying flow.
Modified:
trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java
Modified: trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java?rev=4728&r1=4727&r2=4728&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java (original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java Mon Aug 26 21:44:46 2013
@@ -60,6 +60,9 @@
/** Basis for {@link AuthenticationResult}. */
@Nonnull private final Subject authenticatedSubject;
+ /** Track whether custom principals have been explicitly set (including the empty set). */
+ private boolean principalsAdded;
+
/** Error messages indicating an unknown username. */
@Nonnull @NonnullElements private Collection<String> unknownUsernameErrors;
@@ -194,28 +197,11 @@
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
Constraint.isNotNull(principals, "Principal collection cannot be null.");
+ principalsAdded = true;
authenticatedSubject.getPrincipals().clear();
authenticatedSubject.getPrincipals().addAll(Collections2.filter(principals, Predicates.notNull()));
}
- /**
- * Copy the principals from the {@link AuthenticationFlowDescriptor#getSupportedPrincipals()} method
- * as the basis for the subjects generated by this action.
- *
- * <p>This is a shortcut method for handling the simple case in which all of the principals defined for a flow
- * apply to the action. More complex flows in which different validation steps may produce different principals
- * should explicitly define the appropriate subset to be generated by each action by using the other setter.</p>
- *
- * @param descriptor the flow descriptor to copy from
- */
- public void setSupportedPrincipals(@Nonnull AuthenticationFlowDescriptor descriptor) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- Constraint.isNotNull(descriptor, "Authentication flow descriptor cannot be null.");
-
- authenticatedSubject.getPrincipals().clear();
- authenticatedSubject.getPrincipals().addAll(descriptor.getSupportedPrincipals());
- }
-
/**
* Get the subject to be produced by successful execution of this action.
*
@@ -276,6 +262,12 @@
protected void buildAuthenticationResult(@Nonnull final ProfileRequestContext profileRequestContext,
@Nonnull final AuthenticationContext authenticationContext) throws AuthenticationException {
+ if (!principalsAdded && authenticationContext.getAttemptedFlow() != null) {
+ log.debug("{} Adding custom Principal(s) defined on underlying flow descriptor", getLogPrefix());
+ authenticatedSubject.getPrincipals().addAll(
+ authenticationContext.getAttemptedFlow().getSupportedPrincipals());
+ }
+
AuthenticationResult result = new AuthenticationResult(authenticationContext.getAttemptedFlow().getId(),
populateSubject(authenticatedSubject));
authenticationContext.setAuthenticationResult(result);
More information about the commits
mailing list