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

noreply at shibboleth.net noreply at shibboleth.net
Thu Feb 6 18:55:49 EST 2014


Author: tzeller
Date: Thu Feb  6 18:55:49 2014
New Revision: 5330

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5330&view=rev
Log:
IDP-129 : Initial implementation of SignAssertions action with test.

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

Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml1/SignAssertions.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml1/SignAssertions.java?rev=5330&r1=5329&r2=5330&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml1/SignAssertions.java (original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/saml1/SignAssertions.java Thu Feb  6 18:55:49 2014
@@ -17,28 +17,133 @@
 
 package net.shibboleth.idp.saml.impl.profile.saml1;
 
+import java.util.List;
+
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
 import net.shibboleth.idp.profile.AbstractProfileAction;
-import net.shibboleth.idp.profile.ActionSupport;
+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.saml1.core.Assertion;
 import org.opensaml.saml.saml1.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 {
+    @Override protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext)
+            throws ProfileException {
 
-        // TODO method stub
-        return ActionSupport.buildProceedEvent(this);
+        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());

[... 51 lines stripped ...]


More information about the commits mailing list