/** * Generates a token from an input string * @param token String form of token * @param maxAge max age of the token (in seconds) * @throws BlobCrypterException never */ public BasicSecurityToken(String token, int maxAge, String activeUrl) throws BlobCrypterException { this.token = token; this.tokenData = crypter.unwrap(token, maxAge); this.activeUrl = activeUrl; }
/** * Builds a BlobCrypter from the specified master key * * @param masterKey */ public BasicBlobCrypter(byte[] masterKey) { init(masterKey); }
/** * HMAC sha1 * * @param key the key must be at least 8 bytes in length. * @param in byte array to HMAC. * @return the hash * * @throws GeneralSecurityException */ public static byte[] hmacSha(byte[] key, byte[] in) throws GeneralSecurityException { return hmacSha(key, in, HMAC_TYPE); }
/** * Load a BlobCrypter using the specified key. Override this if you have your own BlobCrypter * implementation. * * @param key The security token key. * @return The BlobCrypter. */ protected BlobCrypter loadCrypter(String key) { return new BasicBlobCrypter(key,HMACType.HMACSHA1); }
/** * @return an encrypted blob of state to store with the client. * @throws BlobCrypterException */ public String getEncryptedState() throws BlobCrypterException { return crypter.wrap(state); }
public void claimToken() { // consumer taking the token state = State.APPROVED; sessionHandle = Crypto.getRandomString(8); }
/** * Verifies an HMAC SHA hash. Throws if the verification fails. * * @param key * @param in * @param expected * @throws GeneralSecurityException */ public static void hmacShaVerify(byte[] key, byte[] in, byte[] expected) throws GeneralSecurityException { hmacShaVerify(key, in, expected, HMAC_TYPE); }
/** * Builds a BlobCrypter from the specified master key * * @param masterKey */ public BasicBlobCrypter(String masterKey) { this(masterKey, null); setHmacTypeFromPreferredHMACAlgorithm(); }
/** * Load a BlobCrypter using the specified key. Override this if you have your own BlobCrypter * implementation. * * @param key The security token key. * @return The BlobCrypter. */ protected BlobCrypter loadCrypter(String key) { return new BasicBlobCrypter(key,HMACType.HMACSHA1); }
/** * Generates a token from an input string * @param token String form of token * @param maxAge max age of the token (in seconds) * @throws BlobCrypterException never */ public BasicSecurityToken(String token, int maxAge, String activeUrl) throws BlobCrypterException { this.token = token; this.tokenData = crypter.unwrap(token, maxAge); this.activeUrl = activeUrl; }
/** * @return an encrypted blob of state to store with the client. * @throws BlobCrypterException */ public String getEncryptedState() throws BlobCrypterException { return crypter.wrap(state); }
public void claimToken() { // consumer taking the token state = State.APPROVED; sessionHandle = Crypto.getRandomString(8); }
/** * HMAC sha1 * * @param key the key must be at least 8 bytes in length. * @param in byte array to HMAC. * @return the hash * * @throws GeneralSecurityException */ public static byte[] hmacSha(byte[] key, byte[] in) throws GeneralSecurityException { return hmacSha(key, in, HMAC_TYPE); }
/** * Builds a BlobCrypter from the specified master key * * @param masterKey */ public BasicBlobCrypter(byte[] masterKey) { init(masterKey); }
/** * Builds a BlobCrypter from the specified master key * * @param masterKey */ public BasicBlobCrypter(byte[] masterKey) { this(masterKey, null); setHmacTypeFromPreferredHMACAlgorithm(); }
/** * Load a BlobCrypter using the specified key. Override this if you have your own BlobCrypter * implementation. * * @param key The security token key. * @return The BlobCrypter. */ protected BlobCrypter loadCrypter(String key) { return new BasicBlobCrypter(key,HMACType.HMACSHA1); }
/** * Builds a BlobCrypter from the specified master key * * @param masterKey */ public BasicBlobCrypter(byte[] masterKey) { this(masterKey, null); setHmacTypeFromPreferredHMACAlgorithm(); }
/** * Load a BlobCrypter from the specified file. Override this if you have your own * BlobCrypter implementation. */ protected BlobCrypter loadCrypterFromFile(File file) throws IOException { return new BasicBlobCrypter(file); }
/** * Builds a BlobCrypter from the specified master key * * @param masterKey */ public BasicBlobCrypter(String masterKey) { this(masterKey, null); setHmacTypeFromPreferredHMACAlgorithm(); }
protected BlobCrypter getBlobCrypter(String key) { BasicBlobCrypter c = new BasicBlobCrypter(key,HMACType.HMACSHA1); c.timeSource = timeSource; return c; }