|
From: <pe...@us...> - 2004-01-19 17:55:03
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id
In directory sc8-pr-cvs1:/tmp/cvs-serv32609/src/java/org/neuclear/id
Modified Files:
NSTools.java SignedNamedCore.java
Log Message:
Updated the NeuClear ID naming scheme to support various levels of semantics
Index: NSTools.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/NSTools.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** NSTools.java 9 Jan 2004 16:34:40 -0000 1.26
--- NSTools.java 19 Jan 2004 17:54:59 -0000 1.27
***************
*** 2,5 ****
--- 2,8 ----
* $Id$
* $Log$
+ * Revision 1.27 2004/01/19 17:54:59 pelle
+ * Updated the NeuClear ID naming scheme to support various levels of semantics
+ *
* Revision 1.26 2004/01/09 16:34:40 pelle
* changed use of base36 encoding to base32 to ensure compatibility with other schemes.
***************
*** 228,232 ****
if (name == null)
return "neu://";
! if (!name.startsWith("neu://"))
name = "neu:/" + name;
if (!isValidName(name))
--- 231,235 ----
if (name == null)
return "neu://";
! if (!name.startsWith("neu:"))
name = "neu:/" + name;
if (!isValidName(name))
***************
*** 277,280 ****
--- 280,289 ----
return (matcher.matches());
}
+ public static boolean isValidTransactionName(final String name) {
+ if (Utility.isEmpty(name))
+ return false;
+ final Matcher matcher = VALID.matcher(name);
+ return (matcher.matches());
+ }
/**
***************
*** 461,469 ****
private static final String VALID_TOP_TOKEN = VALID_USER_TOKEN + "[\\w]([\\w.-]*[\\w])?";
private static final String VALID_SUB_TOKEN = "(\\/[\\w][\\w-]*)*";
! private static final String VALID_TRAN_TOKEN = "(\\![\\w][\\w.-]*)?";
! private static final String VALID_ID = "^neu:" + SCHEME_PREFIX + "\\/\\/(" + VALID_TOP_TOKEN +
! VALID_SUB_TOKEN + VALID_TRAN_TOKEN + ")?$";
private static final Pattern VALID = Pattern.compile(VALID_ID);
private static final String STRIP_URI_ARROBA_EX = "neu://((" + VALID_TOKEN + ")@)?(" + VALID_TOKEN + ")?(" + VALID_SUB_TOKEN + VALID_TRAN_TOKEN + ")$";
--- 470,484 ----
private static final String VALID_TOP_TOKEN = VALID_USER_TOKEN + "[\\w]([\\w.-]*[\\w])?";
private static final String VALID_SUB_TOKEN = "(\\/[\\w][\\w-]*)*";
! private static final String SHA1="[a-zA-Z2-7]{32}";
! private static final String VALID_TRAN_TOKEN = "!"+SHA1+"$";
! private static final String VALID_SHA1ID="^sha1:"+SHA1;
+ private static final String VALID_PETNAME="pet:"+VALID_TOKEN+VALID_TRAN_TOKEN;
+ private static final String VALID_NEU_ID = "neu:\\/\\/(" + VALID_TOP_TOKEN + VALID_SUB_TOKEN+")?";
+ private static final String VALID_ID="^"+VALID_SHA1ID+"|"+VALID_NEU_ID+"|"+VALID_PETNAME+"$";
+
+ private static final String VALID_XACT="^"+VALID_SHA1ID+"|"+VALID_NEU_ID+"|"+VALID_PETNAME+VALID_TRAN_TOKEN+"$";
private static final Pattern VALID = Pattern.compile(VALID_ID);
+ private static final Pattern VALIDX = Pattern.compile(VALID_XACT);
private static final String STRIP_URI_ARROBA_EX = "neu://((" + VALID_TOKEN + ")@)?(" + VALID_TOKEN + ")?(" + VALID_SUB_TOKEN + VALID_TRAN_TOKEN + ")$";
Index: SignedNamedCore.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/SignedNamedCore.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** SignedNamedCore.java 18 Jan 2004 21:20:29 -0000 1.15
--- SignedNamedCore.java 19 Jan 2004 17:54:59 -0000 1.16
***************
*** 2,5 ****
--- 2,8 ----
* $Id$
* $Log$
+ * Revision 1.16 2004/01/19 17:54:59 pelle
+ * Updated the NeuClear ID naming scheme to support various levels of semantics
+ *
* Revision 1.15 2004/01/18 21:20:29 pelle
* Created Base32 encoder that now fully complies with Tyler's spec.
***************
*** 268,271 ****
--- 271,275 ----
import org.neuclear.commons.LowLevelException;
import org.neuclear.commons.crypto.CryptoTools;
+ import org.neuclear.commons.crypto.CryptoException;
import org.neuclear.commons.time.TimeTools;
import org.neuclear.id.resolver.NSResolver;
***************
*** 346,349 ****
--- 350,359 ----
*/
public final static SignedNamedCore read(final Element elem) throws InvalidNamedObjectException, NameResolutionException {
+ try {
+ return readUnnamed(elem);
+ } catch (XMLSecurityException e) {
+ throw new InvalidNamedObjectException("Failed Verification");
+ }
+ /*
final String name = getSignatoryName(elem);
try {
***************
*** 362,366 ****
publicKey = ki.getPublicKey();
}
! if (XMLSecTools.verifySignature(elem, publicKey)) {
final Timestamp timestamp = TimeTools.parseTimeStamp(InvalidNamedObjectException.assertAttributeQName(elem,createQName("timestamp")));
return new SignedNamedCore(name, signatory, timestamp, encodeElement(elem));
--- 372,376 ----
publicKey = ki.getPublicKey();
}
! if (XMLSecTools.verifySignature(elem)) {
final Timestamp timestamp = TimeTools.parseTimeStamp(InvalidNamedObjectException.assertAttributeQName(elem,createQName("timestamp")));
return new SignedNamedCore(name, signatory, timestamp, encodeElement(elem));
***************
*** 371,375 ****
--- 381,388 ----
} catch (ParseException e) {
throw new InvalidNamedObjectException(name,"invalid timestamp");
+ } catch (CryptoException e) {
+ throw new InvalidNamedObjectException(name,"invalid timestamp");
}
+ */
}
|