Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec
In directory sc8-pr-cvs1:/tmp/cvs-serv25308/src/java/org/neuclear/xml/xmlsec
Modified Files:
QuickEmbeddedSignature.java Reference.java SignatureInfo.java
SignedElement.java XMLSecTools.java XMLSignature.java
Log Message:
Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes.
Index: QuickEmbeddedSignature.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/QuickEmbeddedSignature.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** QuickEmbeddedSignature.java 10 Jan 2004 00:02:02 -0000 1.6
--- QuickEmbeddedSignature.java 13 Jan 2004 23:37:59 -0000 1.7
***************
*** 8,11 ****
--- 8,14 ----
* $Id$
* $Log$
+ * Revision 1.7 2004/01/13 23:37:59 pelle
+ * Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes.
+ *
* Revision 1.6 2004/01/10 00:02:02 pelle
* Implemented new Schema for Transfer*
***************
*** 136,141 ****
*/
public final class QuickEmbeddedSignature extends XMLSignature {
! public QuickEmbeddedSignature(final KeyPair keypair, final Element root, final String uri) throws XMLSecurityException, CryptoException {
! this(keypair.getPrivate(), root, uri);
final Element sig = getElement();
final KeyInfo key = new KeyInfo(keypair.getPublic());
--- 139,144 ----
*/
public final class QuickEmbeddedSignature extends XMLSignature {
! public QuickEmbeddedSignature(final KeyPair keypair, final Element root) throws XMLSecurityException, CryptoException {
! this(keypair.getPrivate(), root);
final Element sig = getElement();
final KeyInfo key = new KeyInfo(keypair.getPublic());
***************
*** 143,151 ****
}
! public QuickEmbeddedSignature(final PrivateKey key, final Element root, final String uri) throws XMLSecurityException, CryptoException {
super(getSignatureElement(root, key));
final Element sig = getElement();
! getSi().getReference().setDigest();
final byte[] canonicalizedSignedInfo = XMLSecTools.canonicalize(sig.element("SignedInfo"));
--- 146,154 ----
}
! public QuickEmbeddedSignature(final PrivateKey key, final Element root) throws XMLSecurityException, CryptoException {
super(getSignatureElement(root, key));
final Element sig = getElement();
! // getSi().getReference().setDigest();
final byte[] canonicalizedSignedInfo = XMLSecTools.canonicalize(sig.element("SignedInfo"));
***************
*** 153,161 ****
}
! public QuickEmbeddedSignature(final String name, final Signer signer, final Element root, final String uri) throws XMLSecurityException, UserCancellationException, NonExistingSignerException {
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);
--- 156,164 ----
}
! public QuickEmbeddedSignature(final String name, final Signer signer, final Element root) throws XMLSecurityException, UserCancellationException, NonExistingSignerException {
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);
Index: Reference.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/Reference.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Reference.java 10 Dec 2003 23:57:05 -0000 1.4
--- Reference.java 13 Jan 2004 23:37:59 -0000 1.5
***************
*** 1,4 ****
--- 1,7 ----
/* $Id$
* $Log$
+ * Revision 1.5 2004/01/13 23:37:59 pelle
+ * Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes.
+ *
* Revision 1.4 2003/12/10 23:57:05 pelle
* Did some cleaning up in the builders
***************
*** 117,132 ****
import org.neuclear.commons.Utility;
import org.neuclear.commons.crypto.Base64;
- import org.neuclear.commons.crypto.CryptoException;
import org.neuclear.commons.crypto.CryptoTools;
import org.neuclear.xml.XMLException;
import org.neuclear.xml.XMLTools;
import org.neuclear.xml.c14.Canonicalizer;
- import org.neuclear.xml.c14.CanonicalizerWithComments;
import org.neuclear.xml.c14.CanonicalizerWithoutSignature;
- import org.neuclear.xml.transforms.Transform;
! import java.io.File;
! import java.util.Iterator;
! import java.util.LinkedList;
import java.util.List;
--- 120,130 ----
import org.neuclear.commons.Utility;
import org.neuclear.commons.crypto.Base64;
import org.neuclear.commons.crypto.CryptoTools;
import org.neuclear.xml.XMLException;
import org.neuclear.xml.XMLTools;
import org.neuclear.xml.c14.Canonicalizer;
import org.neuclear.xml.c14.CanonicalizerWithoutSignature;
! import java.io.IOException;
import java.util.List;
***************
*** 134,218 ****
/**
! * Currently only RSA
*/
! public Reference(Element root, final String uri, final SignatureInfo si, final int sigtype) throws XMLException {
super(Reference.TAG_NAME);
! this.root = root;
! this.si = si;
! xmlsigType = sigtype;
! // findRefElement();
! if (root == null)
! loadReference(uri);
! if (getSigType() == XMLSIGTYPE_ENVELOPED)
! addTransform("http://www.w3.org/2000/09/xmldsig#enveloped-signature");
! else if (getSigType() == XMLSIGTYPE_ENVELOPING) {
! root = si.getSig().getElement().element("Object");
! // System.out.println(new String(canonicalizeReference()));// Just debugging here
}
! addTransform("http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
! final Element digMethod = XMLSecTools.createElementInSignatureSpace("DigestMethod");
! digMethod.addAttribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#sha1");
! addElement(digMethod);
! setDigest();
}
! public Reference(final Element elem, final SignatureInfo si) throws XMLSecurityException {
super(elem);
if (!elem.getQName().getName().equals(TAG_NAME))
throw new XMLSecurityException("Element: " + elem.getQualifiedName() + " is not a valid: " + XMLSecTools.NS_DS.getPrefix() + ":" + TAG_NAME);
! this.si = si;
! // Here we will try to get work out Root
! findRefElement();
! // TODO parse Transforms
}
! private void findRefElement() throws XMLSecurityException {
! final Element sigElement = si.getSig().getElement();
! final Element objectElem = sigElement.element(XMLSecTools.createQName("Object"));
!
! if (objectElem != null) { // Enveloping
! xmlsigType = XMLSIGTYPE_ENVELOPING;
! final List contents = objectElem.content();
if (contents.size() == 1)
! root = contents.get(0);
else
! root = contents;
! root = objectElem;
! } else if (sigElement.getParent() != null) { // Enveloped
! xmlsigType = XMLSIGTYPE_ENVELOPED;
! root = getElement().getDocument();
} else {// Detached
! xmlsigType = XMLSIGTYPE_DETACHED;
! loadReference(getElement().attributeValue("URI"));
}
}
! private void loadReference(final String refuri) throws XMLSecurityException {
if (Utility.isEmpty(refuri))
throw new XMLSecurityException("XMLSignature is not linked to Document");
try {
! root = XMLTools.loadDocument(new File(refuri)).getRootElement();
} catch (XMLException e) {
! XMLSecTools.rethrowException(e);
! }
! }
!
! private void addTransform(final String algorithm) throws XMLException {
! if (transforms == null) {
! transforms = new LinkedList();
! // if (transformsElement==null)
! transformsElement = XMLSecTools.createElementInSignatureSpace("Transforms");
! addElement(transformsElement);
}
-
- // Transform tran = TransformerFactory.make(algorithm);
- // if (tran == null) {
- // System.err.println("Couldn't resolve Transform: " + algorithm);
- // tran = new ClearTransform();
- // }
- // transforms.add(tran);
- transformsElement.addElement(XMLSecTools.createQName("Transform")).addAttribute("Algorithm", algorithm);
}
--- 132,224 ----
/**
! * Creates a Reference to a Element, with the given signature type:
! * <ul>
! * <li>
! * Reference.XMLSIGTYPE_ENVELOPED
! * <li>
! * Reference.XMLSIGTYPE_ENVELOPING
! * <ul>
*/
! public Reference(Element root, final int sigtype) throws XMLSecurityException {
super(Reference.TAG_NAME);
! try {
! final Canonicalizer canon;
! Element transformsElement = addElement("Transforms");
! if (sigtype == XMLSIGTYPE_ENVELOPED){
! canon=new CanonicalizerWithoutSignature();
! transformsElement.addElement(XMLSecTools.createQName("Transform")).addAttribute("Algorithm","http://www.w3.org/2000/09/xmldsig#enveloped-signature");
! }else {
! canon= new Canonicalizer();
! }
! transformsElement.addElement(XMLSecTools.createQName("Transform")).addAttribute("Algorithm","http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
! type=sigtype;
! final String id = root.attributeValue("id");
! if (!Utility.isEmpty(id))
! createAttribute("URI","#"+id);
!
! digest=createDigest(canon, root);
! addDigest();
! } catch (IOException e) {
! throw new XMLSecurityException(e);
}
! }
! private void addDigest() {
! addElement("DigestMethod").addAttribute(XMLSecTools.createQName("Algorithm"),"http://www.w3.org/2000/09/xmldsig#sha1");
! getElement().add(XMLSecTools.base64ToElement("DigestValue",digest.getBytes()));
}
! private static String createDigest(final Canonicalizer canon, Object root) throws IOException {
! return new String(Base64.encode(CryptoTools.digest(canon.canonicalize(root))));
! }
!
! public Reference(final String uri) throws XMLSecurityException {
! super(Reference.TAG_NAME);
! type=XMLSIGTYPE_DETACHED;
! try {
! createAttribute("URI",uri);
! digest=createDigest(new Canonicalizer(),loadReference(uri));
! addDigest();
! } catch (IOException e) {
! throw new XMLSecurityException(e);
! }
! }
! /**
! * Build this from XML Reference Element
! * @param elem
! * @throws XMLSecurityException
! */
! public Reference(final Element elem) throws XMLSecurityException {
super(elem);
+ type=0;
if (!elem.getQName().getName().equals(TAG_NAME))
throw new XMLSecurityException("Element: " + elem.getQualifiedName() + " is not a valid: " + XMLSecTools.NS_DS.getPrefix() + ":" + TAG_NAME);
! digest=new String(XMLSecTools.decodeBase64Element(getElement().element(XMLSecTools.createQName("DigestValue"))));
! // findRefElement(elem);
}
! private static Object findRefElement(Element elem) throws XMLSecurityException {
! if (elem.getParent() != null&&elem.getParent().getParent() != null&&elem.getParent().getParent().getParent() != null) { // Enveloped
! return elem.getDocument();
! } else if (elem.getParent() != null&&elem.getParent().getParent() != null&&elem.getParent().getParent().element("Object") != null) { // Enveloped
! final List contents = elem.getParent().getParent().element("Object").content();
if (contents.size() == 1)
! return contents.get(0);
else
! return contents;
} else {// Detached
! return loadReference(elem.attributeValue("URI"));
}
}
! private static Object loadReference(final String refuri) throws XMLSecurityException {
if (Utility.isEmpty(refuri))
throw new XMLSecurityException("XMLSignature is not linked to Document");
try {
! return XMLTools.loadDocument(refuri).getRootElement();
} catch (XMLException e) {
! throw new XMLSecurityException(e);
}
}
***************
*** 221,267 ****
* This returns the Digest
*
! * @return
! * @throws XMLSecurityException
*/
! public final byte[] getDigest() throws XMLSecurityException, CryptoException {
! final Element sv = (Element) getElement().element(XMLSecTools.createQName("DigestValue"));
! if (sv != null)
! return XMLSecTools.decodeBase64Element(sv);
! return null;
! }
!
! final void setDigest() throws XMLSecurityException {
! final Element sv = (Element) getElement().element(XMLSecTools.createQName("DigestValue"));
! final byte[] dig = generateRefenceDigest();
! if (sv == null)
! getElement().add(XMLSecTools.base64ToElement("DigestValue", dig));
! else
! sv.addText(Base64.encode(dig));
}
- //TODO Rewrite this bit
- private final Object performTransforms() {
- // Element subject = root;//(Element) root.clone();
- Object subject = root;
- final Iterator iter = transforms.iterator();
- while (iter.hasNext() && root != null) {
- final Transform transform = (Transform) iter.next();
- subject = transform.transformNode(subject);
- }
- return subject;
- }
private Canonicalizer getCanonicalizer() {
if (getSigType() == Reference.XMLSIGTYPE_ENVELOPED)
return new CanonicalizerWithoutSignature();
else if (c14nType == Canonicalizer.C14NTYPE_WITH_COMMENTS)
return new CanonicalizerWithComments();
return new Canonicalizer();
}
- private Object getReferenceElement() {
- return root;
- }
protected final byte[] canonicalizeReference() {
return XMLSecTools.canonicalize(getCanonicalizer(), getReferenceElement());
--- 227,250 ----
* This returns the Digest
*
! * @return
*/
! public final String getDigest() {
! return digest;
}
private Canonicalizer getCanonicalizer() {
+ /*
if (getSigType() == Reference.XMLSIGTYPE_ENVELOPED)
return new CanonicalizerWithoutSignature();
else if (c14nType == Canonicalizer.C14NTYPE_WITH_COMMENTS)
return new CanonicalizerWithComments();
+ */
return new Canonicalizer();
}
+
+ /*
protected final byte[] canonicalizeReference() {
return XMLSecTools.canonicalize(getCanonicalizer(), getReferenceElement());
***************
*** 276,294 ****
}
! public final String getTagName() {
! return TAG_NAME;
! }
!
! public final int getSigType() {
! return xmlsigType;
}
! private Object root;
! private SignatureInfo si;
!
private static final String TAG_NAME = "Reference";
- private List transforms;
- private Element transformsElement;
- private int xmlsigType = 0;
public final static int XMLSIGTYPE_ENVELOPED = 0;
--- 259,270 ----
}
! */
! public String getUri(){
! return getElement().attributeValue("URI");
}
+ private final String digest;
! private final int type;
private static final String TAG_NAME = "Reference";
public final static int XMLSIGTYPE_ENVELOPED = 0;
***************
*** 296,302 ****
public final static int XMLSIGTYPE_DETACHED = 2;
- private int c14nType;
-
-
- // private PublicKey pub;
}
--- 272,274 ----
Index: SignatureInfo.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/SignatureInfo.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SignatureInfo.java 11 Dec 2003 23:56:53 -0000 1.4
--- SignatureInfo.java 13 Jan 2004 23:37:59 -0000 1.5
***************
*** 1,4 ****
--- 1,7 ----
/* $Id$
* $Log$
+ * Revision 1.5 2004/01/13 23:37:59 pelle
+ * Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes.
+ *
* Revision 1.4 2003/12/11 23:56:53 pelle
* Trying to test the ReceiverServlet with cactus. Still no luck. Need to return a ElementProxy of some sort.
***************
*** 88,93 ****
import org.neuclear.xml.XMLException;
import org.neuclear.xml.c14.Canonicalizer;
- import org.neuclear.xml.c14.CanonicalizerWithComments;
- import org.neuclear.xml.c14.CanonicalizerWithoutSignature;
import java.security.NoSuchAlgorithmException;
--- 91,94 ----
***************
*** 113,117 ****
addElement(sm);
! ref = new Reference(root, uri, this, sigtype);
addElement(ref);
} catch (XMLException e) {
--- 114,118 ----
addElement(sm);
! ref = new Reference(root, sigtype);
addElement(ref);
} catch (XMLException e) {
***************
*** 130,134 ****
final Element refElem = elem.element(XMLSecTools.createQName("Reference"));
if (refElem != null)
! ref = new Reference(refElem, this);
//Check reference element if signature is enveloped
--- 131,135 ----
final Element refElem = elem.element(XMLSecTools.createQName("Reference"));
if (refElem != null)
! ref = new Reference(refElem);
//Check reference element if signature is enveloped
***************
*** 147,154 ****
final Canonicalizer getCanonicalizer() {
! if (ref.getSigType() == Reference.XMLSIGTYPE_ENVELOPED)
! return new CanonicalizerWithoutSignature();
! else if (c14nType == Canonicalizer.C14NTYPE_WITH_COMMENTS)
! return new CanonicalizerWithComments();
return new Canonicalizer();
}
--- 148,155 ----
final Canonicalizer getCanonicalizer() {
! // if (ref.getSigType() == Reference.XMLSIGTYPE_ENVELOPED)
! // return new CanonicalizerWithoutSignature();
! // else if (c14nType == Canonicalizer.C14NTYPE_WITH_COMMENTS)
! // return new CanonicalizerWithComments();
return new Canonicalizer();
}
Index: SignedElement.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/SignedElement.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** SignedElement.java 11 Jan 2004 00:39:19 -0000 1.8
--- SignedElement.java 13 Jan 2004 23:37:59 -0000 1.9
***************
*** 1,4 ****
--- 1,7 ----
/* $Id$
* $Log$
+ * Revision 1.9 2004/01/13 23:37:59 pelle
+ * Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes.
+ *
* Revision 1.8 2004/01/11 00:39:19 pelle
* Cleaned up the schemas even more they now all verifiy.
***************
*** 142,147 ****
import org.neuclear.commons.crypto.CryptoException;
import org.neuclear.commons.crypto.passphraseagents.UserCancellationException;
- import org.neuclear.commons.crypto.signers.Signer;
import org.neuclear.commons.crypto.signers.NonExistingSignerException;
import org.neuclear.xml.AbstractElementProxy;
import org.neuclear.xml.XMLException;
--- 145,150 ----
import org.neuclear.commons.crypto.CryptoException;
import org.neuclear.commons.crypto.passphraseagents.UserCancellationException;
import org.neuclear.commons.crypto.signers.NonExistingSignerException;
+ import org.neuclear.commons.crypto.signers.Signer;
import org.neuclear.xml.AbstractElementProxy;
import org.neuclear.xml.XMLException;
***************
*** 235,239 ****
public final void sign(final PrivateKey priv) throws XMLSecurityException, CryptoException {
preSign();
! sig = XMLSecTools.signElement(getURI(), getElement(), priv);
postSign();
}
--- 238,242 ----
public final void sign(final PrivateKey priv) throws XMLSecurityException, CryptoException {
preSign();
! sig = XMLSecTools.signElement(getElement(), priv);
postSign();
}
***************
*** 241,265 ****
public final void sign(final String name, final Signer signer) throws XMLSecurityException, NonExistingSignerException, UserCancellationException {
preSign();
! sig = XMLSecTools.signElement(getURI(), getElement(), name, signer);
postSign();
}
- /**
- * @return
- * @throws XMLSecurityException
- */
-
- public final byte[] getDigest() throws XMLSecurityException, CryptoException {
- if (sig == null)
- throw new XMLSecurityException("The object can not be verified as it doesnt contain a signature");
- return sig.getDigest();
- }
-
- /**
- * Returns the URI of the Element. This is used in the signing process.
- */
- public String getURI() throws XMLSecurityException {
- return "#" ;
- }
-
}
--- 244,250 ----
public final void sign(final String name, final Signer signer) throws XMLSecurityException, NonExistingSignerException, UserCancellationException {
preSign();
! sig = XMLSecTools.signElement( getElement(), name, signer);
postSign();
}
}
Index: XMLSecTools.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/XMLSecTools.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** XMLSecTools.java 19 Dec 2003 18:03:07 -0000 1.5
--- XMLSecTools.java 13 Jan 2004 23:37:59 -0000 1.6
***************
*** 1,4 ****
--- 1,7 ----
/* $Id$
* $Log$
+ * Revision 1.6 2004/01/13 23:37:59 pelle
+ * Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes.
+ *
* Revision 1.5 2003/12/19 18:03:07 pelle
* Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
***************
*** 183,193 ****
* Signs an element with a given keypair and envelopes the signature within.
*
- * @param baseURI Unique ID of the Element to be signed
* @param root Element to be signed
* @param keypair RSA/DSA KeyPair
* @throws XMLSecurityException
*/
! public static XMLSignature signElement(final String baseURI, final Element root, final KeyPair keypair) throws XMLSecurityException, CryptoException {//, KeyStoreException {
! final XMLSignature sig = new QuickEmbeddedSignature(keypair, root, baseURI);
return sig;
}
--- 186,195 ----
* Signs an element with a given keypair and envelopes the signature within.
*
* @param root Element to be signed
* @param keypair RSA/DSA KeyPair
* @throws XMLSecurityException
*/
! public static XMLSignature signElement(final Element root, final KeyPair keypair) throws XMLSecurityException, CryptoException {//, KeyStoreException {
! final XMLSignature sig = new QuickEmbeddedSignature(keypair, root);
return sig;
}
***************
*** 196,206 ****
* Signs an element with a given Private Key and "Envelopes" the signature within.
*
- * @param baseURI Unique ID of the Element to be signed
* @param root Element to be signed
* @param key RSA Private Key
* @throws XMLSecurityException
*/
! public static XMLSignature signElement(final String baseURI, final Element root, final PrivateKey key) throws XMLSecurityException, CryptoException {//, KeyStoreException {
! final XMLSignature sig = new QuickEmbeddedSignature(key, root, baseURI);
return sig;
}
--- 198,207 ----
* Signs an element with a given Private Key and "Envelopes" the signature within.
*
* @param root Element to be signed
* @param key RSA Private Key
* @throws XMLSecurityException
*/
! public static XMLSignature signElement( final Element root, final PrivateKey key) throws XMLSecurityException, CryptoException {//, KeyStoreException {
! final XMLSignature sig = new QuickEmbeddedSignature(key, root);
return sig;
}
***************
*** 209,213 ****
* Signs an element with a given Private Key and "Envelopes" the signature within.
*
- * @param baseURI Unique ID of the Element to be signed
* @param root Element to be signed
* @param name Alias of key to be used for signing
--- 210,213 ----
***************
*** 215,220 ****
* @throws XMLSecurityException
*/
! public static XMLSignature signElement(final String baseURI, final Element root, final String name, final org.neuclear.commons.crypto.signers.Signer signer) throws XMLSecurityException, NonExistingSignerException, UserCancellationException {//, KeyStoreException {
! final XMLSignature sig = new QuickEmbeddedSignature(name, signer, root, baseURI);
return sig;
}
--- 215,220 ----
* @throws XMLSecurityException
*/
! public static XMLSignature signElement( final Element root, final String name, final org.neuclear.commons.crypto.signers.Signer signer) throws XMLSecurityException, NonExistingSignerException, UserCancellationException {//, KeyStoreException {
! final XMLSignature sig = new QuickEmbeddedSignature(name, signer, root);
return sig;
}
Index: XMLSignature.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/XMLSignature.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** XMLSignature.java 8 Jan 2004 23:38:06 -0000 1.8
--- XMLSignature.java 13 Jan 2004 23:37:59 -0000 1.9
***************
*** 1,4 ****
--- 1,7 ----
/* $Id$
* $Log$
+ * Revision 1.9 2004/01/13 23:37:59 pelle
+ * Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes.
+ *
* Revision 1.8 2004/01/08 23:38:06 pelle
* XMLSignature can now give you the Signing key and the id of the signer.
***************
*** 280,284 ****
if (ki==null){
final Element keyInfoElem = getElement().element(XMLSecTools.createQName("KeyInfo"));
! if (keyInfoElem == null)
ki=new KeyInfo(keyInfoElem);
}
--- 283,287 ----
if (ki==null){
final Element keyInfoElem = getElement().element(XMLSecTools.createQName("KeyInfo"));
! if (keyInfoElem != null)
ki=new KeyInfo(keyInfoElem);
}
***************
*** 290,295 ****
try {
! if (!si.getReference().verifyReferences())
! return false;
final byte[] sig = getSignature();
final byte[] cansi = si.canonicalize();
--- 293,298 ----
try {
! // if (!si.getReference().verifyReferences())
! // return false;
final byte[] sig = getSignature();
final byte[] cansi = si.canonicalize();
***************
*** 303,310 ****
try {
! if (!si.getReference().verifyReferences()) {
! // System.err.println("XMLSIG: References didnt match up");
! return false;
! }
final byte[] sig = getSignature();
final byte[] cansi = si.canonicalize();
--- 306,313 ----
try {
! // if (!si.getReference().verifyReferences()) {
! //// System.err.println("XMLSIG: References didnt match up");
! // return false;
! // }
final byte[] sig = getSignature();
final byte[] cansi = si.canonicalize();
***************
*** 320,333 ****
! public final String getTagName() {
! return TAG_NAME;
! }
!
! public final byte[] getDigest() throws XMLSecurityException, CryptoException {
! if (si == null)
! throw new XMLSecurityException("The object can not be verified as it doesnt contain a signature");
! return si.getReference().getDigest();
! }
!
protected final SignatureInfo getSi() {
return si;
--- 323,327 ----
!
protected final SignatureInfo getSi() {
return si;
|