/** * Returns the secret. * * @return The secret. */ public byte[] getSecret() { return ((OctetSequenceKey) getJWKSet().getKeys().get(0)).toByteArray(); }
public LemonJweService(String secret) throws KeyLengthException { byte[] secretKey = secret.getBytes(); encrypter = new DirectEncrypter(secretKey); jwtProcessor = new DefaultJWTProcessor<SimpleSecurityContext>(); // The JWE key source JWKSource<SimpleSecurityContext> jweKeySource = new ImmutableSecret<SimpleSecurityContext>(secretKey); // Configure a key selector to handle the decryption phase JWEKeySelector<SimpleSecurityContext> jweKeySelector = new JWEDecryptionKeySelector<SimpleSecurityContext>(JWEAlgorithm.DIR, EncryptionMethod.A128CBC_HS256, jweKeySource); jwtProcessor.setJWEKeySelector(jweKeySelector); }
/** * Returns the secret key. * * @return The secret key. */ public SecretKey getSecretKey() { return ((OctetSequenceKey) getJWKSet().getKeys().get(0)).toSecretKey(); } }