[java-opensaml COMMIT] /trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/impl/SAMLAddAttribute...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Sep 25 19:50:23 EDT 2014
Author: scantor
Date: Thu Sep 25 19:50:23 2014
New Revision: 4077
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4077&view=rev
Log:
Implement a lookup strategy for the ACS index.
Modified:
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/impl/SAMLAddAttributeConsumingServiceHandler.java
Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/impl/SAMLAddAttributeConsumingServiceHandler.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/impl/SAMLAddAttributeConsumingServiceHandler.java?rev=4077&r1=4076&r2=4077&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/impl/SAMLAddAttributeConsumingServiceHandler.java (original)
+++ trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/impl/SAMLAddAttributeConsumingServiceHandler.java Thu Sep 25 19:50:23 2014
@@ -47,45 +47,56 @@
/** Logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(SAMLAddAttributeConsumingServiceHandler.class);
- /** How to get the {@link SAMLMetadataContext} from the message. */
- @Nonnull private Function<MessageContext,SAMLMetadataContext> metadataContextStrategy;
+ /** Lookup strategy for {@link SAMLMetadataContext}. */
+ @Nonnull private Function<MessageContext,SAMLMetadataContext> metadataContextLookupStrategy;
+
+ /** Lookup strategy for an {@link AttributeConsumingService} index. */
+ @Nullable private Function<MessageContext,Integer> indexLookupStrategy;
+
+ /** {@link AttributeConsumingService} index. */
+ @Nullable private Integer index;
- /** Request to read from. */
- @Nullable private AuthnRequest authnRequest;
-
/**
* Constructor.
*/
public SAMLAddAttributeConsumingServiceHandler() {
- metadataContextStrategy =
+ metadataContextLookupStrategy =
Functions.compose(
new ChildContextLookup<SAMLPeerEntityContext,SAMLMetadataContext>(SAMLMetadataContext.class),
new ChildContextLookup<MessageContext,SAMLPeerEntityContext>(SAMLPeerEntityContext.class));
+ indexLookupStrategy = new AuthnRequestIndexLookup();
}
/**
- * Get the strategy which find the {@link SAMLMetadataContext} from the message.
+ * Set the strategy to locate the {@link SAMLMetadataContext} from the {@link MessageContext}.
*
- * @return Returns strategy.
+ * @param strategy lookup strategy
*/
- @Nonnull public Function<MessageContext,SAMLMetadataContext> getMetadataContextStrategy() {
- return metadataContextStrategy;
+ public void setMetadataContextLookupStrategy(@Nonnull final Function<MessageContext,SAMLMetadataContext> strategy) {
+ metadataContextLookupStrategy = Constraint.isNotNull(strategy,
+ "SAMLMetadataContext lookup strategy cannot be null");
}
/**
- * Set the strategy which find the {@link SAMLMetadataContext} from the message.
+ * Set the strategy to locate the {@link AttributeConsumingService} index from the {@link MessageContext}.
*
- * @param strategy what to set
+ * @param strategy lookup strategy
*/
- public void setMetadataContextStrategy(@Nonnull final Function<MessageContext,SAMLMetadataContext> strategy) {
- metadataContextStrategy = Constraint.isNotNull(strategy, "Metadata Strategy cannot be null");
+ public void setIndexLookupStrategy(@Nullable final Function<MessageContext,Integer> strategy) {
+ indexLookupStrategy = Constraint.isNotNull(strategy,
+ "AttributeConsumingService index lookup strategy cannot be null");
}
/** {@inheritDoc} */
- @Override protected boolean doPreInvoke(@Nonnull final MessageContext messageContext) {
- final Object message = messageContext.getMessage();
- if (message instanceof AuthnRequest) {
- authnRequest = (AuthnRequest) message;
+ @Override
+ protected boolean doPreInvoke(@Nonnull final MessageContext messageContext) throws MessageHandlerException {
+
+ if (!super.doPreInvoke(messageContext)) {
+ return false;
+ }
+
+ if (indexLookupStrategy != null) {
+ indexLookupStrategy.apply(messageContext);
}
return true;
@@ -93,7 +104,7 @@
/** {@inheritDoc}*/
@Override protected void doInvoke(@Nonnull final MessageContext messageContext) throws MessageHandlerException {
- final SAMLMetadataContext metadataContext = metadataContextStrategy.apply(messageContext);
+ final SAMLMetadataContext metadataContext = metadataContextLookupStrategy.apply(messageContext);
if (metadataContext == null) {
log.debug("{} No metadata context found, nothing to do", getLogPrefix());
return;
[... 45 lines stripped ...]
More information about the commits
mailing list