*
*/
- public AttributeQueryHandle(String handle, SecretKey key)
+ public AttributeQueryHandle(byte[] handle, SecretKey key)
throws HandleException {
try {
cipher.init(Cipher.DECRYPT_MODE, key);
StringTokenizer tokenizer =
new StringTokenizer(
- new String(cipher.doFinal(Base64.decode(handle))),
+ new String(cipher.doFinal(Base64.decode(handle)), "UTF-8"),
"||",
false);
- principal = tokenizer.nextToken();
+ principal =
+ new String(
+ Base64.decode(tokenizer.nextToken().getBytes("ASCII")),
+ "UTF-8");
expirationTime = new Long(tokenizer.nextToken()).longValue();
handleID = tokenizer.nextToken();
} catch (Exception e) {
UUIDGenerator uuidGen = UUIDGenerator.getInstance();
UUID nameSpaceUUID = new UUID(UUID.NAMESPACE_URL);
handleID =
- uuidGen.generateNameBasedUUID(nameSpaceUUID, hsLocation)+ ":" + uuidGen.generateTimeBasedUUID();
-
+ uuidGen.generateNameBasedUUID(nameSpaceUUID, hsLocation)
+ + ":"
+ + uuidGen.generateTimeBasedUUID();
+
Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key);
cipherTextHandle =
cipher.doFinal(
- (principal + "||" + expirationTime + "||" + handleID)
- .getBytes());
+ (
+ new String(
+ Base64.encode(principal.getBytes("UTF-8")),
+ "ASCII")
+ + "||"
+ + expirationTime
+ + "||"
+ + handleID).getBytes(
+ "UTF-8"));
} catch (Exception e) {
throw new HandleException("Error creating handle: " + e);
}
/**
- * Returns a <code>String</code> of ciphertext representing the <code>AttributeQueryHandle</code> instance.
+ * Returns bytes of ciphertext representing the <code>AttributeQueryHandle</code> instance.
*/
- public String serialize() {
+ public byte[] serialize() {
- return new String(Base64.encode(cipherTextHandle));
+ return Base64.encode(cipherTextHandle);
}
/**
public boolean isExpired() {
- if (System.currentTimeMillis() > expirationTime) {
+ if (System.currentTimeMillis() >= expirationTime) {
return true;
} else {
return false;
/**
* Returns a <code>String</code> representation of the unique identifier for this handle.
*/
-
+
public String getHandleID() {
return handleID;
}