Author: anil.saldhana(a)jboss.com
Date: 2009-11-13 11:41:37 -0500 (Fri, 13 Nov 2009)
New Revision: 941
Added:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2SignatureGenerationHandler.java
Removed:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2SignatureHandler.java
Modified:
identity-federation/trunk/jboss-identity-web/src/test/java/org/jboss/test/identity/federation/web/saml/handlers/SAML2SignatureHandlerUnitTestCase.java
Log:
bring in saml sig gen handler
Added:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2SignatureGenerationHandler.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2SignatureGenerationHandler.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2SignatureGenerationHandler.java 2009-11-13
16:41:37 UTC (rev 941)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.identity.federation.web.handlers.saml2;
+
+import java.security.KeyPair;
+
+import org.apache.log4j.Logger;
+import org.jboss.identity.federation.api.saml.v2.sig.SAML2Signature;
+import org.jboss.identity.federation.core.exceptions.ProcessingException;
+import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerRequest;
+import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerResponse;
+import org.jboss.identity.federation.web.constants.GeneralConstants;
+import org.w3c.dom.Document;
+
+/**
+ * Handles SAML2 Signature
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 12, 2009
+ */
+public class SAML2SignatureGenerationHandler extends BaseSAML2Handler
+{
+ private static Logger log = Logger.getLogger(SAML2SignatureGenerationHandler.class);
+ private boolean trace = log.isTraceEnabled();
+
+ @Override
+ public void generateSAMLRequest(SAML2HandlerRequest request, SAML2HandlerResponse
response)
+ throws ProcessingException
+ {
+ //Generate the signature
+ Document samlDocument = response.getResultingDocument();
+
+ if(samlDocument == null && trace)
+ {
+ log.trace("No document generated in the handler chain. Cannot generate
signature");
+ return;
+ }
+
+ //Get the Key Pair
+ KeyPair keypair = (KeyPair)
this.handlerChainConfig.getParameter(GeneralConstants.KEYPAIR);
+
+ if(keypair == null)
+ {
+ log.error("Key Pair cannot be found");
+ throw new ProcessingException("KeyPair not found");
+ }
+
+ SAML2Signature samlSignature = new SAML2Signature();
+ //Get the ID from the root
+ String id = samlDocument.getDocumentElement().getAttribute("ID");
+
+ try
+ {
+ samlSignature.sign(samlDocument, id, keypair);
+ }
+ catch (Exception e)
+ {
+ log.error("Unable to sign:",e);
+ throw new ProcessingException("Unable to sign");
+ }
+ }
+
+ public void handleRequestType(SAML2HandlerRequest request, SAML2HandlerResponse
response) throws ProcessingException
+ {
+ //Nothing to do
+ }
+}
\ No newline at end of file
Deleted:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2SignatureHandler.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2SignatureHandler.java 2009-11-13
16:33:59 UTC (rev 940)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2SignatureHandler.java 2009-11-13
16:41:37 UTC (rev 941)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.identity.federation.web.handlers.saml2;
-
-import java.security.KeyPair;
-
-import org.apache.log4j.Logger;
-import org.jboss.identity.federation.api.saml.v2.sig.SAML2Signature;
-import org.jboss.identity.federation.core.exceptions.ProcessingException;
-import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerRequest;
-import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerResponse;
-import org.jboss.identity.federation.web.constants.GeneralConstants;
-import org.w3c.dom.Document;
-
-/**
- * Handles SAML2 Signature
- * @author Anil.Saldhana(a)redhat.com
- * @since Oct 12, 2009
- */
-public class SAML2SignatureHandler extends BaseSAML2Handler
-{
- private static Logger log = Logger.getLogger(SAML2SignatureHandler.class);
- private boolean trace = log.isTraceEnabled();
-
- @Override
- public void generateSAMLRequest(SAML2HandlerRequest request, SAML2HandlerResponse
response)
- throws ProcessingException
- {
- //Generate the signature
- Document samlDocument = response.getResultingDocument();
-
- if(samlDocument == null && trace)
- {
- log.trace("No document generated in the handler chain. Cannot generate
signature");
- return;
- }
-
- //Get the Key Pair
- KeyPair keypair = (KeyPair)
this.handlerChainConfig.getParameter(GeneralConstants.KEYPAIR);
-
- if(keypair == null)
- {
- log.error("Key Pair cannot be found");
- throw new ProcessingException("KeyPair not found");
- }
-
- SAML2Signature samlSignature = new SAML2Signature();
- //Get the ID from the root
- String id = samlDocument.getDocumentElement().getAttribute("ID");
-
- try
- {
- samlSignature.sign(samlDocument, id, keypair);
- }
- catch (Exception e)
- {
- log.error("Unable to sign:",e);
- throw new ProcessingException("Unable to sign");
- }
- }
-
- public void handleRequestType(SAML2HandlerRequest request, SAML2HandlerResponse
response) throws ProcessingException
- {
- //Nothing to do
- }
-}
\ No newline at end of file
Modified:
identity-federation/trunk/jboss-identity-web/src/test/java/org/jboss/test/identity/federation/web/saml/handlers/SAML2SignatureHandlerUnitTestCase.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/test/java/org/jboss/test/identity/federation/web/saml/handlers/SAML2SignatureHandlerUnitTestCase.java 2009-11-13
16:33:59 UTC (rev 940)
+++
identity-federation/trunk/jboss-identity-web/src/test/java/org/jboss/test/identity/federation/web/saml/handlers/SAML2SignatureHandlerUnitTestCase.java 2009-11-13
16:41:37 UTC (rev 941)
@@ -47,7 +47,7 @@
import org.jboss.identity.federation.web.constants.GeneralConstants;
import org.jboss.identity.federation.web.core.HTTPContext;
import org.jboss.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler;
-import org.jboss.identity.federation.web.handlers.saml2.SAML2SignatureHandler;
+import org.jboss.identity.federation.web.handlers.saml2.SAML2SignatureGenerationHandler;
import org.jboss.test.identity.federation.web.mock.MockHttpServletRequest;
import org.jboss.test.identity.federation.web.mock.MockHttpServletResponse;
import org.jboss.test.identity.federation.web.mock.MockHttpSession;
@@ -76,7 +76,7 @@
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
KeyPair keypair = kpg.genKeyPair();
- SAML2SignatureHandler handler = new SAML2SignatureHandler();
+ SAML2SignatureGenerationHandler handler = new SAML2SignatureGenerationHandler();
SAML2HandlerChainConfig chainConfig = new DefaultSAML2HandlerChainConfig();
SAML2HandlerConfig handlerConfig = new DefaultSAML2HandlerConfig();