|
From: <pe...@us...> - 2003-09-24 23:56:53
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/contracts/nsauth
In directory sc8-pr-cvs1:/tmp/cvs-serv524/src/java/org/neuclear/contracts/nsauth
Modified Files:
AuthenticationTicket.java
Log Message:
Refactoring nearly done. New model for creating signed objects.
With view for supporting the xmlpull api shortly for performance reasons.
Currently still uses dom4j but that has been refactored out that it
should now be very quick to implement a xmlpull implementation.
A side benefit of this is that the API has been further simplified. I still have some work
todo with regards to cleaning up some of the outlying parts of the code.
Index: AuthenticationTicket.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/contracts/nsauth/AuthenticationTicket.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** AuthenticationTicket.java 23 Sep 2003 19:16:26 -0000 1.3
--- AuthenticationTicket.java 24 Sep 2003 23:56:47 -0000 1.4
***************
*** 13,18 ****
import org.dom4j.Namespace;
import org.neuclear.id.Identity;
! import org.neuclear.id.NamedObject;
! import org.neuclear.id.NamedObjectFactory;
import org.neuclear.id.signrequest.SignatureRequest;
import org.neuclear.time.TimeTools;
--- 13,17 ----
import org.dom4j.Namespace;
import org.neuclear.id.Identity;
! import org.neuclear.id.SignedNamedObject;
import org.neuclear.id.signrequest.SignatureRequest;
import org.neuclear.time.TimeTools;
***************
*** 29,70 ****
* It generates a unique Name in the users Identity, which the user then signs.
*/
! public class AuthenticationTicket extends NamedObject {
/**
* <p>Used by a website to create an authentication ticket for validation.</p>
* <p>Eg.:<br>
! * <tt>NamedObject ticket=new AuthenticationTicket("neu://test/bob","neu://site/neubay",36000,"http://neubay.com");</tt><br>
* Would give you a namedobject containing the following xml:<br>
* <pre><nsauth:AuthenticationTicket xmlns:nsauth="http://neuclear.org/neu/nsauth" xmlns:nsdl="http://neuclear.org/neu/nsdl" nsdl:name="/test/two/neu.testapp.-2o1qkqrvxyesyt7dae22ulvp56eju30zyys5t6nxjjie2gw3qq" nsauth:validto="20021002T084919848GMT+00:00" nsauth:href="http://localhost:8080/neudistframework/">
* </nsauth:AuthenticationTicket>
*</pre>
! *
! * @param user The Users namespace eg: neu://test/bob
! * @param requester The requesters Identity eg. neu://site/neubay
! * @param validity The validity of the ticket in Milliseconds
! * @param siteurl URL for interactive signing service to send user to after signing.
! */
! private AuthenticationTicket(String user, String requester, long validity, String siteurl) throws NeudistException {
! super(createUniqueTicketName(user, requester), AuthenticationTicket.TAG_NAME, AuthenticationTicket.NS_NSAUTH);
!
! NamedObject userns = NamedObjectFactory.fetchNamedObject(user);
!
! if (userns == null || (!(userns instanceof Identity)) || (Utility.isEmpty(((Identity) userns).getSigner())))
! throw new NeudistException("The provided namespace: " + user + " doesnt exist or doesnt allow interactive signing");
! Element root = getElement();
! if (validity >= 0)
! root.addAttribute(DocumentHelper.createQName("validto", NS_NSAUTH), TimeTools.formatTimeStamp(new Timestamp(new Date().getTime() + validity)));
! if (!Utility.isEmpty(siteurl))
! root.addAttribute(DocumentHelper.createQName("href", NS_NSAUTH), siteurl);
! }
- /**
- * This constructor is used to create a UserAuthenticationTicket from an XML Element
- * @param elem AuthenticationTicket element
- * @throws NeudistException
- */
- public AuthenticationTicket(Element elem) throws NeudistException {
- super(elem);
}
public static SignatureRequest createAuthenticationRequest(String user, String requester, long validity, String siteurl, String targeturl, PrivateKey signer) throws NeudistException {
AuthenticationTicket ticket = new AuthenticationTicket(user, requester, validity, siteurl);
--- 28,59 ----
* It generates a unique Name in the users Identity, which the user then signs.
*/
! public class AuthenticationTicket extends SignedNamedObject {
/**
* <p>Used by a website to create an authentication ticket for validation.</p>
* <p>Eg.:<br>
! * <tt>SignedNamedObject ticket=new AuthenticationTicket("neu://test/bob","neu://site/neubay",36000,"http://neubay.com");</tt><br>
* Would give you a namedobject containing the following xml:<br>
* <pre><nsauth:AuthenticationTicket xmlns:nsauth="http://neuclear.org/neu/nsauth" xmlns:nsdl="http://neuclear.org/neu/nsdl" nsdl:name="/test/two/neu.testapp.-2o1qkqrvxyesyt7dae22ulvp56eju30zyys5t6nxjjie2gw3qq" nsauth:validto="20021002T084919848GMT+00:00" nsauth:href="http://localhost:8080/neudistframework/">
* </nsauth:AuthenticationTicket>
*</pre>
! *
! * @param name
! * @param signatory
! * @param timestamp
! * @param digest
! * @param requester
! * @param validto
! * @param siteurl
! * @throws NeudistException
! */
! private AuthenticationTicket(String name, Identity signatory,Timestamp timestamp,String digest, String requester, Timestamp validto, String siteurl) throws NeudistException {
! super(name, signatory, timestamp, digest);
! this.validTo=validto;
! this.siteurl=siteurl;
! this.requester=requester;
}
+ /*
public static SignatureRequest createAuthenticationRequest(String user, String requester, long validity, String siteurl, String targeturl, PrivateKey signer) throws NeudistException {
AuthenticationTicket ticket = new AuthenticationTicket(user, requester, validity, siteurl);
***************
*** 72,75 ****
--- 61,65 ----
}
+ */
/**
***************
*** 111,116 ****
*/
public Timestamp getValidTo() throws NeudistException {
! String ts = getElement().attributeValue(DocumentHelper.createQName("validto", NS_NSAUTH));
! return TimeTools.parseTimeStamp(ts);
}
--- 101,105 ----
*/
public Timestamp getValidTo() throws NeudistException {
! return validTo;
}
***************
*** 120,124 ****
*/
public String getSiteHref() {
! return getElement().attributeValue(DocumentHelper.createQName("href", NS_NSAUTH));
}
--- 109,113 ----
*/
public String getSiteHref() {
! return siteurl;
}
***************
*** 127,136 ****
}
- /**
- * @return the XML Identity object
- */
- public Namespace getNS() {
- return NS_NSAUTH;
- }
/*
--- 116,119 ----
***************
*** 149,152 ****
--- 132,138 ----
*/
+ private String requester;
+ private String siteurl;
+ private Timestamp validTo;
private static final String TAG_NAME = "AuthenticationTicket";
public static final String URI_NSAUTH = "http://neuclear.org/neu/nsauth";
|