50 if (StringUtils.isBlank(encryptedJwe)) {
54 String[] jweParts = encryptedJwe.split(
"\\.");
55 if (jweParts.length != 5) {
56 throw new InvalidJwtException(
"Invalid JWS format.");
59 String encodedHeader = jweParts[0];
60 String encodedEncryptedKey = jweParts[1];
61 String encodedInitializationVector = jweParts[2];
62 String encodedCipherText = jweParts[3];
63 String encodedIntegrityValue = jweParts[4];
66 jwe.setEncodedHeader(encodedHeader);
67 jwe.setEncodedEncryptedKey(encodedEncryptedKey);
68 jwe.setEncodedInitializationVector(encodedInitializationVector);
69 jwe.setEncodedCiphertext(encodedCipherText);
70 jwe.setEncodedIntegrityValue(encodedIntegrityValue);
72 jwe.setHeader(
new JwtHeader(encodedHeader));
75 jwe.getHeader().getClaimAsString(JwtHeaderName.ALGORITHM));
77 jwe.getHeader().getClaimAsString(JwtHeaderName.ENCRYPTION_METHOD));
80 byte[] initializationVector = Base64Util.base64urldecode(encodedInitializationVector);
81 byte[] authenticationTag = Base64Util.base64urldecode(encodedIntegrityValue);
82 byte[] additionalAuthenticatedData = jwe.getAdditionalAuthenticatedData().getBytes(Util.UTF8_STRING_ENCODING);
84 String plainText =
decryptCipherText(encodedCipherText, contentMasterKey, initializationVector,
85 authenticationTag, additionalAuthenticatedData);
86 jwe.setClaims(
new JwtClaims(plainText));
89 }
catch (InvalidJwtException e) {
90 throw new InvalidJweException(e);
91 }
catch (UnsupportedEncodingException e) {
92 throw new InvalidJweException(e);
abstract String decryptCipherText(String encodedCipherText, byte[] contentMasterKey, byte[] initializationVector, byte[] authenticationTag, byte[] additionalAuthenticatedData)
BlockEncryptionAlgorithm blockEncryptionAlgorithm
Definition: AbstractJweDecrypter.java:29
static BlockEncryptionAlgorithm fromName(String name)
Definition: BlockEncryptionAlgorithm.java:83
abstract byte [] decryptEncryptionKey(String encodedEncryptedKey)
KeyEncryptionAlgorithm keyEncryptionAlgorithm
Definition: AbstractJweDecrypter.java:28
static KeyEncryptionAlgorithm fromName(String name)
Definition: KeyEncryptionAlgorithm.java:51