Following commit break the build with compilation error, it seems you
haven't commit new class called SignKeyDataHolder. Please look into this
issue.

Compilation failure:
[ERROR]
/home/sagara/dev/code/wso2/trunk/carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/Util.java:[66,71]
cannot find symbol
[ERROR] symbol  : class SignKeyDataHolder
[ERROR] location: package
org.wso2.carbon.identity.authenticator.saml2.sso.common.builders


Thanks !

---------- Forwarded message ----------
From: <[email protected]>
Date: Thu, Oct 4, 2012 at 1:47 PM
Subject: [Commits] [Carbon-platform] svn commit r144866 - in
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common:
. builders
To: [email protected]


Author: suresh
Date: Thu Oct  4 13:47:19 2012
New Revision: 144866
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=144866

Log:
committing saml signing code

Modified:

 
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/Util.java

 
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/builders/AuthenticationRequestBuilder.java

 
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/builders/LogoutRequestBuilder.java

Modified:
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/Util.java
URL:
http://wso2.org/svn/browse/wso2/carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/Util.java?rev=144866&r1=144865&r2=144866&view=diff
==============================================================================
---
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/Util.java
     (original)
+++
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/Util.java
     Thu Oct  4 13:47:19 2012
@@ -17,12 +17,31 @@
 */
 package org.wso2.carbon.identity.authenticator.saml2.sso.common;

+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.cert.CertificateEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.zip.DataFormatException;
+import java.util.zip.Deflater;
+import java.util.zip.DeflaterOutputStream;
+import java.util.zip.Inflater;
+import java.util.zip.InflaterInputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.xml.security.c14n.Canonicalizer;
 import org.opensaml.Configuration;
 import org.opensaml.DefaultBootstrap;
-import org.opensaml.saml2.core.Response;
+import org.opensaml.saml2.core.AuthnRequest;
+import org.opensaml.saml2.core.LogoutRequest;
 import org.opensaml.xml.ConfigurationException;
 import org.opensaml.xml.XMLObject;
 import org.opensaml.xml.XMLObjectBuilder;
@@ -44,23 +63,7 @@
 import org.w3c.dom.ls.LSOutput;
 import org.w3c.dom.ls.LSSerializer;
 import org.wso2.carbon.core.security.AuthenticatorsConfiguration;
-
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.security.cert.CertificateEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.zip.DataFormatException;
-import java.util.zip.Deflater;
-import java.util.zip.DeflaterOutputStream;
-import java.util.zip.Inflater;
-import java.util.zip.InflaterInputStream;
+import
org.wso2.carbon.identity.authenticator.saml2.sso.common.builders.SignKeyDataHolder;

 /**
  * This class contains all the utility methods required by SAML2 SSO
Authenticator module.
@@ -217,62 +220,116 @@
         }
     }

-    public static Response setSignature(Response response, String
signatureAlgorithm,
-                                        X509Credential cred)
-            throws SAML2SSOUIAuthenticatorException {
-        doBootstrap();
-        try {
-            Signature signature = (Signature)
buildXMLObject(Signature.DEFAULT_ELEMENT_NAME);
-            signature.setSigningCredential(cred);
-            signature.setSignatureAlgorithm(signatureAlgorithm);
-
 
signature.setCanonicalizationAlgorithm(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
-
-            try {
-                KeyInfo keyInfo = (KeyInfo)
buildXMLObject(KeyInfo.DEFAULT_ELEMENT_NAME);
-                X509Data data = (X509Data)
buildXMLObject(X509Data.DEFAULT_ELEMENT_NAME);
-                X509Certificate cert = (X509Certificate)
buildXMLObject(X509Certificate.DEFAULT_ELEMENT_NAME);
-                String value =
org.apache.xml.security.utils.Base64.encode(cred.getEntityCertificate().getEncoded());
-                cert.setValue(value);
-                data.getX509Certificates().add(cert);
-                keyInfo.getX509Datas().add(data);
-                signature.setKeyInfo(keyInfo);
-            } catch (CertificateEncodingException e) {
-                throw new
SAML2SSOUIAuthenticatorException("errorGettingCert");
-            }
-
-            response.setSignature(signature);
-
-            List<Signature> signatureList = new ArrayList<Signature>();
-            signatureList.add(signature);
-
-            //Marshall and Sign
-            MarshallerFactory marshallerFactory =
org.opensaml.xml.Configuration.getMarshallerFactory();
-            Marshaller marshaller =
marshallerFactory.getMarshaller(response);
-
-            marshaller.marshall(response);
-
-            org.apache.xml.security.Init.init();
-            Signer.signObjects(signatureList);
-            return response;
-
-        } catch (Exception e) {
-            throw new SAML2SSOUIAuthenticatorException("Error When signing
the assertion.", e);
-        }
-    }
+       public static AuthnRequest setSignature(AuthnRequest authnRequest,
String signatureAlgorithm,
+                                               X509Credential cred)
+                                                                   throws
Exception {
+               log.debug("Signing the AuthnRequest");
+               doBootstrap();
+               try {
+                       Signature signature = (Signature)
buildXMLObject(Signature.DEFAULT_ELEMENT_NAME);
+                       signature.setSigningCredential(cred);
+                       signature.setSignatureAlgorithm(signatureAlgorithm);
+
signature.setCanonicalizationAlgorithm(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
+
+                       try {
+                               KeyInfo keyInfo = (KeyInfo)
buildXMLObject(KeyInfo.DEFAULT_ELEMENT_NAME);
+                               X509Data data = (X509Data)
buildXMLObject(X509Data.DEFAULT_ELEMENT_NAME);
+                               X509Certificate cert =
+                                                      (X509Certificate)
buildXMLObject(X509Certificate.DEFAULT_ELEMENT_NAME);
+                               String value =
+
 org.apache.xml.security.utils.Base64.encode(cred.getEntityCertificate()
+
                   .getEncoded());
+                               cert.setValue(value);
+                               data.getX509Certificates().add(cert);
+                               keyInfo.getX509Datas().add(data);
+                               signature.setKeyInfo(keyInfo);
+                       } catch (CertificateEncodingException e) {
+                               throw new
SAML2SSOUIAuthenticatorException("errorGettingCert");
+                       }
+
+                       authnRequest.setSignature(signature);
+
+                       List<Signature> signatureList = new
ArrayList<Signature>();
+                       signatureList.add(signature);
+
+                       // Marshall and Sign
+                       MarshallerFactory marshallerFactory =
+
org.opensaml.xml.Configuration.getMarshallerFactory();
+                       Marshaller marshaller =
marshallerFactory.getMarshaller(authnRequest);
+
+                       marshaller.marshall(authnRequest);
+
+                       org.apache.xml.security.Init.init();
+                       Signer.signObjects(signatureList);
+                       return authnRequest;
+
+               } catch (Exception e) {
+                       throw new Exception("Error While signing the
assertion.", e);
+               }
+       }
+
+       public static LogoutRequest setSignature(LogoutRequest logoutReq,
String signatureAlgorithm,
+                                                SignKeyDataHolder cred)
+
throws Exception {
+               log.debug("Signing the AuthnRequest");
+               doBootstrap();
+               try {
+                       Signature signature = (Signature)
buildXMLObject(Signature.DEFAULT_ELEMENT_NAME);
+                       signature.setSigningCredential(cred);
+                       signature.setSignatureAlgorithm(signatureAlgorithm);
+
signature.setCanonicalizationAlgorithm(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
+
+                       try {
+                               KeyInfo keyInfo = (KeyInfo)
buildXMLObject(KeyInfo.DEFAULT_ELEMENT_NAME);
+                               X509Data data = (X509Data)
buildXMLObject(X509Data.DEFAULT_ELEMENT_NAME);
+                               X509Certificate cert =
+                                                      (X509Certificate)
buildXMLObject(X509Certificate.DEFAULT_ELEMENT_NAME);
+                               String value =
+
 org.apache.xml.security.utils.Base64.encode(cred.getEntityCertificate()
+
                   .getEncoded());
+                               cert.setValue(value);
+                               data.getX509Certificates().add(cert);
+                               keyInfo.getX509Datas().add(data);
+                               signature.setKeyInfo(keyInfo);
+                       } catch (CertificateEncodingException e) {
+                               throw new Exception("errorGettingCert");
+                       }
+
+                       logoutReq.setSignature(signature);
+
+                       List<Signature> signatureList = new
ArrayList<Signature>();
+                       signatureList.add(signature);
+
+                       // Marshall and Sign
+                       MarshallerFactory marshallerFactory =
+
org.opensaml.xml.Configuration.getMarshallerFactory();
+                       Marshaller marshaller =
marshallerFactory.getMarshaller(logoutReq);
+
+                       marshaller.marshall(logoutReq);
+
+                       org.apache.xml.security.Init.init();
+                       Signer.signObjects(signatureList);
+                       return logoutReq;
+
+               } catch (Exception e) {
+                       throw new Exception("Error While signing the
assertion.", e);
+               }
+       }
+

     public static XMLObject buildXMLObject(QName objectQName)
-            throws SAML2SSOUIAuthenticatorException {
+            throws Exception {

         XMLObjectBuilder builder =
org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName);
         if (builder == null) {
-            throw new SAML2SSOUIAuthenticatorException("Unable to retrieve
builder for object QName "
+            throw new Exception("Unable to retrieve builder for object
QName "
                                                      + objectQName);
         }
         return builder.buildObject(objectQName.getNamespaceURI(),
objectQName.getLocalPart(),
                                    objectQName.getPrefix());
     }

-
+
     /**
      * Generates a unique Id for Authentication Requests
      *

Modified:
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/builders/AuthenticationRequestBuilder.java
URL:
http://wso2.org/svn/browse/wso2/carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/builders/AuthenticationRequestBuilder.java?rev=144866&r1=144865&r2=144866&view=diff
==============================================================================
---
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/builders/AuthenticationRequestBuilder.java
    (original)
+++
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/builders/AuthenticationRequestBuilder.java
    Thu Oct  4 13:47:19 2012
@@ -19,6 +19,7 @@

 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.xml.security.signature.XMLSignature;
 import org.joda.time.DateTime;
 import org.opensaml.common.SAMLVersion;
 import org.opensaml.saml1.core.NameIdentifier;
@@ -50,7 +51,8 @@
      * @return AuthnRequest Object
      * @throws
org.wso2.carbon.identity.authenticator.saml2.sso.ui.SAML2SSOUIAuthenticatorException
error when bootstrapping
      */
-    public AuthnRequest buildAuthenticationRequest(String subjectName)
throws SAML2SSOUIAuthenticatorException {
+    public AuthnRequest buildAuthenticationRequest(String subjectName)
throws Exception {
+       log.info("Building Authentication Request");
         Util.doBootstrap();
         AuthnRequest authnRequest =
(AuthnRequest)Util.buildXMLObject(AuthnRequest.DEFAULT_ELEMENT_NAME);
         authnRequest.setID(Util.createID());
@@ -58,6 +60,7 @@
         authnRequest.setIssueInstant(new DateTime());
         authnRequest.setIssuer(buildIssuer());
         authnRequest.setNameIDPolicy(buildNameIDPolicy());
+
         if (subjectName != null) {
             Subject subject = new SubjectBuilder().buildObject();
             NameID nameId = new NameIDBuilder().buildObject();
@@ -67,6 +70,9 @@
             authnRequest.setSubject(subject);

         }
+
+        Util.setSignature(authnRequest,
XMLSignature.ALGO_ID_SIGNATURE_RSA, new SignKeyDataHolder());
+
         return authnRequest;
     }


Modified:
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/builders/LogoutRequestBuilder.java
URL:
http://wso2.org/svn/browse/wso2/carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/builders/LogoutRequestBuilder.java?rev=144866&r1=144865&r2=144866&view=diff
==============================================================================
---
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/builders/LogoutRequestBuilder.java
    (original)
+++
carbon/platform/branches/4.0.0/components/authenticators/saml2-sso-authenticator/org.wso2.carbon.identity.authenticator.saml2.sso.common/4.0.2/src/main/java/org/wso2/carbon/identity/authenticator/saml2/sso/common/builders/LogoutRequestBuilder.java
    Thu Oct  4 13:47:19 2012
@@ -18,6 +18,9 @@
 package org.wso2.carbon.identity.authenticator.saml2.sso.common.builders;

 import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.xml.security.signature.XMLSignature;
 import org.joda.time.DateTime;
 import org.opensaml.saml2.core.Issuer;
 import org.opensaml.saml2.core.LogoutRequest;
@@ -33,14 +36,18 @@
  * This class is used to generate the Logout Requests.
  */
 public class LogoutRequestBuilder {
+
+       private static Log log =
LogFactory.getLog(LogoutRequestBuilder.class);

     /**
      * Build the logout request
      * @param subject name of the user
      * @param reason reason for generating logout request.
      * @return LogoutRequest object
+     * @throws Exception
      */
-    public LogoutRequest buildLogoutRequest(String subject, String reason)
{
+    public LogoutRequest buildLogoutRequest(String subject, String reason)
throws Exception {
+       log.info("Building logout request");
         Util.doBootstrap();
         LogoutRequest logoutReq = new
org.opensaml.saml2.core.impl.LogoutRequestBuilder().buildObject();
         logoutReq.setID(Util.createID());
@@ -65,6 +72,8 @@
         logoutReq.getSessionIndexes().add(sessionIndex);

         logoutReq.setReason(reason);
+
+        Util.setSignature(logoutReq, XMLSignature.ALGO_ID_SIGNATURE_RSA,
new SignKeyDataHolder());

         return logoutReq;
     }
_______________________________________________
Commits mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/commits



-- 
Sagara Gunathunga

Technical Lead; WSO2, Inc.;  http://wso2.com
V.P Apache Web Services ;  http://ws.apache.org/
Blog ;  http://ssagara.blogspot.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to