Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/builders
In directory sc8-pr-cvs1:/tmp/cvs-serv13078/src/java/org/neuclear/id/builders
Modified Files:
EmbeddedSignedObjectBuilder.java NamedObjectBuilder.java
SignatureRequestBuilder.java
Added Files:
Builder.java
Log Message:
Completed all the builders and contracts.
Added a new abstract Value class to contain either an amount or a list of serial numbers.
Now ready to finish off the AssetControllers.
--- NEW FILE: Builder.java ---
package org.neuclear.id.builders;
import org.neuclear.xml.xmlsec.SignedElement;
import org.neuclear.xml.xmlsec.XMLSecurityException;
import org.neuclear.id.SignedNamedObject;
import org.neuclear.id.InvalidNamedObjectException;
import org.neuclear.id.NameResolutionException;
import org.neuclear.id.NSTools;
import org.neuclear.id.verifier.VerifyingReader;
import org.neuclear.commons.time.TimeTools;
import org.dom4j.QName;
import org.dom4j.Namespace;
import org.dom4j.Element;
import org.dom4j.DocumentHelper;
/**
* Created by IntelliJ IDEA.
* User: pelleb
* Date: Jan 10, 2004
* Time: 10:21:48 PM
* To change this template use Options | File Templates.
*/
public class Builder extends SignedElement {
public Builder(final QName qname) {
super(qname);
}
public Builder(final String name, final Namespace ns) {
super(name, ns);
}
public Builder(final Element elem) throws XMLSecurityException {
super(elem);
}
public Builder(final String name, final String prefix, final String nsURI) {
super(name, prefix, nsURI);
}
final public SignedNamedObject convert() throws InvalidNamedObjectException, NameResolutionException{
return VerifyingReader.getInstance().read(getElement());
}
/**
* Sign NamedObject using given PrivateKey. This also adds a timestamp to the root element prior to signing
*/
protected final void preSign() throws XMLSecurityException {
// We need to timestamp it before we sign it
getElement().addAttribute(DocumentHelper.createQName("timestamp", NSTools.NS_NEUID), TimeTools.createTimeStamp());
}
}
Index: EmbeddedSignedObjectBuilder.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/builders/EmbeddedSignedObjectBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** EmbeddedSignedObjectBuilder.java 11 Jan 2004 00:39:14 -0000 1.1
--- EmbeddedSignedObjectBuilder.java 12 Jan 2004 22:39:26 -0000 1.2
***************
*** 4,7 ****
--- 4,12 ----
import org.neuclear.xml.xmlsec.XMLSecurityException;
import org.neuclear.id.SignedNamedObject;
+ import org.neuclear.id.NameResolutionException;
+ import org.neuclear.id.InvalidNamedObjectException;
+ import org.neuclear.commons.crypto.signers.Signer;
+ import org.neuclear.commons.crypto.signers.NonExistingSignerException;
+ import org.neuclear.commons.crypto.passphraseagents.UserCancellationException;
import org.dom4j.QName;
import org.dom4j.DocumentHelper;
***************
*** 15,19 ****
* To change this template use Options | File Templates.
*/
! public class EmbeddedSignedObjectBuilder extends SignedElement {
public EmbeddedSignedObjectBuilder(final QName qname, final SignedNamedObject embedded) {
super(qname);
--- 20,24 ----
* To change this template use Options | File Templates.
*/
! public class EmbeddedSignedObjectBuilder extends Builder {
public EmbeddedSignedObjectBuilder(final QName qname, final SignedNamedObject embedded) {
super(qname);
***************
*** 28,30 ****
--- 33,48 ----
return "#"; //To change body of implemented methods use Options | File Templates.
}
+
+ public final SignedNamedObject convert(String name,Signer signer) throws NameResolutionException, InvalidNamedObjectException {
+ try {
+ sign(name,signer);
+ } catch (XMLSecurityException e) {
+ throw new InvalidNamedObjectException("Problem in XML Sig",e);
+ } catch (NonExistingSignerException e) {
+ throw new InvalidNamedObjectException("Can not Sign",e);
+ } catch (UserCancellationException e) {
+ throw new InvalidNamedObjectException("User Cancelled Signing",e);
+ }
+ return convert();
+ }
}
Index: NamedObjectBuilder.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/builders/NamedObjectBuilder.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** NamedObjectBuilder.java 20 Dec 2003 00:21:19 -0000 1.21
--- NamedObjectBuilder.java 12 Jan 2004 22:39:26 -0000 1.22
***************
*** 2,5 ****
--- 2,10 ----
* $Id$
* $Log$
+ * Revision 1.22 2004/01/12 22:39:26 pelle
+ * Completed all the builders and contracts.
+ * Added a new abstract Value class to contain either an amount or a list of serial numbers.
+ * Now ready to finish off the AssetControllers.
+ *
* Revision 1.21 2003/12/20 00:21:19 pelle
* overwrote the standard Object.toString(), hashCode() and equals() methods for SignedNamedObject/Core
***************
*** 241,245 ****
* This simple wrapper takes most of the contents of a NamedObject and puts it into a Serializable form that can be signed.
*/
! public class NamedObjectBuilder extends SignedElement implements Cloneable {
protected NamedObjectBuilder(final String name, final String tagName, final String prefix, final String nsURI) throws InvalidNamedObjectException {
super(tagName, prefix, nsURI);
--- 246,251 ----
* This simple wrapper takes most of the contents of a NamedObject and puts it into a Serializable form that can be signed.
*/
! public class NamedObjectBuilder extends Builder implements Cloneable {
! /*
protected NamedObjectBuilder(final String name, final String tagName, final String prefix, final String nsURI) throws InvalidNamedObjectException {
super(tagName, prefix, nsURI);
***************
*** 247,250 ****
--- 253,257 ----
setName(name);
}
+ */
protected NamedObjectBuilder(final String name, final String tagName, final Namespace ns) throws InvalidNamedObjectException {
***************
*** 289,297 ****
}
- final public SignedNamedObject convert() throws InvalidNamedObjectException, NameResolutionException{
-
- return VerifyingReader.getInstance().read(getElement());
- }
-
/**
* The full name (URI) of an object
--- 296,299 ----
***************
*** 360,372 ****
/**
- * Sign NamedObject using given PrivateKey. This also adds a timestamp to the root element prior to signing
- */
- protected final void preSign() throws XMLSecurityException {
- // We need to timestamp it before we sign it
- getElement().addAttribute(DocumentHelper.createQName("timestamp", NSTools.NS_NEUID), TimeTools.createTimeStamp());
- }
-
-
- /**
* Adds a TargetReference to a NamedObject.<br>
* This can only be done if the object isn't signed.
--- 362,365 ----
***************
*** 439,456 ****
*/
- 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;
- }
- }
-
-
- return null;
-
- }
--- 432,435 ----
***************
*** 459,515 ****
}
! /**
! * Creates and returns a copy of this object. The precise meaning
! * of "copy" may depend on the class of the object. The general
! * intent is that, for any object <tt>x</tt>, the expression:
! * <blockquote>
! * <pre>
! * x.clone() != x</pre></blockquote>
! * will be true, and that the expression:
! * <blockquote>
! * <pre>
! * x.clone().getClass() == x.getClass()</pre></blockquote>
! * will be <tt>true</tt>, but these are not absolute requirements.
! * While it is typically the case that:
! * <blockquote>
! * <pre>
! * x.clone().equals(x)</pre></blockquote>
! * will be <tt>true</tt>, this is not an absolute requirement.
! * <p/>
! * By convention, the returned object should be obtained by calling
! * <tt>super.clone</tt>. If a class and all of its superclasses (except
! * <tt>Object</tt>) obey this convention, it will be the case that
! * <tt>x.clone().getClass() == x.getClass()</tt>.
! * <p/>
! * By convention, the object returned by this method should be independent
! * of this object (which is being cloned). To achieve this independence,
! * it may be necessary to modify one or more fields of the object returned
! * by <tt>super.clone</tt> before returning it. Typically, this means
! * copying any mutable objects that comprise the internal "deep structure"
! * of the object being cloned and replacing the references to these
! * objects with references to the copies. If a class contains only
! * primitive fields or references to immutable objects, then it is usually
! * the case that no fields in the object returned by <tt>super.clone</tt>
! * need to be modified.
! * <p/>
! * The method <tt>clone</tt> for class <tt>Object</tt> performs a
! * specific cloning operation. First, if the class of this object does
! * not implement the interface <tt>Cloneable</tt>, then a
! * <tt>CloneNotSupportedException</tt> is thrown. Note that all arrays
! * are considered to implement the interface <tt>Cloneable</tt>.
! * Otherwise, this method creates a new instance of the class of this
! * object and initializes all its fields with exactly the contents of
! * the corresponding fields of this object, as if by assignment; the
! * contents of the fields are not themselves cloned. Thus, this method
! * performs a "shallow copy" of this object, not a "deep copy" operation.
! * <p/>
! * The class <tt>Object</tt> does not itself implement the interface
! * <tt>Cloneable</tt>, so calling the <tt>clone</tt> method on an object
! * whose class is <tt>Object</tt> will result in throwing an
! * exception at run time.
! *
! * @return a clone of this instance.
! * @see Cloneable
! */
public Object clone() {
try {
--- 438,442 ----
}
!
public Object clone() {
try {
Index: SignatureRequestBuilder.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/builders/SignatureRequestBuilder.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** SignatureRequestBuilder.java 11 Dec 2003 23:57:29 -0000 1.7
--- SignatureRequestBuilder.java 12 Jan 2004 22:39:26 -0000 1.8
***************
*** 27,30 ****
--- 27,35 ----
$Id$
$Log$
+ Revision 1.8 2004/01/12 22:39:26 pelle
+ Completed all the builders and contracts.
+ Added a new abstract Value class to contain either an amount or a list of serial numbers.
+ Now ready to finish off the AssetControllers.
+
Revision 1.7 2003/12/11 23:57:29 pelle
Trying to test the ReceiverServlet with cactus. Still no luck. Need to return a ElementProxy of some sort.
***************
*** 72,76 ****
*/
public final class SignatureRequestBuilder extends NamedObjectBuilder {
! public SignatureRequestBuilder(final String requestor, final String userid, final NamedObjectBuilder unsigned, final String description) throws NeuClearException {
super(NSTools.createUniqueTransactionID(requestor, userid), SignatureRequest.SIGREQUEST_TAG);
final Element unsignedElem = addElement("Unsigned");
--- 77,81 ----
*/
public final class SignatureRequestBuilder extends NamedObjectBuilder {
! public SignatureRequestBuilder(final String requestor, final String userid, final Builder unsigned, final String description) throws NeuClearException {
super(NSTools.createUniqueTransactionID(requestor, userid), SignatureRequest.SIGREQUEST_TAG);
final Element unsignedElem = addElement("Unsigned");
|