Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec
In directory sc8-pr-cvs1:/tmp/cvs-serv5237/src/java/org/neuclear/xml/xmlsec
Modified Files:
KeyInfo.java QuickEmbeddedSignature.java SignedElement.java
XMLSecTools.java XMLSignature.java
Log Message:
Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
- For most cases the main exception to worry about now is InvalidNamedObjectException.
- Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
runtime exception.
- Source and Store patterns each now have their own exceptions that generalizes the various physical
exceptions that can happen in that area.
Index: KeyInfo.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/KeyInfo.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** KeyInfo.java 11 Dec 2003 23:56:53 -0000 1.4
--- KeyInfo.java 19 Dec 2003 18:03:07 -0000 1.5
***************
*** 73,77 ****
*/
public final PublicKey getPublicKey()
! throws XMLSecurityException, CryptoException {
if (pub == null) {
try {
--- 73,77 ----
*/
public final PublicKey getPublicKey()
! throws XMLSecurityException {
if (pub == null) {
try {
Index: QuickEmbeddedSignature.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/QuickEmbeddedSignature.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** QuickEmbeddedSignature.java 21 Nov 2003 04:44:31 -0000 1.3
--- QuickEmbeddedSignature.java 19 Dec 2003 18:03:07 -0000 1.4
***************
*** 8,11 ****
--- 8,19 ----
* $Id$
* $Log$
+ * Revision 1.4 2003/12/19 18:03:07 pelle
+ * Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
+ * - For most cases the main exception to worry about now is InvalidNamedObjectException.
+ * - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
+ * runtime exception.
+ * - Source and Store patterns each now have their own exceptions that generalizes the various physical
+ * exceptions that can happen in that area.
+ *
* Revision 1.3 2003/11/21 04:44:31 pelle
* EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
***************
*** 102,106 ****
--- 110,116 ----
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;
***************
*** 132,136 ****
}
! public QuickEmbeddedSignature(final String name, final Signer signer, final Element root, final String uri) throws XMLSecurityException, CryptoException {
super(getSignatureElement(root,signer.getKeyType(name)));
final Element sig = getElement();
--- 142,146 ----
}
! 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();
Index: SignedElement.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/SignedElement.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** SignedElement.java 10 Dec 2003 23:57:05 -0000 1.5
--- SignedElement.java 19 Dec 2003 18:03:07 -0000 1.6
***************
*** 1,4 ****
--- 1,12 ----
/* $Id$
* $Log$
+ * Revision 1.6 2003/12/19 18:03:07 pelle
+ * Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
+ * - For most cases the main exception to worry about now is InvalidNamedObjectException.
+ * - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
+ * runtime exception.
+ * - Source and Store patterns each now have their own exceptions that generalizes the various physical
+ * exceptions that can happen in that area.
+ *
* Revision 1.5 2003/12/10 23:57:05 pelle
* Did some cleaning up in the builders
***************
*** 114,118 ****
--- 122,128 ----
import org.dom4j.QName;
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;
***************
*** 202,206 ****
}
! public final void sign(final String name, final Signer signer) throws XMLSecurityException, CryptoException {
preSign();
sig = XMLSecTools.signElement(getURI(), getElement(), name, signer);
--- 212,216 ----
}
! public final void sign(final String name, final Signer signer) throws XMLSecurityException, NonExistingSignerException, UserCancellationException {
preSign();
sig = XMLSecTools.signElement(getURI(), getElement(), name, signer);
Index: XMLSecTools.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/XMLSecTools.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** XMLSecTools.java 21 Nov 2003 04:44:31 -0000 1.4
--- XMLSecTools.java 19 Dec 2003 18:03:07 -0000 1.5
***************
*** 1,4 ****
--- 1,12 ----
/* $Id$
* $Log$
+ * 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:
+ * - For most cases the main exception to worry about now is InvalidNamedObjectException.
+ * - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
+ * runtime exception.
+ * - Source and Store patterns each now have their own exceptions that generalizes the various physical
+ * exceptions that can happen in that area.
+ *
* Revision 1.4 2003/11/21 04:44:31 pelle
* EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
***************
*** 142,145 ****
--- 150,155 ----
import org.neuclear.commons.crypto.Base64;
import org.neuclear.commons.crypto.CryptoException;
+ import org.neuclear.commons.crypto.passphraseagents.UserCancellationException;
+ import org.neuclear.commons.crypto.signers.NonExistingSignerException;
import org.neuclear.xml.XMLException;
import org.neuclear.xml.c14.Canonicalizer;
***************
*** 205,209 ****
* @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, CryptoException {//, KeyStoreException {
final XMLSignature sig = new QuickEmbeddedSignature(name, signer, root, baseURI);
return sig;
--- 215,219 ----
* @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;
***************
*** 312,316 ****
* @throws XMLSecurityException
*/
! public static boolean verifySignature(final Element elem, final PublicKey pub) throws XMLSecurityException, CryptoException {
final XMLSignature sig = getXMLSignature(elem);
return sig.verifySignature(pub);
--- 322,326 ----
* @throws XMLSecurityException
*/
! public static boolean verifySignature(final Element elem, final PublicKey pub) throws XMLSecurityException {
final XMLSignature sig = getXMLSignature(elem);
return sig.verifySignature(pub);
***************
*** 325,329 ****
* @throws XMLSecurityException
*/
! public static boolean verifySignature(final Element elem, final PublicKey[] pubs) throws XMLSecurityException, CryptoException {
final XMLSignature sig = getXMLSignature(elem);
return sig.verifySignature(pubs);
--- 335,339 ----
* @throws XMLSecurityException
*/
! public static boolean verifySignature(final Element elem, final PublicKey[] pubs) throws XMLSecurityException {
final XMLSignature sig = getXMLSignature(elem);
return sig.verifySignature(pubs);
***************
*** 467,472 ****
* @return
*/
! public static BigInteger decodeBigIntegerFromElement(final Element element)
! throws CryptoException {
return new BigInteger(1, decodeBase64Element(element));
}
--- 477,481 ----
* @return
*/
! public static BigInteger decodeBigIntegerFromElement(final Element element) throws XMLSecurityException {
return new BigInteger(1, decodeBase64Element(element));
}
***************
*** 511,515 ****
* @return
*/
! public static byte[] decodeBase64Element(final Element element) throws CryptoException {
final Iterator iter = element.nodeIterator();
--- 520,524 ----
* @return
*/
! public static byte[] decodeBase64Element(final Element element) throws XMLSecurityException {
final Iterator iter = element.nodeIterator();
***************
*** 526,530 ****
}
! return Base64.decode(sb.toString());
}
--- 535,543 ----
}
! try {
! return Base64.decode(sb.toString());
! } catch (CryptoException e) {
! throw new XMLSecurityException(e);
! }
}
Index: XMLSignature.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/XMLSignature.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** XMLSignature.java 11 Dec 2003 23:56:53 -0000 1.5
--- XMLSignature.java 19 Dec 2003 18:03:07 -0000 1.6
***************
*** 1,4 ****
--- 1,12 ----
/* $Id$
* $Log$
+ * Revision 1.6 2003/12/19 18:03:07 pelle
+ * Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
+ * - For most cases the main exception to worry about now is InvalidNamedObjectException.
+ * - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
+ * runtime exception.
+ * - Source and Store patterns each now have their own exceptions that generalizes the various physical
+ * exceptions that can happen in that area.
+ *
* Revision 1.5 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.
***************
*** 246,250 ****
}
! public final boolean verifySignature() throws XMLSecurityException, CryptoException {
final Element keyInfoElem = getElement().element(XMLSecTools.createQName("KeyInfo"));
if (keyInfoElem == null)
--- 254,258 ----
}
! public final boolean verifySignature() throws XMLSecurityException {
final Element keyInfoElem = getElement().element(XMLSecTools.createQName("KeyInfo"));
if (keyInfoElem == null)
***************
*** 255,280 ****
}
! public final boolean verifySignature(final PublicKey pk) throws XMLSecurityException, CryptoException {
! if (!si.getReference().verifyReferences())
! return false;
! final byte[] sig = getSignature();
! final byte[] cansi = si.canonicalize();
! return CryptoTools.verify(pk, cansi, sig);
}
! public final boolean verifySignature(final PublicKey[] pks) throws XMLSecurityException, CryptoException {
! if (!si.getReference().verifyReferences()) {
// System.err.println("XMLSIG: References didnt match up");
return false;
}
- final byte[] sig = getSignature();
- final byte[] cansi = si.canonicalize();
- for (int i = 0; i < pks.length; i++)
- if (CryptoTools.verify(pks[i], cansi, sig))
- return true;
- // System.err.println("XMLSIG: Signature didnt Verify");
- return false;
}
--- 263,296 ----
}
! public final boolean verifySignature(final PublicKey pk) throws XMLSecurityException {
! try {
! if (!si.getReference().verifyReferences())
! return false;
! final byte[] sig = getSignature();
! final byte[] cansi = si.canonicalize();
! return CryptoTools.verify(pk, cansi, sig);
! } catch (CryptoException e) {
! throw new XMLSecurityException(e);
! }
}
! public final boolean verifySignature(final PublicKey[] pks) throws XMLSecurityException {
! try {
! if (!si.getReference().verifyReferences()) {
// System.err.println("XMLSIG: References didnt match up");
+ return false;
+ }
+ final byte[] sig = getSignature();
+ final byte[] cansi = si.canonicalize();
+ for (int i = 0; i < pks.length; i++)
+ if (CryptoTools.verify(pks[i], cansi, sig))
+ return true;
+ // System.err.println("XMLSIG: Signature didnt Verify");
return false;
+ } catch (CryptoException e) {
+ throw new XMLSecurityException(e);
}
}
|