|
From: Pelle B. <pe...@us...> - 2004-03-20 17:30:10
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19634/src/java/org/neuclear/id Modified Files: SignedNamedCore.java Log Message: The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. Index: SignedNamedCore.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/SignedNamedCore.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** SignedNamedCore.java 3 Mar 2004 23:26:42 -0000 1.21 --- SignedNamedCore.java 20 Mar 2004 17:19:55 -0000 1.22 *************** *** 2,5 **** --- 2,8 ---- * $Id$ * $Log$ + * Revision 1.22 2004/03/20 17:19:55 pelle + * The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. + * * Revision 1.21 2004/03/03 23:26:42 pelle * Updated various tests to use the AbstractObjectCreationTest *************** *** 289,296 **** import org.neuclear.commons.LowLevelException; import org.neuclear.commons.crypto.CryptoTools; ! import org.neuclear.xml.xmlsec.InvalidSignatureException; ! import org.neuclear.xml.xmlsec.XMLSecTools; ! import org.neuclear.xml.xmlsec.XMLSecurityException; ! import org.neuclear.xml.xmlsec.XMLSignature; import java.security.PublicKey; --- 292,296 ---- import org.neuclear.commons.LowLevelException; import org.neuclear.commons.crypto.CryptoTools; ! import org.neuclear.xml.xmlsec.*; import java.security.PublicKey; *************** *** 302,305 **** --- 302,306 ---- * </p><p> * The SignedNamedCore has + * * @see NamedObjectReader * @see SignedNamedObject *************** *** 312,322 **** /** * SignedNamedCore for use in creating Identities for anonymous keys * @param pub */ ! public SignedNamedCore(final PublicKey pub){ ! this.digest=CryptoTools.encodeBase32(CryptoTools.digest(pub.getEncoded())); ! this.name="sha1:"+digest; ! this.timestamp=System.currentTimeMillis(); ! this.encoded=new String(pub.getEncoded()); this.signer = null;//new Identity(this,pub); } --- 313,324 ---- /** * SignedNamedCore for use in creating Identities for anonymous keys + * * @param pub */ ! public SignedNamedCore(final PublicKey pub) { ! this.digest = CryptoTools.encodeBase32(CryptoTools.digest(pub.getEncoded())); ! this.name = "sha1:" + digest; ! this.timestamp = System.currentTimeMillis(); ! this.encoded = new String(pub.getEncoded()); this.signer = null;//new Identity(this,pub); } *************** *** 324,339 **** /** * SignedNamedCore for creating SignedNamedObjects from Nymous sources * @param pub * @param encoded */ ! private SignedNamedCore(final PublicKey pub, final String encoded){ this.signer = new Identity(pub); ! this.digest=CryptoTools.encodeBase32(CryptoTools.digest(encoded.getBytes())); ! this.name=signer.getName()+"!"+digest; ! this.timestamp=System.currentTimeMillis(); ! this.encoded=encoded; } /** * SignedNamedCore for normal signed named objects * @param name * @param signer --- 326,344 ---- /** * SignedNamedCore for creating SignedNamedObjects from Nymous sources + * * @param pub * @param encoded */ ! private SignedNamedCore(final PublicKey pub, final String encoded) { this.signer = new Identity(pub); ! this.digest = CryptoTools.encodeBase32(CryptoTools.digest(encoded.getBytes())); ! this.name = signer.getName() + "!" + digest; ! this.timestamp = System.currentTimeMillis(); ! this.encoded = encoded; } + /** * SignedNamedCore for normal signed named objects + * * @param name * @param signer *************** *** 346,366 **** this.timestamp = timestamp.getTime(); this.encoded = encoded; ! this.digest=CryptoTools.encodeBase32(CryptoTools.digest(encoded.getBytes())); } ! private SignedNamedCore() { ! this.name="neu://"; ! this.signer=null;//new Identity(this,Identity.getRootPK()); final byte[] encoded = Identity.getRootPK().getEncoded(); ! this.digest=CryptoTools.encodeBase32(CryptoTools.digest(encoded)); ! this.timestamp=System.currentTimeMillis(); ! this.encoded=new String(encoded); } /** * Used to read and authenticate a SignedNamedCore. ! * ! * @param elem ! * @return * @throws InvalidNamedObjectException */ --- 351,371 ---- this.timestamp = timestamp.getTime(); this.encoded = encoded; ! this.digest = CryptoTools.encodeBase32(CryptoTools.digest(encoded.getBytes())); } ! private SignedNamedCore() { ! this.name = "neu://"; ! this.signer = null;//new Identity(this,Identity.getRootPK()); final byte[] encoded = Identity.getRootPK().getEncoded(); ! this.digest = CryptoTools.encodeBase32(CryptoTools.digest(encoded)); ! this.timestamp = System.currentTimeMillis(); ! this.encoded = new String(encoded); } /** * Used to read and authenticate a SignedNamedCore. ! * ! * @param elem ! * @return * @throws InvalidNamedObjectException */ *************** *** 413,419 **** private static SignedNamedCore readUnnamed(final Element elem) throws XMLSecurityException, InvalidNamedObjectException { try { ! final XMLSignature sig=XMLSecTools.getXMLSignature(elem); final PublicKey pub = sig.getSignersKey(); ! return new SignedNamedCore(pub,encodeElement(elem)); } catch (InvalidSignatureException e) { throw new InvalidNamedObjectException("Unnamed object failed Signature verification"); --- 418,424 ---- private static SignedNamedCore readUnnamed(final Element elem) throws XMLSecurityException, InvalidNamedObjectException { try { ! final XMLSignature sig = new EnvelopedSignature(elem); final PublicKey pub = sig.getSignersKey(); ! return new SignedNamedCore(pub, encodeElement(elem)); } catch (InvalidSignatureException e) { throw new InvalidNamedObjectException("Unnamed object failed Signature verification"); *************** *** 423,427 **** private static String getSignatoryName(final Element elem) throws InvalidNamedObjectException { final String name = elem.attributeValue(getNameAttrQName()); ! if (name==null) return null; return NSTools.normalizeNameURI(name); --- 428,432 ---- private static String getSignatoryName(final Element elem) throws InvalidNamedObjectException { final String name = elem.attributeValue(getNameAttrQName()); ! if (name == null) return null; return NSTools.normalizeNameURI(name); *************** *** 440,443 **** --- 445,449 ---- return DocumentHelper.createQName("name", NSTools.NS_NEUID); } + private static QName createQName(String name) { return DocumentHelper.createQName(name, NSTools.NS_NEUID); *************** *** 513,524 **** public final boolean equals(Object object) { ! if (object==this) return true; if (object instanceof SignedNamedCore) return true; ! return encoded.equals(((SignedNamedCore)object).getEncoded()); //To change body of overriden methods use Options | File Templates. } ! static Identity createSimpleIdentity(PublicKey pub){ ! return new Identity(new SignedNamedCore(pub),pub,null,null); } --- 519,531 ---- public final boolean equals(Object object) { ! if (object == this) return true; if (object instanceof SignedNamedCore) return true; ! return encoded.equals(((SignedNamedCore) object).getEncoded()); //To change body of overriden methods use Options | File Templates. } ! ! static Identity createSimpleIdentity(PublicKey pub) { ! return new Identity(new SignedNamedCore(pub), pub, null, null); } |