|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--spki.BaseObj
|
+--spki.Hash
spki Hash class. A Hash object gives the hash of some other object.
Formal definition:
<alg-id>:: <byte-string> | <uri> ;
<hash-alg-id>:: <alg-id> ;
<hash-value>:: <byte-string> ;
<hash>:: "(" "hash" <hash-alg-id> <hash-value> <uris>? ")" ;
NOTE: For now, only algorithm name is supported for the alg-id.
NOTE: Due to bugs in Cryptix 3.0.3, the MD5 and SHA1 hashing algorithms produce non-comformant output, so we have to use the hashing algorithms provided by Sun. We do not recommend use of other algorithms than MD5 or SHA1.
TODO: support using URI as the alg-id?
| Field Summary | |
private static String |
__ME
This class's full name. |
private String |
alg_id
The hash algorithm ID. |
private MessageDigest |
md
The digest object used for hashing input values. |
static String |
SEXP_NAME
This class S-Expression type name, used by toSExpression() and other methods. |
private URIs |
uris
The hashed-object's URI, maybe null. |
private byte[] |
value
The hash value. |
| Fields inherited from class spki.BaseObj |
__ME,
cache_sexp,
cached_sexp,
DEFAULT_HASH_ALG,
locked,
SEXP_NAME |
| Constructor Summary | |
protected |
Hash()
Don't use me! |
|
Hash(byte[] value,
String alg_id,
URIs uris)
Create an immutable hash object with the specified hashing algorithm and pre-fab hash value. |
|
Hash(SExpression sexp)
Create an immutable Hash object from an S-Expression. |
|
Hash(String alg_id,
byte[] input,
URIs uris)
Create immutable Hash object from input with the specified hashing algorithm. |
| Method Summary | |
boolean |
equals(Hash that)
Compare this object against the given object. |
boolean |
equals(Principal that)
Compare this object with another principal. |
String |
getAlgId()
Get this object's hashing algorithm ID. |
String |
getB64Value()
Return the hash value as a Base64-encoded string. |
private MessageDigest |
getMD(String alg_id)
Try to get a MessageDigest provider. |
byte[] |
getValue()
Get this object's hash value. |
private void |
hash(byte[] input)
Hash the specified data, store the result, and make this object immutable. |
Principal |
toHashPrincipal()
Convert this principal into a hash representation. |
SExpression |
toSExpression()
Build an SExpression representing this object. |
| Methods inherited from class spki.BaseObj |
disableSExpressionCaching,
enableSExpressionCaching,
extractHashAlgId,
getCachedSExpression,
isLocked,
isSListOfType,
lock,
providerToSPKI,
setCachedSExpression,
spkiToProvider,
toString |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private static final String __ME
public static final String SEXP_NAME
toSExpression()private MessageDigest md
private String alg_id
private byte[] value
private URIs uris
| Constructor Detail |
protected Hash()
Hash(SExpression),
Hash(String,byte[],URIs),
Hash(byte[],String,URIs)
public Hash(SExpression sexp)
throws SPKIException,
ParseException
BaseObj.BaseObj(SExpression)
public Hash(String alg_id,
byte[] input,
URIs uris)
throws SPKIException
alg_id - String containing the desired hashing algorithm.input - Byte array of input data to calculate hash value of.uris - the hased-object's URI, maybe null.
public Hash(byte[] value,
String alg_id,
URIs uris)
throws SPKIException
alg_id - String containing the desired hashing algorithm.value - byte array containing the hash-value.uris - the hased-object's URI, maybe null.| Method Detail |
public SExpression toSExpression()
throws SPKIException
public boolean equals(Principal that)
that - a principal to compare with.
public Principal toHashPrincipal()
throws SPKIException
public String getAlgId()
public byte[] getValue()
public String getB64Value()
public boolean equals(Hash that)
that - the Hash object to compare this object against.
private MessageDigest getMD(String alg_id)
throws SPKIException
alg_id - String containing the desired algorithm ID.
private void hash(byte[] input)
throws IllegalStateException
input - Byte array of input data to calculate hash value of.getValue(),
BaseObj.lock()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||