[java-identity-provider COMMIT] in /trunk: idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/session/SAML2SPSe...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Mar 6 21:33:37 EST 2014
Author: scantor
Date: Thu Mar 6 21:33:37 2014
New Revision: 5538
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5538&view=rev
Log:
Revise session creation to bypass BasicMessageMetadataContext.
Modified:
trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/session/SAML2SPSessionCreationStrategy.java
trunk/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/BasicSPSessionCreationStrategy.java
Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/session/SAML2SPSessionCreationStrategy.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/session/SAML2SPSessionCreationStrategy.java?rev=5538&r1=5537&r2=5538&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/session/SAML2SPSessionCreationStrategy.java (original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/session/SAML2SPSessionCreationStrategy.java Thu Mar 6 21:33:37 2014
@@ -21,7 +21,7 @@
import javax.annotation.Nullable;
import org.joda.time.DateTime;
-import org.opensaml.messaging.context.BasicMessageMetadataContext;
+import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.messaging.context.navigate.MessageLookup;
import org.opensaml.profile.context.ProfileRequestContext;
import org.opensaml.profile.context.navigate.OutboundMessageContextLookup;
@@ -32,6 +32,7 @@
import org.slf4j.LoggerFactory;
import net.shibboleth.idp.authn.context.AuthenticationContext;
+import net.shibboleth.idp.profile.context.RelyingPartyContext;
import net.shibboleth.idp.saml.session.SAML2SPSession;
import net.shibboleth.idp.session.BasicSPSession;
import net.shibboleth.idp.session.SPSession;
@@ -64,6 +65,9 @@
/** Lifetime of sessions to create. */
@Positive @Duration private final long sessionLifetime;
+ /** RelyingPartyContext lookup strategy. */
+ @Nonnull private Function<ProfileRequestContext,RelyingPartyContext> relyingPartyContextLookupStrategy;
+
/** Response lookup strategy. */
@Nonnull private Function<ProfileRequestContext, Response> responseLookupStrategy;
@@ -75,23 +79,44 @@
*/
public SAML2SPSessionCreationStrategy(@Positive @Duration final long lifetime) {
sessionLifetime = Constraint.isGreaterThan(0, lifetime, "Lifetime must be greater than 0");
+ relyingPartyContextLookupStrategy = new ChildContextLookup<>(RelyingPartyContext.class);
responseLookupStrategy =
Functions.compose(new MessageLookup<>(Response.class), new OutboundMessageContextLookup());
}
+ /**
+ * Set the strategy used to locate the {@link RelyingPartyContext} to operate on.
+ *
+ * @param strategy lookup strategy
+ */
+ public void setRelyingPartyContextLookupStrategy(
+ @Nonnull final Function<ProfileRequestContext,RelyingPartyContext> strategy) {
+ relyingPartyContextLookupStrategy = Constraint.isNotNull(strategy,
+ "RelyingPartyContext lookup strategy cannot be null");
+ }
+
+ /**
+ * Set the strategy used to locate the {@link Response} to operate on.
+ *
+ * @param strategy strategy used to locate the {@link Response} to operate on
+ */
+ public void setResponseLookupStrategy(@Nonnull final Function<ProfileRequestContext, Response> strategy) {
+ responseLookupStrategy = Constraint.isNotNull(strategy, "Response lookup strategy cannot be null");
+ }
+
/** {@inheritDoc} */
@Override
@Nullable public SPSession apply(@Nullable final ProfileRequestContext input) {
- if (input == null || input.getInboundMessageContext() == null) {
- log.debug("No inbound MessageContext, no SAML2SPSession created");
+ final RelyingPartyContext rpCtx = relyingPartyContextLookupStrategy.apply(input);
+ if (rpCtx == null) {
+ log.debug("No RelyingPartyContext, no SAML2SPSession created");
return null;
}
- final BasicMessageMetadataContext mdCtx =
- input.getInboundMessageContext().getSubcontext(BasicMessageMetadataContext.class, false);
- if (mdCtx == null || mdCtx.getMessageIssuer() == null) {
- log.debug("No message issuer found in inbound BasicMessageMetadataContext, no SAML2SPSession created");
+ final String issuer = rpCtx.getRelyingPartyId();
+ if (issuer == null) {
+ log.debug("No relying party ID, no SAML2SPSession created");
return null;
}
@@ -105,8 +130,8 @@
if (result == null) {
log.info("Creating BasicSPSession in the absence of necessary information");
final long now = System.currentTimeMillis();
- return new BasicSPSession(mdCtx.getMessageIssuer(),
- authCtx.getAuthenticationResult().getAuthenticationFlowId(), now, now + sessionLifetime);
[... 95 lines stripped ...]
More information about the commits
mailing list