[java-identity-provider COMMIT] in /trunk/idp-saml-impl/src: main/java/net/shibboleth/idp/saml/impl/profile/saml1/Add...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Jan 9 14:30:47 EST 2014
Author: scantor
Date: Thu Jan 9 14:30:47 2014
New Revision: 5171
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5171&view=rev
Log:
Forgot to honor matchingPrincipal property on RequestedPrincipalContext
Modified:
trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml1/AddAuthenticationStatementToAssertion.java
trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/impl/profile/saml1/AddAuthenticationStatementToAssertionTest.java
Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml1/AddAuthenticationStatementToAssertion.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml1/AddAuthenticationStatementToAssertion.java?rev=5171&r1=5170&r2=5171&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml1/AddAuthenticationStatementToAssertion.java (original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml1/AddAuthenticationStatementToAssertion.java Thu Jan 9 14:30:47 2014
@@ -25,6 +25,7 @@
import net.shibboleth.idp.authn.AuthenticationResult;
import net.shibboleth.idp.authn.AuthnEventIds;
import net.shibboleth.idp.authn.context.AuthenticationContext;
+import net.shibboleth.idp.authn.context.RequestedPrincipalContext;
import net.shibboleth.idp.authn.principal.DefaultPrincipalDeterminationStrategy;
import net.shibboleth.idp.profile.IdPEventIds;
@@ -66,8 +67,8 @@
*
* <p>The {@link AuthenticationStatement} will have its authentication instant set, based on
* {@link AuthenticationResult#getAuthenticationInstant()} via {@link AuthenticationContext#getAuthenticationResult()}.
- * The method property will be set via an injected or defaulted function that obtains an
- * {@link AuthenticationMethodPrincipal} from the profile context.</p>
+ * The method property will be set via {@link RequestedPrincipalContext#getMatchingPrincipal()}, or via an injected
+ * or defaulted function that obtains an {@link AuthenticationMethodPrincipal} from the profile context.</p>
*
* @event {@link EventIds#PROCEED_EVENT_ID}
* @event {@link EventIds#INVALID_MSG_CTX}
@@ -206,7 +207,9 @@
@Nonnull final AuthenticationContext authenticationContext) throws AuthenticationException {
final Assertion assertion = getStatementAssertion();
- assertion.getAuthenticationStatements().add(buildAuthenticationStatement(profileRequestContext));
+ final AuthenticationStatement statement = buildAuthenticationStatement(profileRequestContext,
+ authenticationContext.getSubcontext(RequestedPrincipalContext.class, false));
+ assertion.getAuthenticationStatements().add(statement);
log.debug("{} Added AuthenticationStatement to assertion {}", getLogPrefix(), assertion.getID());
}
@@ -228,11 +231,13 @@
* Build the {@link AuthenticationStatement} to be added to the {@link Response}.
*
* @param profileRequestContext current request context
+ * @param requestedPrincipalContext context specifying request requirements for authn method
*
* @return the authentication statement
*/
@Nonnull private AuthenticationStatement buildAuthenticationStatement(
- @Nonnull final ProfileRequestContext profileRequestContext) {
+ @Nonnull final ProfileRequestContext profileRequestContext,
+ @Nullable final RequestedPrincipalContext requestedPrincipalContext) {
final SAMLObjectBuilder<AuthenticationStatement> statementBuilder = (SAMLObjectBuilder<AuthenticationStatement>)
XMLObjectProviderRegistrySupport.getBuilderFactory().<AuthenticationStatement>getBuilderOrThrow(
@@ -240,7 +245,12 @@
final AuthenticationStatement statement = statementBuilder.buildObject();
statement.setAuthenticationInstant(new DateTime(authenticationResult.getAuthenticationInstant()));
- statement.setAuthenticationMethod(methodLookupStrategy.apply(profileRequestContext).getName());
+
+ if (requestedPrincipalContext != null && requestedPrincipalContext.getMatchingPrincipal() != null) {
+ statement.setAuthenticationMethod(requestedPrincipalContext.getMatchingPrincipal().getName());
+ } else {
+ statement.setAuthenticationMethod(methodLookupStrategy.apply(profileRequestContext).getName());
+ }
return statement;
}
Modified: trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/impl/profile/saml1/AddAuthenticationStatementToAssertionTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/impl/profile/saml1/AddAuthenticationStatementToAssertionTest.java?rev=5171&r1=5170&r2=5171&view=diff
==============================================================================
[... 125 lines stripped ...]
More information about the commits
mailing list