|
From: <pe...@us...> - 2004-01-10 00:02:05
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec
In directory sc8-pr-cvs1:/tmp/cvs-serv23382/src/java/org/neuclear/xml/xmlsec
Modified Files:
KeyInfo.java QuickEmbeddedSignature.java
Log Message:
Implemented new Schema for Transfer*
Working on it for Exchange*, so far all Receipts are implemented.
Added SignedNamedDocument which is a generic SignedNamedObject that works with all Signed XML.
Changed SignedNamedObject.getDigest() from byte array to String.
The whole malarchy in neuclear-pay does not build yet. The refactoring is a big job, but getting there.
Index: KeyInfo.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/KeyInfo.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** KeyInfo.java 8 Jan 2004 23:38:06 -0000 1.7
--- KeyInfo.java 10 Jan 2004 00:02:02 -0000 1.8
***************
*** 4,20 ****
import org.dom4j.Element;
- import org.neuclear.commons.crypto.CryptoException;
import org.neuclear.commons.crypto.Base64;
import org.neuclear.commons.crypto.CryptoTools;
import org.neuclear.commons.crypto.keyresolvers.KeyResolverFactory;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
- import java.security.cert.Certificate;
- import java.security.cert.X509Certificate;
import java.security.cert.CertificateEncodingException;
- import java.security.cert.CertificateFactory;
import java.security.cert.CertificateException;
import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPublicKey;
--- 4,19 ----
import org.dom4j.Element;
import org.neuclear.commons.crypto.Base64;
import org.neuclear.commons.crypto.CryptoTools;
import org.neuclear.commons.crypto.keyresolvers.KeyResolverFactory;
+ import java.io.ByteArrayInputStream;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
+ import java.security.cert.CertificateFactory;
+ import java.security.cert.X509Certificate;
import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPublicKey;
***************
*** 24,28 ****
import java.security.spec.RSAPublicKeySpec;
import java.util.Iterator;
- import java.io.ByteArrayInputStream;
public final class KeyInfo extends AbstractXMLSigElement {
--- 23,26 ----
***************
*** 69,74 ****
--- 67,80 ----
}
}
+ public KeyInfo(final PublicKey pub, final String name){
+ this(pub);
+ appendKeyName(name);
+ }
public KeyInfo(final String name) {
super(TAG_NAME);
+ appendKeyName(name);
+ }
+
+ private void appendKeyName(final String name) {
final Element kv = XMLSecTools.createElementInSignatureSpace("KeyName");
kv.addText(name);
Index: QuickEmbeddedSignature.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/QuickEmbeddedSignature.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** QuickEmbeddedSignature.java 7 Jan 2004 23:11:51 -0000 1.5
--- QuickEmbeddedSignature.java 10 Jan 2004 00:02:02 -0000 1.6
***************
*** 8,11 ****
--- 8,18 ----
* $Id$
* $Log$
+ * Revision 1.6 2004/01/10 00:02:02 pelle
+ * Implemented new Schema for Transfer*
+ * Working on it for Exchange*, so far all Receipts are implemented.
+ * Added SignedNamedDocument which is a generic SignedNamedObject that works with all Signed XML.
+ * Changed SignedNamedObject.getDigest() from byte array to String.
+ * The whole malarchy in neuclear-pay does not build yet. The refactoring is a big job, but getting there.
+ *
* Revision 1.5 2004/01/07 23:11:51 pelle
* XMLSig now has various added features:
***************
*** 110,130 ****
*/
- import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
- import org.neuclear.commons.crypto.Base64;
- import org.neuclear.commons.crypto.CryptoTools;
- import org.neuclear.commons.crypto.signers.Signer;
- import org.neuclear.commons.crypto.signers.NonExistingSignerException;
import org.neuclear.commons.crypto.CryptoException;
import org.neuclear.commons.crypto.passphraseagents.UserCancellationException;
import java.security.KeyPair;
- import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.interfaces.DSAPrivateKey;
import java.security.interfaces.RSAPrivateKey;
- import java.util.Date;
/**
--- 117,134 ----
*/
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.neuclear.commons.crypto.CryptoException;
+ import org.neuclear.commons.crypto.CryptoTools;
import org.neuclear.commons.crypto.passphraseagents.UserCancellationException;
+ import org.neuclear.commons.crypto.signers.NonExistingSignerException;
+ import org.neuclear.commons.crypto.signers.PublicKeySource;
+ import org.neuclear.commons.crypto.signers.Signer;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.interfaces.DSAPrivateKey;
import java.security.interfaces.RSAPrivateKey;
/**
***************
*** 152,158 ****
super(getSignatureElement(root,signer.getKeyType(name)));
final Element sig = getElement();
- addElement(new KeyInfo(name)); // Add the signers name
getSi().getReference().setDigest();
final byte[] canonicalizedSignedInfo = XMLSecTools.canonicalize(sig.element("SignedInfo"));
--- 156,166 ----
super(getSignatureElement(root,signer.getKeyType(name)));
final Element sig = getElement();
getSi().getReference().setDigest();
+ if (signer instanceof PublicKeySource){
+ final KeyInfo key = new KeyInfo(((PublicKeySource)signer).getPublicKey(name),name);
+ sig.add(key.getElement());
+ } else
+ addElement(new KeyInfo(name)); // Add the signers name
final byte[] canonicalizedSignedInfo = XMLSecTools.canonicalize(sig.element("SignedInfo"));
***************
*** 225,229 ****
! public static void main(final String[] args) {
try {
final KeyPair kp = CryptoTools.createKeyPair();
--- 233,237 ----
! /* public static void main(final String[] args) {
try {
final KeyPair kp = CryptoTools.createKeyPair();
***************
*** 258,262 ****
e.printStackTrace(); //TODO Handle exception
}
-
}
}
--- 266,270 ----
e.printStackTrace(); //TODO Handle exception
}
}
+ */
}
|