|
From: <pe...@us...> - 2003-12-19 18:03:37
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/builders
In directory sc8-pr-cvs1:/tmp/cvs-serv5310/src/java/org/neuclear/id/builders
Modified Files:
IdentityBuilder.java NamedObjectBuilder.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: IdentityBuilder.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/builders/IdentityBuilder.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** IdentityBuilder.java 18 Dec 2003 17:40:19 -0000 1.15
--- IdentityBuilder.java 19 Dec 2003 18:03:34 -0000 1.16
***************
*** 2,5 ****
--- 2,13 ----
* $Id$
* $Log$
+ * Revision 1.16 2003/12/19 18:03:34 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.15 2003/12/18 17:40:19 pelle
* You can now create keys that get stored with a X509 certificate in the keystore. These can be saved as well.
***************
*** 212,215 ****
--- 220,224 ----
import org.neuclear.id.NSTools;
import org.neuclear.id.Identity;
+ import org.neuclear.id.InvalidNamedObjectException;
import org.neuclear.xml.xmlsec.XMLSecTools;
import org.neuclear.xml.xmlsec.XMLSecurityException;
***************
*** 230,234 ****
*/
! public IdentityBuilder(final String name, final PublicKey allow, final String repository, final String signer, final String logger, final String receiver) throws NeuClearException {
this(createNEUIDQName(TAGNAME), name, allow, repository, signer, logger, receiver);
}
--- 239,243 ----
*/
! public IdentityBuilder(final String name, final PublicKey allow, final String repository, final String signer, final String logger, final String receiver) throws InvalidNamedObjectException {
this(createNEUIDQName(TAGNAME), name, allow, repository, signer, logger, receiver);
}
***************
*** 244,248 ****
* @param receiver URL of default receiver for namespace
*/
! protected IdentityBuilder(final QName tag, final String name, final PublicKey allow, final String repository, final String signer, final String logger, final String receiver) throws NeuClearException {
super(name, tag);
--- 253,257 ----
* @param receiver URL of default receiver for namespace
*/
! protected IdentityBuilder(final QName tag, final String name, final PublicKey allow, final String repository, final String signer, final String logger, final String receiver) throws InvalidNamedObjectException {
super(name, tag);
Index: NamedObjectBuilder.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/builders/NamedObjectBuilder.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** NamedObjectBuilder.java 18 Dec 2003 17:40:19 -0000 1.19
--- NamedObjectBuilder.java 19 Dec 2003 18:03:34 -0000 1.20
***************
*** 2,5 ****
--- 2,13 ----
* $Id$
* $Log$
+ * Revision 1.20 2003/12/19 18:03:34 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.19 2003/12/18 17:40:19 pelle
* You can now create keys that get stored with a X509 certificate in the keystore. These can be saved as well.
***************
*** 211,219 ****
import org.neuclear.commons.Utility;
import org.neuclear.commons.crypto.signers.Signer;
import org.neuclear.commons.time.TimeTools;
! import org.neuclear.id.Identity;
! import org.neuclear.id.NSTools;
! import org.neuclear.id.Named;
! import org.neuclear.id.SignedNamedObject;
import org.neuclear.id.resolver.NSResolver;
import org.neuclear.id.verifier.VerifyingReader;
--- 219,226 ----
import org.neuclear.commons.Utility;
import org.neuclear.commons.crypto.signers.Signer;
+ import org.neuclear.commons.crypto.signers.NonExistingSignerException;
+ import org.neuclear.commons.crypto.passphraseagents.UserCancellationException;
import org.neuclear.commons.time.TimeTools;
! import org.neuclear.id.*;
import org.neuclear.id.resolver.NSResolver;
import org.neuclear.id.verifier.VerifyingReader;
***************
*** 223,226 ****
--- 230,234 ----
import java.sql.Timestamp;
+ import java.text.ParseException;
/**
***************
*** 228,232 ****
*/
public class NamedObjectBuilder extends SignedElement implements Named, Cloneable {
! protected NamedObjectBuilder(final String name, final String tagName, final String prefix, final String nsURI) throws NeuClearException {
super(tagName, prefix, nsURI);
createDocument();
--- 236,240 ----
*/
public class NamedObjectBuilder extends SignedElement implements Named, Cloneable {
! protected NamedObjectBuilder(final String name, final String tagName, final String prefix, final String nsURI) throws InvalidNamedObjectException {
super(tagName, prefix, nsURI);
createDocument();
***************
*** 234,238 ****
}
! protected NamedObjectBuilder(final String name, final String tagName, final Namespace ns) throws NeuClearException {
super(tagName, ns);
createDocument();
--- 242,246 ----
}
! protected NamedObjectBuilder(final String name, final String tagName, final Namespace ns) throws InvalidNamedObjectException {
super(tagName, ns);
createDocument();
***************
*** 240,244 ****
}
! protected NamedObjectBuilder(final String name, final String tagName) throws NeuClearException {
super(tagName, NSTools.NS_NEUID);
createDocument();
--- 248,252 ----
}
! protected NamedObjectBuilder(final String name, final String tagName) throws InvalidNamedObjectException {
super(tagName, NSTools.NS_NEUID);
createDocument();
***************
*** 246,250 ****
}
! protected NamedObjectBuilder(final String name, final QName qname) throws NeuClearException {
super(qname);
createDocument();
--- 254,258 ----
}
! protected NamedObjectBuilder(final String name, final QName qname) throws InvalidNamedObjectException {
super(qname);
createDocument();
***************
*** 252,272 ****
}
! public NamedObjectBuilder(final Element elem) throws XMLSecurityException {
super(elem);
}
! public NamedObjectBuilder(final Document doc) throws XMLSecurityException {
super(doc.getRootElement());
}
! final public SignedNamedObject sign(final Signer signer) throws NeuClearException, XMLException {
! sign(getSignatory().getName(), signer); //Sign with parent key
! return convert();
}
! final public SignedNamedObject convert() throws NeuClearException, XMLException {
return VerifyingReader.getInstance().read(getElement());
--- 260,287 ----
}
! public NamedObjectBuilder(final Element elem) throws XMLSecurityException,InvalidNamedObjectException {
super(elem);
+ final String name=getName();
+ if (!NSTools.isValidName(name))
+ throw new InvalidNamedObjectException(name);
}
! public NamedObjectBuilder(final Document doc) throws XMLSecurityException,InvalidNamedObjectException {
super(doc.getRootElement());
}
! final public SignedNamedObject sign(final Signer signer) throws InvalidNamedObjectException, NonExistingSignerException, UserCancellationException, NameResolutionException {
! try {
! sign(getSignatory().getName(), signer); //Sign with parent key
! return convert();
! } catch (XMLSecurityException e) {
! throw new InvalidNamedObjectException(getName(),e);
! }
}
! final public SignedNamedObject convert() throws InvalidNamedObjectException, NameResolutionException{
return VerifyingReader.getInstance().read(getElement());
***************
*** 279,283 ****
*/
public final String getName() {
! return getElement().attributeValue(getNameAttrQName());
}
--- 294,302 ----
*/
public final String getName() {
! QName q=getNameAttrQName();
! if (getElement()!=null&&getElement().attribute(q)!=null)
! return getElement().attributeValue(q);
! return null;
!
}
***************
*** 287,295 ****
* @return Parent Name
*/
! public final String getLocalName() throws NeuClearException {
return NSTools.getLocalName(getName());
}
! private void setName(final String name) throws NeuClearException {
getElement().addAttribute(getNameAttrQName(), NSTools.normalizeNameURI(name));
}
--- 306,314 ----
* @return Parent Name
*/
! public final String getLocalName() throws InvalidNamedObjectException {
return NSTools.getLocalName(getName());
}
! private void setName(final String name) throws InvalidNamedObjectException {
getElement().addAttribute(getNameAttrQName(), NSTools.normalizeNameURI(name));
}
***************
*** 414,423 ****
*/
! public final Timestamp getTimeStamp() throws NeuClearException {
final String timeString = getElement().attributeValue(DocumentHelper.createQName("timestamp", NSTools.NS_NEUID));
if (isSigned() && !Utility.isEmpty(timeString)) {
try {
return TimeTools.parseTimeStamp(timeString);
! } catch (NeuClearException e) {
return null;
}
--- 433,442 ----
*/
! public final Timestamp getTimeStamp() {
final String timeString = getElement().attributeValue(DocumentHelper.createQName("timestamp", NSTools.NS_NEUID));
if (isSigned() && !Utility.isEmpty(timeString)) {
try {
return TimeTools.parseTimeStamp(timeString);
! } catch (ParseException e) {
return null;
}
***************
*** 430,434 ****
! public final Identity getSignatory() throws NeuClearException {
return NSResolver.resolveIdentity(NSTools.getSignatoryURI(getName()));
}
--- 449,453 ----
! public final Identity getSignatory() throws InvalidNamedObjectException, NameResolutionException {
return NSResolver.resolveIdentity(NSTools.getSignatoryURI(getName()));
}
***************
*** 492,496 ****
DocumentHelper.createDocument(elem);
return new NamedObjectBuilder(elem);
! } catch (XMLSecurityException e) {
throw new RuntimeException(e);
}
--- 511,515 ----
DocumentHelper.createDocument(elem);
return new NamedObjectBuilder(elem);
! } catch (Exception e) {
throw new RuntimeException(e);
}
|