Author: psharples
Date: Thu Jul 26 15:12:25 2012
New Revision: 1366035

URL: http://svn.apache.org/viewvc?rev=1366035&view=rev
Log:
Initial commit of the digsig signing functionality. See WOOKIE-139.

Added:
    incubator/wookie/trunk/digsig-client/
    incubator/wookie/trunk/digsig-client/java/
    incubator/wookie/trunk/digsig-client/java/README.txt   (with props)
    incubator/wookie/trunk/digsig-client/java/resources/
    incubator/wookie/trunk/digsig-client/java/resources/logo.png   (with props)
    incubator/wookie/trunk/digsig-client/java/resources/wookie_test_store.jks   
(with props)
    incubator/wookie/trunk/digsig-client/java/src/
    incubator/wookie/trunk/digsig-client/java/src-tests/
    incubator/wookie/trunk/digsig-client/java/src/org/
    incubator/wookie/trunk/digsig-client/java/src/org/apache/
    incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/
    incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/
    
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/
    
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/SignCoordinator.java
   (with props)
    
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/
    
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignWidgets.java
   (with props)
    
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignerConstants.java
   (with props)
    
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/ui/
    
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/ui/SignerJFrame.java
   (with props)
Modified:
    incubator/wookie/trunk/.classpath
    incubator/wookie/trunk/ivy.xml

Modified: incubator/wookie/trunk/.classpath
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/.classpath?rev=1366035&r1=1366034&r2=1366035&view=diff
==============================================================================
--- incubator/wookie/trunk/.classpath (original)
+++ incubator/wookie/trunk/.classpath Thu Jul 26 15:12:25 2012
@@ -1,13 +1,14 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="src" path="src-tests"/>
-       <classpathentry kind="src" output="parser/java/bin" 
path="parser/java/src"/>
-       <classpathentry kind="src" output="parser/java/bin" 
path="parser/java/src-test"/>
-       <classpathentry kind="src" path="connector/java/src"/>
-       <classpathentry kind="src" path="connector/java/src-test"/>
-       <classpathentry kind="con" 
path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
-       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-       <classpathentry kind="con" 
path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?ivyXmlPath=ivy.xml&amp;confs=*"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="src" path="src-tests"/>
+       <classpathentry kind="src" output="parser/java/bin" 
path="parser/java/src"/>
+       <classpathentry kind="src" output="parser/java/bin" 
path="parser/java/src-test"/>
+       <classpathentry kind="src" path="connector/java/src"/>
+       <classpathentry kind="src" path="connector/java/src-test"/>
+       <classpathentry kind="src" output="digsig-client/java/bin" 
path="digsig-client/java/src"/>
+       <classpathentry kind="con" 
path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="con" 
path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?ivyXmlPath=ivy.xml&amp;confs=*"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>

Added: incubator/wookie/trunk/digsig-client/java/README.txt
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/digsig-client/java/README.txt?rev=1366035&view=auto
==============================================================================
--- incubator/wookie/trunk/digsig-client/java/README.txt (added)
+++ incubator/wookie/trunk/digsig-client/java/README.txt Thu Jul 26 15:12:25 
2012
@@ -0,0 +1,89 @@
+===========================
+Client Widget Signer Guide
+===========================
+
+This is the client digital signature widget signing package developed as part
+of Apache Wookie (incubating).
+See http://dev.w3.org/2006/waf/widgets-digsig/ 
+and https://issues.apache.org/jira/browse/WOOKIE-139
+for more info. (Thanks to Pushpalanka Jayawardhana)
+
+Guide to the Swing based client application
+===========================================
+Run "SignCoordinator" (as a standalone java app) and a swing based application 
should 
+appear.  What follows is a brief explanation of the fields in the application.
+
+Author/Distributor
+------------------     
+Your role should be selected. Depending on your role, files will be selected 
for signing 
+according to the W3C widget digsig specification. An Author will sign all the 
content of the 
+widget except distributor signatures. A distributor will sign all the content 
of a widget 
+except other distributor signatures.
+
+Keystore File
+-------------
+The recommended key length is 4096 bits. Only RSA keystores are accepted here 
according to W3C 
+widget digsig specification. You can use the given sample keystore file for 
testing purposes 
+which is generated using Java keytool. (Found in 
digsig-client/java/resources/wookie_test_store.jks)
+Alternatively see below on how to generate a new one.
+
+Keystore Password
+-----------------
+Password given for Keystore file. For the sample keystore file this is 
'wookie'.
+
+Private Key Alias
+-----------------
+The key alias given in key generation. For the sample this is 'wookietest'.
+
+Private Key Password
+--------------------
+You can keep this blank to use the same password as of the keystore, which is 
the default setting. 
+If it differs you can enter it here. 
+
+Certificate Alias
+-----------------
+The alias for the X509 certificate. You can keep this blank to use the same 
alias as of the private 
+key, which is the default setting.
+
+Path to Widget
+--------------
+Point to the folder which carries widget content. Once you select the path, 
the content to be signed 
+will be shown in the below text area. According to your role files will be 
selected and any hidden 
+files(name starting with '.') will be skipped. Before signing you can check 
whether the signing content 
+is correct. Any modifications needed should be done in the widget folder and 
reselect the folder in GUI.
+
+Widget Name
+-----------
+Any preferred name for the widget.
+
+Once you press 'Sign' the signer will generate a signature file for the 
selected content, using the given 
+key details. The generated signature file will be stored in the same folder. 
Also the signed content and the 
+signature will be packed into 'widget_name.wgt' and stored in the same folder, 
that you can directly send 
+to deployment.
+
+
+How to generate a new keystore file
+===================================
+
+Replace <your *something*> with your own values below
+
+C:\temp>keytool  -genkeypair -alias <your alias> -storepass <your password> 
-validity 365 -keyalg RSA -keysize 4096 -keystore <filename>.jks
+What is your first and last name?
+  [Unknown]:  <enter your name> 
+What is the name of your organizational unit?
+  [Unknown]:  <enter your ou>
+What is the name of your organization?
+  [Unknown]:  <enter your org>
+What is the name of your City or Locality?
+  [Unknown]:  <enter your city>
+What is the name of your State or Province?
+  [Unknown]:  <enter your state>
+What is the two-letter country code for this unit?
+  [Unknown]:  <enter your county, i,e GB>
+Is CN=Fred Bloggs, OU=myDept, O=Acme99 Inc, L=someTown, ST=someState, C=gb 
correct?
+  [no]:  yes
+
+Enter key password for <your alias>
+        (RETURN if same as keystore password):
+
+C:\temp>
\ No newline at end of file

Propchange: incubator/wookie/trunk/digsig-client/java/README.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/wookie/trunk/digsig-client/java/resources/logo.png
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/digsig-client/java/resources/logo.png?rev=1366035&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/wookie/trunk/digsig-client/java/resources/logo.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/wookie/trunk/digsig-client/java/resources/wookie_test_store.jks
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/digsig-client/java/resources/wookie_test_store.jks?rev=1366035&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
incubator/wookie/trunk/digsig-client/java/resources/wookie_test_store.jks
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/SignCoordinator.java
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/SignCoordinator.java?rev=1366035&view=auto
==============================================================================
--- 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/SignCoordinator.java
 (added)
+++ 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/SignCoordinator.java
 Thu Jul 26 15:12:25 2012
@@ -0,0 +1,27 @@
+/*
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wookie.digsig.client;
+
+import org.apache.wookie.digsig.client.model.SignWidgets;
+import org.apache.wookie.digsig.client.ui.SignerJFrame;
+
+/** @author Pushpalanka */
+public class SignCoordinator {
+
+    public static void main(String args[]) {
+        SignWidgets signWidgets = new SignWidgets();
+        SignerJFrame signerJFrame = new SignerJFrame(signWidgets);
+        signerJFrame.setVisible(true);
+    }
+}

Propchange: 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/SignCoordinator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignWidgets.java
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignWidgets.java?rev=1366035&view=auto
==============================================================================
--- 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignWidgets.java
 (added)
+++ 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignWidgets.java
 Thu Jul 26 15:12:25 2012
@@ -0,0 +1,311 @@
+/*
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wookie.digsig.client.model;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.Random;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.signature.ObjectContainer;
+import org.apache.xml.security.signature.SignatureProperties;
+import org.apache.xml.security.signature.SignatureProperty;
+import org.apache.xml.security.signature.XMLSignature;
+import org.apache.xml.security.signature.XMLSignatureException;
+import org.apache.xml.security.transforms.Transforms;
+import org.apache.xml.security.utils.XMLUtils;
+import org.apache.xml.security.utils.resolver.ResourceResolver;
+import org.w3c.dom.Element;
+
+/** @author Pushpalanka */
+
+/**
+ * Perform signing over a widget according to the recommendations specified
+ * in W3C widgets digsig specification
+ */
+public class SignWidgets {
+
+               private String keyStoreType = "JKS";
+               private String keyStoreFile = "";
+               private String keyStorePass = "";
+               private String privateKeyAlias = "";
+               private String privateKeyPass = "";
+               private String certificateAlias = "";
+               private String pathToWidget = "";
+               private String documentsList = "";
+               private String role = "AuthorSignature";
+               private String target = "";
+               private String roleURI = "";
+               private String name = "";
+               private String[] documents;
+               private String signatureFileName = "";
+
+               public void setKeyStoreFile(String keyStoreFile) {
+                               this.keyStoreFile = keyStoreFile;
+               }
+
+               public void setKeyStorePass(String keyStorePass) {
+                               this.keyStorePass = keyStorePass;
+               }
+
+               public void setPrivateKeyAlias(String privateKeyAlias) {
+                               this.privateKeyAlias = privateKeyAlias;
+               }
+
+               public void setPrivateKeyPass(String privateKeyPass) {
+                               this.privateKeyPass = privateKeyPass;
+               }
+
+               public void setCertificateAlias(String certificateAlias) {
+                               this.certificateAlias = certificateAlias;
+               }
+
+               public void setRole(String role) {
+                               this.role = role;
+               }
+
+               public void setDocumentsList(String documentsList) {
+                               this.documentsList = documentsList;
+               }
+
+               public void setPathToWidget(String pathToWidget) {
+                               this.pathToWidget = pathToWidget;
+               }
+
+               public void setName(String name) {
+                               this.name = name;
+               }
+
+               static {
+                               org.apache.xml.security.Init.init();
+               }
+
+               /** Generate signature for the widget content under W3C widgets 
digsig specification */
+               public void sign() throws KeyStoreException, IOException,
+                               NoSuchAlgorithmException, CertificateException,
+                               UnrecoverableKeyException, XMLSecurityException,
+                               ParserConfigurationException {
+
+                               //set signature file names according to the 
role as specified in W3C widgets digsig spec
+                               if(role.equals("AuthorSignature")){
+                                               signatureFileName = 
"/author-signature.xml";
+                               }
+                               else{
+                                               Random randomGenerator = new 
Random();
+                                               Integer number = 
randomGenerator.nextInt(20);
+                                               signatureFileName = 
"/signature" + number + ".xml";
+                               }
+
+                               File signatureFile = new File(pathToWidget + 
signatureFileName);
+
+                               //get the private key from keystore
+                               KeyStore ks = 
KeyStore.getInstance(keyStoreType);
+                               FileInputStream fis = new 
FileInputStream(keyStoreFile);
+                               ks.load(fis, keyStorePass.toCharArray());
+                               PrivateKey privateKey = (PrivateKey) 
ks.getKey(privateKeyAlias,
+                                               privateKeyPass.toCharArray());
+
+                               javax.xml.parsers.DocumentBuilderFactory dbf = 
javax.xml.parsers.DocumentBuilderFactory
+                                               .newInstance();
+                               dbf.setNamespaceAware(true);
+                               javax.xml.parsers.DocumentBuilder db = 
dbf.newDocumentBuilder();
+                               org.w3c.dom.Document doc = db.newDocument();
+
+                               //BaseURI provides the base for the path to 
referenced content from the signature
+                               String BaseURI = 
signatureFile.toURI().toURL().toString();
+                               XMLSignature sig = new XMLSignature(doc, 
BaseURI,
+                                               
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256,
+                                               
Transforms.TRANSFORM_C14N11_OMIT_COMMENTS);
+                               
+                               sig.setId(role);
+
+                               doc.appendChild(sig.getElement());
+                               {
+
+                                               Transforms transforms = new 
Transforms(doc);
+
+                                               
transforms.addTransform(Transforms.TRANSFORM_C14N11_OMIT_COMMENTS);
+                                               addDocuments(sig, 
documentsList);
+
+                                               customizeToRole(role);
+
+                                               //Adding signature properties
+                                               SignatureProperty profile = new 
SignatureProperty(doc, target,
+                                                               
SignerConstants.SIGNATURE_PROPERTY_ID_PROFILE);
+                                               Element profileElement = doc
+                                                               
.createElement(SignerConstants.SIGNATURE_PROPERTY_ID_PROFILE_TAG_NAME);
+                                               
profileElement.setAttribute("URI", SignerConstants.PROFILE_URI);
+                                               
profile.appendChild(profileElement);
+
+                                               SignatureProperty role = new 
SignatureProperty(doc, target,
+                                                               
SignerConstants.SIGNATURE_PROPERTY_ID_ROLE);
+                                               Element roleElement = doc
+                                                               
.createElement(SignerConstants.SIGNATURE_PROPERTY_ID_ROLE_TAG_NAME);
+                                               roleElement.setAttribute("URI", 
roleURI);
+                                               role.appendChild(roleElement);
+
+                                               SignatureProperty identifier = 
new SignatureProperty(doc, target,
+                                                               
SignerConstants.SIGNATURE_PROPERTY_ID_IDENTIFIER);
+                                               Element identifierElement = doc
+                                                               
.createElement(SignerConstants.SIGNATURE_PROPERTY_ID_IDENTIFIER_TAG_NAME);
+                                               
identifierElement.setTextContent(name);
+                                               
identifier.appendChild(identifierElement);
+
+                                               SignatureProperties props = new 
SignatureProperties(doc);
+
+                                               
props.setXPathNamespaceContext(SignerConstants.XMLNS_DSP,
+                                                               
SignerConstants.SIGNATURE_PROPERTIES_NAMESPACE);
+                                               
props.addSignatureProperty(profile);
+                                               
props.addSignatureProperty(role);
+                                               
props.addSignatureProperty(identifier);
+                                               ObjectContainer object = new 
ObjectContainer(doc);
+                                               object.setId("prop");
+
+                                               
object.appendChild(doc.createTextNode("\n"));
+                                               
object.appendChild(props.getElement());
+                                               
object.appendChild(doc.createTextNode("\n"));
+
+                                               //Refer the properties section 
of the signature which needs
+                                               //to be signed too, that 
include role information.
+                                               sig.appendObject(object);
+                                               sig.addDocument("#prop", 
transforms,
+                                                               
SignerConstants.DIGEST_METHOD_ALGORITHM);
+
+                                               ResourceResolver 
offlineResolver = null;
+                                               
sig.addResourceResolver(offlineResolver);
+
+                                               {
+                                                               X509Certificate 
cert = (X509Certificate) ks
+                                                                               
.getCertificate(certificateAlias);
+                                                               
if(cert.equals(null)){
+                                                                               
throw new NullPointerException();
+                                                               }
+                                                               
sig.addKeyInfo(cert);
+                                                               
sig.addKeyInfo(cert.getPublicKey());
+
+                                                               
System.out.println("Start signing");
+                                                               
sig.sign(privateKey);
+                                                               
System.out.println("Finished signing");
+                                               }
+
+                                               FileOutputStream f = new 
FileOutputStream(signatureFile);
+
+                                               XMLUtils.outputDOM(doc, f);
+                                               f.close();
+                                               System.out.println("Wrote 
signature to " + BaseURI);
+                               }
+               }
+
+               /**
+                * To add the content of the widget as reference in the 
signature
+                *
+                * @param sig : generating signature
+                * @param documentsList: list of files inside widget folder. 
All the content of .wgt needs to be signed.
+                */
+               private void addDocuments(XMLSignature sig, String 
documentsList) {
+                               documents = documentsList.split("\n");
+                               for(int i = 0; i < documents.length; i++){
+                                               try {
+                                                               
sig.addDocument(documents[i], null,
+                                                                               
SignerConstants.DIGEST_METHOD_ALGORITHM);
+                                               }
+                                               catch(XMLSignatureException e) {
+                                                               
e.printStackTrace();
+                                               }
+                               }
+               }
+
+               /**
+                * Set parameters of the signature according to the role of the 
signer
+                *
+                * @param role: whether signing person is author or distributor
+                */
+               private void customizeToRole(String role) {
+                               if(role.equals("AuthorSignature")){
+                                               target = 
SignerConstants.SIGN_TARGET_AUTHOR;
+                                               roleURI = 
SignerConstants.ROLE_URI_AUTHOR;
+                               }
+                               else if(role.equals("DistributorSignature")){
+                                               target = 
SignerConstants.SIGN_TARGET_DISTRIBUTOR;
+                                               roleURI = 
SignerConstants.ROLE_URI_DISTRIBUTOR;
+                               }
+                               else{
+
+                               }
+               }
+
+               /** Pack the content into a .wgt package */
+               public void repackZip() throws IOException {
+                               File sourceOfFiles = new File(pathToWidget);
+                               ZipArchiveOutputStream out = new 
ZipArchiveOutputStream(new File(
+                                               sourceOfFiles.getAbsolutePath() 
+ File.separator + name + ".wgt"));
+                               out.setEncoding("UTF-8");
+                               for(File aFile : sourceOfFiles.listFiles()){
+                                               
if(!aFile.getName().endsWith(".wgt")){
+                                                               pack(aFile, 
out, "");
+                                               }
+                               }
+                               out.flush();
+                               out.close();
+               }
+
+               /**
+                * Recursively locates and adds files and folders to a zip 
archive
+                *
+                * @param file: directory that includes widget content
+                * @param out: ZipArchiveOutputStream
+                * @param path:location of content inside .wgt, relatively
+                */
+               private static void pack(File file, ZipArchiveOutputStream out, 
String path)
+                               throws IOException {
+
+                               // To avoid include of hidden files and folders 
checking has done on name to
+                               // start with ".".
+                               if(file.isDirectory() && 
!(file.getName().startsWith("."))){
+                                               path = path + file.getName() + 
"/";
+                                               for(File aFile : 
file.listFiles()){
+                                                               pack(aFile, 
out, path);
+                                               }
+                               }
+                               else{
+
+                                               String name = file.getName();
+                                               if(!name.startsWith(".")){
+                                                               ZipArchiveEntry 
entry = (ZipArchiveEntry) out.createArchiveEntry(file,
+                                                                               
path + name);
+                                                               
out.putArchiveEntry(entry);
+                                                               byte[] buf = 
new byte[1024];
+                                                               int len;
+                                                               FileInputStream 
in = new FileInputStream(file);
+                                                               while((len = 
in.read(buf)) > 0){
+                                                                               
out.write(buf, 0, len);
+                                                               }
+                                                               
out.closeArchiveEntry();
+                                               }
+                               }
+               }
+}

Propchange: 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignWidgets.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignerConstants.java
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignerConstants.java?rev=1366035&view=auto
==============================================================================
--- 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignerConstants.java
 (added)
+++ 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignerConstants.java
 Thu Jul 26 15:12:25 2012
@@ -0,0 +1,33 @@
+/*
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wookie.digsig.client.model;
+
+/** @author Pushpalanka */
+public class SignerConstants {
+
+               public static final String SIGN_TARGET_DISTRIBUTOR = 
"#DistributorSignature";
+               public static final String SIGN_TARGET_AUTHOR = 
"#AuthorSignature";
+               public static final String DIGEST_METHOD_ALGORITHM = 
"http://www.w3.org/2001/04/xmlenc#sha256";;
+               public static final String PROFILE_URI = 
"http://www.w3.org/ns/widgets-digsig#profile";;
+               public static final String ROLE_URI_DISTRIBUTOR = 
"http://www.w3.org/ns/widgets-digsig#role-distributor";;
+               public static final String ROLE_URI_AUTHOR = 
"http://www.w3.org/ns/widgets-digsig#role-author";;
+               public static final String SIGNATURE_PROPERTIES_NAMESPACE = 
"http://www.w3.org/2009/xmldsig-properties";;
+               public static final String SIGNATURE_PROPERTY_ID_ROLE = "role";
+               public static final String SIGNATURE_PROPERTY_ID_PROFILE = 
"profile";
+               public static final String SIGNATURE_PROPERTY_ID_IDENTIFIER = 
"identifier";
+               public static final String SIGNATURE_PROPERTY_ID_ROLE_TAG_NAME 
= "dsp:Role";
+               public static final String 
SIGNATURE_PROPERTY_ID_PROFILE_TAG_NAME = "dsp:Profile";
+               public static final String 
SIGNATURE_PROPERTY_ID_IDENTIFIER_TAG_NAME = "dsp:Identifier";
+               public static final String XMLNS_DSP = "xmlns:dsp";
+}

Propchange: 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/model/SignerConstants.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/ui/SignerJFrame.java
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/ui/SignerJFrame.java?rev=1366035&view=auto
==============================================================================
--- 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/ui/SignerJFrame.java
 (added)
+++ 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/ui/SignerJFrame.java
 Thu Jul 26 15:12:25 2012
@@ -0,0 +1,658 @@
+/*
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wookie.digsig.client.ui;
+
+import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.io.File;
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+
+import javax.swing.*;
+import javax.swing.filechooser.FileNameExtensionFilter;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.wookie.digsig.client.model.SignWidgets;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.signature.XMLSignatureException;
+
+/** @author Pushpalanka */
+
+/** Provide a GUI for the user submit the needed to details to sign a widget */
+public class SignerJFrame extends javax.swing.JFrame {
+
+        private static final long serialVersionUID = 1L;
+        SignWidgets signWidgets; // private?
+               private String role;
+
+               /** Creates new form SignerJFrame */
+               public SignerJFrame(SignWidgets signWidgets) {
+                               initComponents();
+                               this.signWidgets = signWidgets;
+               }
+
+               /** This method is called from within the constructor to 
initialize the form. */
+               private void initComponents() {
+
+                               buttonGroup1 = new ButtonGroup();
+                               jPanel1 = new JPanel();
+                               jLabel1 = new JLabel();
+                               authorRadioButton1 = new JRadioButton();
+                               distributorRadioButton2 = new JRadioButton();
+                               jLabel2 = new JLabel();
+                               jLabel3 = new JLabel();
+                               jLabel4 = new JLabel();
+                               jLabel5 = new JLabel();
+                               jLabel6 = new JLabel();
+                               jLabel7 = new JLabel();
+                               kSTextField = new JTextField();
+                               kSPasswordField = new JPasswordField();
+                               pKAlias = new JTextField();
+                               pKPasswordField = new JPasswordField();
+                               certificateAliasText = new JTextField();
+                               filesScrollPane = new JScrollPane();
+                               jTextArea1 = new JTextArea();
+                               signButton = new JButton();
+                               browseButton1 = new JButton();
+                               browseButton2 = new JButton();
+                               jLabel8 = new JLabel();
+                               jLabel9 = new JLabel();
+                               widgetTextField1 = new JTextField();
+                               widgetName = new JTextField();
+                               jLabel10 = new JLabel();
+
+                               
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+                               setBackground(new Color(228, 222, 145));
+                               setBounds(new Rectangle(350, 100, 0, 0));
+
+                               jPanel1.setBackground(new Color(245, 240, 181));
+
+                               jLabel1.setIcon(new ImageIcon(
+                                               
"digsig-client/java/resources/logo.png")); // NOI18N
+
+                               authorRadioButton1.setBackground(new Color(245, 
240, 181));
+                               buttonGroup1.add(authorRadioButton1);
+                               authorRadioButton1.setSelected(true);
+                               authorRadioButton1.setText("Author");
+
+                               distributorRadioButton2.setBackground(new 
Color(245, 240, 181));
+                               buttonGroup1.add(distributorRadioButton2);
+                               distributorRadioButton2.setText("Distributor");
+
+                               jLabel2.setText("Keystore file:");
+
+                               jLabel3.setText("Keystore Password:");
+
+                               jLabel4.setText("Private Key Alias:");
+
+                               jLabel5.setText("Private Key Password:");
+
+                               jLabel6.setText("Certificate Alias:");
+
+                               jLabel7.setText("Following files will be 
signed");
+
+                               pKPasswordField.setToolTipText("Keep blank to 
use as same as keystore");
+
+                               certificateAliasText.setToolTipText("Keep blank 
to use as same as key");
+
+                               jTextArea1.setColumns(20);
+                               jTextArea1.setEditable(false);
+                               jTextArea1.setRows(5);
+                               filesScrollPane.setViewportView(jTextArea1);
+
+                               signButton.setBackground(new 
java.awt.Color(100, 40, 0));
+                               signButton.setForeground(new 
java.awt.Color(255, 255, 255));
+                               signButton.setText("Sign");
+                               signButton.setFocusPainted(true);
+                               signButton.setBorderPainted(true);
+                               signButton.setPreferredSize(new 
java.awt.Dimension(67, 23));
+                               signButton.addMouseListener(new 
java.awt.event.MouseAdapter() {
+                                               public void 
mouseClicked(java.awt.event.MouseEvent evt) {
+                                                               try {
+                                                                               
signButtonMouseClicked(evt);
+                                                               }
+                                                               catch(Exception 
e) {
+                                                                               
e.printStackTrace();
+                                                               }
+                                               }
+                               });
+
+                               browseButton1.setText("Browse");
+                               browseButton1.setBackground(new 
java.awt.Color(228, 222, 145));
+                               browseButton1.setFocusPainted(true);
+                               browseButton1.setBorderPainted(true);
+                               browseButton1.addMouseListener(new 
java.awt.event.MouseAdapter() {
+                                               public void 
mouseClicked(java.awt.event.MouseEvent evt) {
+                                                               
browseButton1MouseClicked(evt);
+                                               }
+                               });
+
+                               browseButton2.setText("Browse");
+                               browseButton2.setBackground(new 
java.awt.Color(228, 222, 145));
+                               browseButton2.setFocusPainted(true);
+                               browseButton2.setBorderPainted(true);
+                               browseButton2.addMouseListener(new 
java.awt.event.MouseAdapter() {
+                                               public void 
mouseClicked(java.awt.event.MouseEvent evt) {
+                                                               
browseButton2MouseClicked(evt);
+                                               }
+                               });
+
+                               jLabel8.setFont(new Font("Garamond", 1, 24));
+                               jLabel8.setForeground(new Color(113, 70, 20));
+                               
jLabel8.setHorizontalAlignment(SwingConstants.CENTER);
+                               jLabel8.setText("Widget Signer");
+
+                               jLabel9.setText("Path to Widget:");
+
+                               jLabel10.setText("Widget Name:");
+
+                               GroupLayout jPanel1Layout = new 
GroupLayout(jPanel1);
+                               jPanel1.setLayout(jPanel1Layout);
+                               jPanel1Layout
+                                               
.setHorizontalGroup(jPanel1Layout
+                                                               
.createParallelGroup(GroupLayout.Alignment.LEADING)
+                                                               .addGroup(
+                                                                               
jPanel1Layout
+                                                                               
                .createSequentialGroup()
+                                                                               
                .addContainerGap()
+                                                                               
                .addGroup(
+                                                                               
                                jPanel1Layout
+                                                                               
                                                
.createParallelGroup(GroupLayout.Alignment.LEADING)
+                                                                               
                                                
.addComponent(jLabel2).addComponent(jLabel3)
+                                                                               
                                                
.addComponent(jLabel4).addComponent(jLabel5)
+                                                                               
                                                
.addComponent(jLabel6).addComponent(jLabel9)
+                                                                               
                                                .addComponent(jLabel10))
+                                                                               
                .addGap(12, 12, 12)
+                                                                               
                .addGroup(
+                                                                               
                                jPanel1Layout
+                                                                               
                                                
.createParallelGroup(GroupLayout.Alignment.LEADING)
+                                                                               
                                                .addGroup(
+                                                                               
                                                                
jPanel1Layout.createSequentialGroup()
+                                                                               
                                                                                
.addComponent(jLabel7).addContainerGap())
+                                                                               
                                                .addGroup(
+                                                                               
                                                                jPanel1Layout
+                                                                               
                                                                                
.createSequentialGroup()
+                                                                               
                                                                                
.addGroup(
+                                                                               
                                                                                
                jPanel1Layout
+                                                                               
                                                                                
                                .createParallelGroup(
+                                                                               
                                                                                
                                                GroupLayout.Alignment.TRAILING)
+                                                                               
                                                                                
                                .addGroup(
+                                                                               
                                                                                
                                                GroupLayout.Alignment.LEADING,
+                                                                               
                                                                                
                                                jPanel1Layout
+                                                                               
                                                                                
                                                                
.createSequentialGroup()
+                                                                               
                                                                                
                                                                .addGap(2, 2, 2)
+                                                                               
                                                                                
                                                                .addGroup(
+                                                                               
                                                                                
                                                                                
jPanel1Layout
+                                                                               
                                                                                
                                                                                
                .createParallelGroup(
+                                                                               
                                                                                
                                                                                
                                GroupLayout.Alignment.LEADING)
+                                                                               
                                                                                
                                                                                
                .addGroup(
+                                                                               
                                                                                
                                                                                
                                jPanel1Layout
+                                                                               
                                                                                
                                                                                
                                                .createSequentialGroup()
+                                                                               
                                                                                
                                                                                
                                                .addComponent(
+                                                                               
                                                                                
                                                                                
                                                                
authorRadioButton1)
+                                                                               
                                                                                
                                                                                
                                                .addGap(79,
+                                                                               
                                                                                
                                                                                
                                                                79, 79)
+                                                                               
                                                                                
                                                                                
                                                .addComponent(
+                                                                               
                                                                                
                                                                                
                                                                
distributorRadioButton2))
+                                                                               
                                                                                
                                                                                
                .addComponent(
+                                                                               
                                                                                
                                                                                
                                jLabel8,
+                                                                               
                                                                                
                                                                                
                                GroupLayout.PREFERRED_SIZE,
+                                                                               
                                                                                
                                                                                
                                227,
+                                                                               
                                                                                
                                                                                
                                GroupLayout.PREFERRED_SIZE))
+                                                                               
                                                                                
                                                                
.addPreferredGap(
+                                                                               
                                                                                
                                                                                
LayoutStyle.ComponentPlacement.RELATED,
+                                                                               
                                                                                
                                                                                
39, Short.MAX_VALUE)
+                                                                               
                                                                                
                                                                
.addComponent(jLabel1))
+                                                                               
                                                                                
                                .addGroup(
+                                                                               
                                                                                
                                                jPanel1Layout
+                                                                               
                                                                                
                                                                
.createSequentialGroup()
+                                                                               
                                                                                
                                                                .addGroup(
+                                                                               
                                                                                
                                                                                
jPanel1Layout
+                                                                               
                                                                                
                                                                                
                .createParallelGroup(
+                                                                               
                                                                                
                                                                                
                                GroupLayout.Alignment.LEADING)
+                                                                               
                                                                                
                                                                                
                .addComponent(
+                                                                               
                                                                                
                                                                                
                                filesScrollPane,
+                                                                               
                                                                                
                                                                                
                                GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                                                                                
                                382,
+                                                                               
                                                                                
                                                                                
                                Short.MAX_VALUE)
+                                                                               
                                                                                
                                                                                
                .addComponent(
+                                                                               
                                                                                
                                                                                
                                widgetTextField1,
+                                                                               
                                                                                
                                                                                
                                GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                                                                                
                                382,
+                                                                               
                                                                                
                                                                                
                                Short.MAX_VALUE)
+                                                                               
                                                                                
                                                                                
                .addComponent(
+                                                                               
                                                                                
                                                                                
                                kSTextField,
+                                                                               
                                                                                
                                                                                
                                GroupLayout.Alignment.TRAILING,
+                                                                               
                                                                                
                                                                                
                                GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                                                                                
                                382,
+                                                                               
                                                                                
                                                                                
                                Short.MAX_VALUE)
+                                                                               
                                                                                
                                                                                
                .addGroup(
+                                                                               
                                                                                
                                                                                
                                jPanel1Layout
+                                                                               
                                                                                
                                                                                
                                                .createParallelGroup(
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.Alignment.TRAILING,
+                                                                               
                                                                                
                                                                                
                                                                false)
+                                                                               
                                                                                
                                                                                
                                                .addComponent(
+                                                                               
                                                                                
                                                                                
                                                                
certificateAliasText,
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.Alignment.LEADING)
+                                                                               
                                                                                
                                                                                
                                                .addComponent(
+                                                                               
                                                                                
                                                                                
                                                                pKPasswordField,
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.Alignment.LEADING)
+                                                                               
                                                                                
                                                                                
                                                .addComponent(
+                                                                               
                                                                                
                                                                                
                                                                pKAlias,
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.Alignment.LEADING)
+                                                                               
                                                                                
                                                                                
                                                .addComponent(
+                                                                               
                                                                                
                                                                                
                                                                kSPasswordField,
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.Alignment.LEADING,
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.PREFERRED_SIZE,
+                                                                               
                                                                                
                                                                                
                                                                211,
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.PREFERRED_SIZE))
+                                                                               
                                                                                
                                                                                
                .addComponent(
+                                                                               
                                                                                
                                                                                
                                widgetName,
+                                                                               
                                                                                
                                                                                
                                GroupLayout.PREFERRED_SIZE,
+                                                                               
                                                                                
                                                                                
                                212,
+                                                                               
                                                                                
                                                                                
                                GroupLayout.PREFERRED_SIZE))
+                                                                               
                                                                                
                                                                .addGap(29, 29, 
29)
+                                                                               
                                                                                
                                                                .addGroup(
+                                                                               
                                                                                
                                                                                
jPanel1Layout
+                                                                               
                                                                                
                                                                                
                .createParallelGroup(
+                                                                               
                                                                                
                                                                                
                                GroupLayout.Alignment.LEADING)
+                                                                               
                                                                                
                                                                                
                .addComponent(
+                                                                               
                                                                                
                                                                                
                                signButton,
+                                                                               
                                                                                
                                                                                
                                GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                                                                                
                                GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                                                                                
                                Short.MAX_VALUE)
+                                                                               
                                                                                
                                                                                
                .addGroup(
+                                                                               
                                                                                
                                                                                
                                jPanel1Layout
+                                                                               
                                                                                
                                                                                
                                                .createParallelGroup(
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.Alignment.TRAILING,
+                                                                               
                                                                                
                                                                                
                                                                false)
+                                                                               
                                                                                
                                                                                
                                                .addComponent(
+                                                                               
                                                                                
                                                                                
                                                                browseButton1,
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                                                                                
                                                                Short.MAX_VALUE)
+                                                                               
                                                                                
                                                                                
                                                .addComponent(
+                                                                               
                                                                                
                                                                                
                                                                browseButton2,
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                                                                                
                                                                
GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                                                                                
                                                                
Short.MAX_VALUE)))))
+                                                                               
                                                                                
.addGap(24, 24, 24)))));
+                               jPanel1Layout
+                                               .setVerticalGroup(jPanel1Layout
+                                                               
.createParallelGroup(GroupLayout.Alignment.LEADING)
+                                                               .addGroup(
+                                                                               
jPanel1Layout
+                                                                               
                .createSequentialGroup()
+                                                                               
                .addContainerGap()
+                                                                               
                .addGroup(
+                                                                               
                                jPanel1Layout
+                                                                               
                                                .createParallelGroup(
+                                                                               
                                                                
GroupLayout.Alignment.TRAILING, false)
+                                                                               
                                                .addGroup(
+                                                                               
                                                                jPanel1Layout
+                                                                               
                                                                                
.createSequentialGroup()
+                                                                               
                                                                                
.addComponent(jLabel8,
+                                                                               
                                                                                
                GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                Short.MAX_VALUE)
+                                                                               
                                                                                
.addGap(18, 18, 18)
+                                                                               
                                                                                
.addGroup(
+                                                                               
                                                                                
                jPanel1Layout
+                                                                               
                                                                                
                                .createParallelGroup(
+                                                                               
                                                                                
                                                GroupLayout.Alignment.BASELINE)
+                                                                               
                                                                                
                                .addComponent(authorRadioButton1)
+                                                                               
                                                                                
                                .addComponent(
+                                                                               
                                                                                
                                                distributorRadioButton2)))
+                                                                               
                                                .addComponent(jLabel1))
+                                                                               
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+                                                                               
                .addGroup(
+                                                                               
                                jPanel1Layout
+                                                                               
                                                
.createParallelGroup(GroupLayout.Alignment.BASELINE)
+                                                                               
                                                .addComponent(jLabel2)
+                                                                               
                                                .addComponent(browseButton1)
+                                                                               
                                                .addComponent(kSTextField,
+                                                                               
                                                                
GroupLayout.PREFERRED_SIZE,
+                                                                               
                                                                
GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                
GroupLayout.PREFERRED_SIZE))
+                                                                               
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+                                                                               
                .addGroup(
+                                                                               
                                jPanel1Layout
+                                                                               
                                                
.createParallelGroup(GroupLayout.Alignment.LEADING)
+                                                                               
                                                .addComponent(jLabel3)
+                                                                               
                                                .addComponent(kSPasswordField,
+                                                                               
                                                                
GroupLayout.PREFERRED_SIZE,
+                                                                               
                                                                
GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                
GroupLayout.PREFERRED_SIZE))
+                                                                               
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
+                                                                               
                .addGroup(
+                                                                               
                                jPanel1Layout
+                                                                               
                                                
.createParallelGroup(GroupLayout.Alignment.LEADING)
+                                                                               
                                                .addComponent(jLabel4)
+                                                                               
                                                .addComponent(pKAlias, 
GroupLayout.PREFERRED_SIZE,
+                                                                               
                                                                
GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                
GroupLayout.PREFERRED_SIZE))
+                                                                               
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
+                                                                               
                .addGroup(
+                                                                               
                                jPanel1Layout
+                                                                               
                                                
.createParallelGroup(GroupLayout.Alignment.LEADING)
+                                                                               
                                                .addComponent(jLabel5)
+                                                                               
                                                .addComponent(pKPasswordField,
+                                                                               
                                                                
GroupLayout.PREFERRED_SIZE, 20,
+                                                                               
                                                                
GroupLayout.PREFERRED_SIZE))
+                                                                               
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
+                                                                               
                .addGroup(
+                                                                               
                                jPanel1Layout
+                                                                               
                                                
.createParallelGroup(GroupLayout.Alignment.LEADING)
+                                                                               
                                                .addComponent(jLabel6)
+                                                                               
                                                
.addComponent(certificateAliasText,
+                                                                               
                                                                
GroupLayout.PREFERRED_SIZE,
+                                                                               
                                                                
GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                
GroupLayout.PREFERRED_SIZE))
+                                                                               
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
+                                                                               
                .addGroup(
+                                                                               
                                jPanel1Layout
+                                                                               
                                                
.createParallelGroup(GroupLayout.Alignment.LEADING)
+                                                                               
                                                .addGroup(
+                                                                               
                                                                jPanel1Layout
+                                                                               
                                                                                
.createParallelGroup(
+                                                                               
                                                                                
                GroupLayout.Alignment.BASELINE)
+                                                                               
                                                                                
.addComponent(browseButton2)
+                                                                               
                                                                                
.addComponent(widgetTextField1,
+                                                                               
                                                                                
                GroupLayout.PREFERRED_SIZE,
+                                                                               
                                                                                
                GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                GroupLayout.PREFERRED_SIZE))
+                                                                               
                                                .addComponent(jLabel9))
+                                                                               
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
+                                                                               
                .addGroup(
+                                                                               
                                jPanel1Layout
+                                                                               
                                                
.createParallelGroup(GroupLayout.Alignment.TRAILING)
+                                                                               
                                                .addGroup(
+                                                                               
                                                                jPanel1Layout
+                                                                               
                                                                                
.createSequentialGroup()
+                                                                               
                                                                                
.addGroup(
+                                                                               
                                                                                
                jPanel1Layout
+                                                                               
                                                                                
                                .createParallelGroup(
+                                                                               
                                                                                
                                                GroupLayout.Alignment.BASELINE)
+                                                                               
                                                                                
                                .addComponent(widgetName,
+                                                                               
                                                                                
                                                GroupLayout.PREFERRED_SIZE,
+                                                                               
                                                                                
                                                GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                                                GroupLayout.PREFERRED_SIZE)
+                                                                               
                                                                                
                                .addComponent(jLabel10))
+                                                                               
                                                                                
.addGap(18, 18, 18)
+                                                                               
                                                                                
.addComponent(jLabel7)
+                                                                               
                                                                                
.addPreferredGap(
+                                                                               
                                                                                
                LayoutStyle.ComponentPlacement.RELATED)
+                                                                               
                                                                                
.addComponent(filesScrollPane,
+                                                                               
                                                                                
                GroupLayout.PREFERRED_SIZE,
+                                                                               
                                                                                
                GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                                
                GroupLayout.PREFERRED_SIZE))
+                                                                               
                                                .addComponent(signButton,
+                                                                               
                                                                
GroupLayout.PREFERRED_SIZE,
+                                                                               
                                                                
GroupLayout.DEFAULT_SIZE,
+                                                                               
                                                                
GroupLayout.PREFERRED_SIZE))
+                                                                               
                .addContainerGap(22, Short.MAX_VALUE)));
+
+                               GroupLayout layout = new 
GroupLayout(getContentPane());
+                               getContentPane().setLayout(layout);
+                               
layout.setHorizontalGroup(layout.createParallelGroup(
+                                               
GroupLayout.Alignment.LEADING).addComponent(jPanel1,
+                                               GroupLayout.Alignment.TRAILING, 
GroupLayout.DEFAULT_SIZE,
+                                               GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE));
+                               
layout.setVerticalGroup(layout.createParallelGroup(
+                                               
GroupLayout.Alignment.LEADING).addComponent(jPanel1,
+                                               GroupLayout.DEFAULT_SIZE, 
GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
+
+                               pack();
+               }
+
+               /** Handle signing when user clicked sign button */
+               private void signButtonMouseClicked(MouseEvent evt) throws 
Exception {
+                               role = "AuthorSignature";
+
+                               String ksPassword = 
String.valueOf(kSPasswordField.getPassword());
+                               String pkPassword = "";
+                               String pKAliasText = pKAlias.getText();
+                               String certificateAlias = "";
+                               if(distributorRadioButton2.isSelected()){
+                                               role = "DistributorSignature";
+                               }
+
+                               //If private key password is not filled in, use 
keystore password as default
+                               
if(String.valueOf(pKPasswordField.getPassword()).equals("")){
+                                               pkPassword = ksPassword;
+                               }
+                               else{
+                                               pkPassword = 
String.valueOf(pKPasswordField.getPassword());
+                               }
+
+                               //If certificate alias is not filled in, use 
private key alias as default
+                               if(certificateAliasText.getText().equals("")){
+                                               certificateAlias = pKAliasText;
+                               }
+                               else{
+                                               certificateAlias = 
certificateAliasText.getText();
+                               }
+
+                               signWidgets.setRole(role);
+                               
signWidgets.setKeyStoreFile(kSTextField.getText());
+                               signWidgets.setKeyStorePass(ksPassword);
+                               signWidgets.setPrivateKeyAlias(pKAliasText);
+                               signWidgets.setPrivateKeyPass(pkPassword);
+                               
signWidgets.setCertificateAlias(certificateAlias);
+                               signWidgets.setDocumentsList(result);
+                               
signWidgets.setPathToWidget(widgetTextField1.getText());
+                               signWidgets.setName(widgetName.getText());
+                               try {
+                                               signWidgets.sign();
+                               }
+
+                               catch(NoSuchAlgorithmException e) {
+                                               
JOptionPane.showMessageDialog(this, "Incorrect algorithm! Use RSA-256.",
+                                                               "Error", 
JOptionPane.ERROR_MESSAGE);
+                                               e.printStackTrace();
+                                               kSTextField.setText("");
+                                               return;
+                               }
+                               catch(CertificateException e) {
+                                               
JOptionPane.showMessageDialog(this, "Provided certificate has problems.",
+                                                               "Error", 
JOptionPane.ERROR_MESSAGE);
+                                               kSTextField.setText("");
+                                               kSPasswordField.setText("");
+                                               
certificateAliasText.setText("");
+                                               e.printStackTrace();
+                                               return;
+                               }
+                               catch(UnrecoverableKeyException e) {
+                                               
JOptionPane.showMessageDialog(this, "A given password is incorrect.",
+                                                               "Error", 
JOptionPane.ERROR_MESSAGE);
+                                               kSPasswordField.setText("");
+                                               e.printStackTrace();
+                                               return;
+                               }
+                               catch(ParserConfigurationException e) {
+                                               
JOptionPane.showMessageDialog(this, "Error in creating the signature",
+                                                               "Error", 
JOptionPane.ERROR_MESSAGE);
+                                               kSPasswordField.setText("");
+                                               e.printStackTrace();
+                                               return;
+                               }
+                               catch(NullPointerException e) {
+                                               
JOptionPane.showMessageDialog(this, "Error with the given aliases.",
+                                                               "Error", 
JOptionPane.ERROR_MESSAGE);
+                                               pKAlias.setText("");
+                                               
certificateAliasText.setText("");
+                                               e.printStackTrace();
+                                               return;
+                               }
+                               catch(XMLSignatureException e) {
+                                               
JOptionPane.showMessageDialog(this, "Expect a RSA Private Key.", "Error",
+                                                               
JOptionPane.ERROR_MESSAGE);
+                                               kSTextField.setText("");
+                                               kSPasswordField.setText("");
+                                               e.printStackTrace();
+                                               return;
+                               }
+                               catch(XMLSecurityException e) {
+                                               
JOptionPane.showMessageDialog(this,
+                                                               "Error in 
generating signature using transforms.", "Error",
+                                                               
JOptionPane.ERROR_MESSAGE);
+                                               e.printStackTrace();
+                                               return;
+                               }
+                               catch(IOException e) {
+                                               
JOptionPane.showMessageDialog(this, "Error in accessing files.", "Error",
+                                                               
JOptionPane.ERROR_MESSAGE);
+                                               kSPasswordField.setText("");
+                                               widgetTextField1.setText("");
+                                               e.printStackTrace();
+                                               return;
+                               }
+
+                               try {
+                                               signWidgets.repackZip();
+                                               System.out.print(".wgt 
stored.");
+                               }
+                               catch(IOException e) {
+                                               
JOptionPane.showMessageDialog(this, "Error in creating the .wgt.",
+                                                               "Error", 
JOptionPane.ERROR_MESSAGE);
+                                               kSTextField.setText("");
+                                               kSPasswordField.setText("");
+                                               e.printStackTrace();
+                               }
+
+                               JOptionPane.showMessageDialog(this, "Signed " + 
widgetName.getText()
+                                               + " widget" + " saved.", 
"Success", JOptionPane.INFORMATION_MESSAGE);
+               }
+
+               /**
+                * Get the location of keystore file(This needs to be RSA with 
key length being 4096 bits,
+                * according to W3C widget digsig specification)
+                */
+               private void 
browseButton1MouseClicked(java.awt.event.MouseEvent evt) {
+                               JFileChooser chooser = new JFileChooser("");
+                               chooser.setMultiSelectionEnabled(false);
+                               
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+                               FileNameExtensionFilter filter = new 
FileNameExtensionFilter(".jks",
+                                               new String[]{"jks"});
+                               chooser.setFileFilter(filter);
+                               int returnVal = 
chooser.showOpenDialog((java.awt.Component) null);
+
+                               if(returnVal == JFileChooser.APPROVE_OPTION){
+
+                                               java.io.File inFile = 
chooser.getSelectedFile();
+                                               
kSTextField.setText(inFile.getAbsolutePath());
+                               }
+               }
+
+               /** Get the location of widget to be signed */
+               private void 
browseButton2MouseClicked(java.awt.event.MouseEvent evt) {
+                               JFileChooser chooser = new JFileChooser("");
+                               File absoluteWidgetFolder = null;
+                               jTextArea1.setText("");
+                               result = "";
+                               chooser.setMultiSelectionEnabled(false);
+                               
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+                               int returnVal = 
chooser.showOpenDialog((java.awt.Component) null);
+
+                               if(returnVal == JFileChooser.APPROVE_OPTION){
+                                               absoluteWidgetFolder = 
chooser.getSelectedFile();
+                                               
widgetTextField1.setText(absoluteWidgetFolder.getAbsolutePath());
+                                               try {
+                                                               //So the 
content that is to be signed for user to check.
+                                                               
jTextArea1.setText(listFilesForFolder(absoluteWidgetFolder));
+                                               }
+                                               catch(NullPointerException e) {
+                                                               
JOptionPane.showMessageDialog(this, "No files found to be signed.",
+                                                                               
"Error", JOptionPane.ERROR_MESSAGE);
+                                               }
+                               }
+               }
+
+               /**
+                * List the files and folders inside the widget folder 
according to the hierarchies
+                *
+                * @param absolutePath : to widget content folder
+                * @return result : list of names of files inside the widget 
folder
+                */
+               private String listFilesForFolder(File absolutePath) {
+                               String path = widgetTextField1.getText();
+                               File[] list = absolutePath.listFiles();
+
+                               for(final File fileEntry : list){
+
+                                               //remove files starting with 
'.'(hidden files) as those should not be included in widget
+                                               
if(!fileEntry.getName().startsWith(".")){
+                                                               String 
relativePath = new File(path).toURI()
+                                                                               
.relativize(fileEntry.toURI()).getPath();
+                                                               
if(fileEntry.isDirectory()){
+                                                                               
listFilesForFolder(fileEntry);
+                                                               }
+
+                                                               else{
+                                                                               
//author should not sign any other signature
+                                                                               
if(authorRadioButton1.isSelected()
+                                                                               
                && ((relativePath.contains("signature")) && (relativePath
+                                                                               
                .endsWith(".xml")))){
+
+                                                                               
}
+                                                                               
//distributor should not sign another distributors signature, but author
+                                                                               
else if(distributorRadioButton2.isSelected()
+                                                                               
                && ((relativePath.contains("signature")
+                                                                               
                && (relativePath.endsWith(".xml")) && (!relativePath
+                                                                               
                .contains("author"))))){
+
+                                                                               
}
+                                                                               
else{
+                                                                               
                result = result + relativePath + "\n";
+                                                                               
}
+                                                               }
+                                               }
+                               }
+                               return result;
+               }
+
+               /**
+                * @param args
+                *
+                */
+               private javax.swing.JRadioButton authorRadioButton1;
+               private javax.swing.JRadioButton distributorRadioButton2;
+               private javax.swing.JButton browseButton1;
+               private javax.swing.JButton browseButton2;
+               private javax.swing.ButtonGroup buttonGroup1;
+               private javax.swing.JTextField certificateAliasText;
+               private javax.swing.JScrollPane filesScrollPane;
+               private javax.swing.JLabel jLabel1;
+               private javax.swing.JLabel jLabel2;
+               private javax.swing.JLabel jLabel3;
+               private javax.swing.JLabel jLabel4;
+               private javax.swing.JLabel jLabel5;
+               private javax.swing.JLabel jLabel6;
+               private javax.swing.JLabel jLabel7;
+               private javax.swing.JLabel jLabel8;
+               private javax.swing.JLabel jLabel9;
+               private javax.swing.JLabel jLabel10;
+               private javax.swing.JPanel jPanel1;
+               private javax.swing.JTextArea jTextArea1;
+               private javax.swing.JTextField widgetName;
+               private javax.swing.JPasswordField kSPasswordField;
+               private javax.swing.JTextField kSTextField;
+               private javax.swing.JTextField pKAlias;
+               private javax.swing.JPasswordField pKPasswordField;
+               private javax.swing.JButton signButton;
+               private javax.swing.JTextField widgetTextField1;
+               private String result = "";
+}

Propchange: 
incubator/wookie/trunk/digsig-client/java/src/org/apache/wookie/digsig/client/ui/SignerJFrame.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/wookie/trunk/ivy.xml
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/ivy.xml?rev=1366035&r1=1366034&r2=1366035&view=diff
==============================================================================
--- incubator/wookie/trunk/ivy.xml (original)
+++ incubator/wookie/trunk/ivy.xml Thu Jul 26 15:12:25 2012
@@ -103,7 +103,9 @@
         <dependency org="org.apache.openjpa" name="openjpa-all" rev="2.0.0" 
conf="deploy->default">
         </dependency>
         <dependency org="commons-pool" name="commons-pool" rev="1.3" 
conf="deploy->default">
-               </dependency>        
+        </dependency>
+        <dependency org="org.apache.santuario" name="xmlsec" rev="1.5.2" 
conf="deploy->default">
+        </dependency>
 
         <!-- Libraries used in a development/test environment but not in 
deployment -->
         <dependency org="javax.servlet" name="servlet-api" rev="2.5" 
conf="runtime->default">
@@ -134,7 +136,18 @@
         
                <!-- DDLUtils Library -->
         <dependency org="org.apache.ddlutils" name="ddlutils" rev="1.0" 
conf="ddlutils->default">
+            <exclude module="xerces" />
+            <exclude module="xml-apis" />
         </dependency>
+        <!-- 
+        The two dependencies below are what are shipped with apache santuario.
+        Older versions of xerces seem to break the digsig client hence
+        why they are excluded in the ddlutil dependency above
+        -->
+        <!-- <dependency org="xerces" name="xercesImpl" rev="2.9.1" />-->
+        <!-- jar below is always replaced by 2.0.2 when ddlutils includes 
xerces --> 
+        <!-- <dependency org="xml-apis" name="xml-apis" rev="1.3.04" /> -->
+        
         <dependency org="log4j" name="log4j" rev="1.2.16" 
conf="ddlutils->default">
         </dependency>
         


Reply via email to