[java-identity-provider COMMIT] in /trunk/idp-saml-impl/src: main/java/net/shibboleth/idp/saml/impl/profile/saml2/Sig...

noreply at shibboleth.net noreply at shibboleth.net
Thu Feb 6 19:59:07 EST 2014


Author: tzeller
Date: Thu Feb  6 19:59:07 2014
New Revision: 5334

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5334&view=rev
Log:
IDP-130 : Ported SignAssertions action and test from SAML 1 to SAML 2.

Added:
    trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/impl/profile/saml2/SignAssertionsTest.java   (with props)
Modified:
    trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml2/SignAssertions.java

Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml2/SignAssertions.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml2/SignAssertions.java?rev=5334&r1=5333&r2=5334&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml2/SignAssertions.java (original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml2/SignAssertions.java Thu Feb  6 19:59:07 2014
@@ -17,26 +17,133 @@
 
 package net.shibboleth.idp.saml.impl.profile.saml2;
 
+import java.util.List;
+
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
 import net.shibboleth.idp.profile.AbstractProfileAction;
+import net.shibboleth.idp.saml.profile.SAMLEventIds;
+import net.shibboleth.utilities.java.support.xml.SerializeSupport;
+
+import org.opensaml.core.xml.io.MarshallingException;
+import org.opensaml.core.xml.util.XMLObjectSupport;
+import org.opensaml.messaging.context.MessageContext;
 import org.opensaml.profile.ProfileException;
+import org.opensaml.profile.action.ActionSupport;
+import org.opensaml.profile.action.EventIds;
 import org.opensaml.profile.context.ProfileRequestContext;
-
+import org.opensaml.saml.saml2.core.Assertion;
 import org.opensaml.saml.saml2.core.Response;
-import org.springframework.webflow.execution.Event;
-import org.springframework.webflow.execution.RequestContext;
+import org.opensaml.security.SecurityException;
+import org.opensaml.xmlsec.SignatureSigningParameters;
+import org.opensaml.xmlsec.context.SecurityParametersContext;
+import org.opensaml.xmlsec.signature.support.SignatureException;
+import org.opensaml.xmlsec.signature.support.SignatureSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
 
 /**
- *
+ * Action that signs {@link Assertion}s in a {@link Response}.
+ * 
+ * @event {@link EventIds#PROCEED_EVENT_ID}
+ * @event {@link EventIds#INVALID_MSG_CTX}
+ * @event {@link SAMLEventIds.NO_RESPONSE}
+ * @event {@link SAMLEventIds.NO_ASSERTION}
  */
-public class SignAssertions extends AbstractProfileAction<Object, Response> {
+// TODO Complete Javadoc
+public class SignAssertions extends AbstractProfileAction {
+
+    /** Class logger. */
+    private final Logger log = LoggerFactory.getLogger(SignAssertions.class);
+
+    /** The signature signing parameters. */
+    @Nullable private SignatureSigningParameters signatureSigningParameters;
+
+    /** The assertions to be signed. */
+    @Nullable private List<Assertion> assertions;
 
     /** {@inheritDoc} */
-    protected Event doExecute(@Nonnull final RequestContext springRequestContext,
-            @Nonnull final ProfileRequestContext<Object, Response> profileRequestContext) throws ProfileException {
-        // TODO Auto-generated method stub
-        return null;
+    @Override protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext)
+            throws ProfileException {
+
+        final MessageContext<Response> outboundMsgCtx = profileRequestContext.getOutboundMessageContext();
+        if (outboundMsgCtx == null) {
+            log.debug("{} No outbound message context available", getId());
+            ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
+            return false;
+        }
+
+        final SecurityParametersContext secParamCtx = outboundMsgCtx.getSubcontext(SecurityParametersContext.class);
+        if (secParamCtx == null) {
+            log.debug("{} Will not sign assertions because no security parameters context is available", getId());
+            return false;
+        }
+
+        signatureSigningParameters = secParamCtx.getSignatureSigningParameters();
+        if (signatureSigningParameters == null) {
+            log.debug("{} Will not sign assertions because no signature signing parameters available", getId());
+            return false;
+        }
+
+        final Response response = outboundMsgCtx.getMessage();
+        if (response == null) {
+            log.debug("{} No response available", getId());
+            ActionSupport.buildEvent(profileRequestContext, SAMLEventIds.NO_RESPONSE);
+            return false;
+        }
+
+        assertions = response.getAssertions();
+        if (assertions == null || assertions.isEmpty()) {
+            log.debug("{} No assertions available", getLogPrefix());
+            ActionSupport.buildEvent(profileRequestContext, SAMLEventIds.NO_ASSERTION);

[... 51 lines stripped ...]


More information about the commits mailing list