use of com.zimbra.common.util.BlobMetaDataEncodingException in project zm-mailbox by Zimbra.
the class JWEUtil method getDecodedJWE.
public static Map<String, String> getDecodedJWE(String jwe) throws ServiceException {
Map<String, String> result = null;
if (StringUtils.isEmpty(jwe)) {
return result;
}
String[] jweArr = jwe.split("_");
if (jweArr.length != 2) {
throw ServiceException.PARSE_ERROR("invalid jwe format", null);
}
AuthTokenKey key = AuthTokenKey.getVersion(jweArr[0]);
String data = DataSource.decryptData(new String(key.getKey()), jweArr[1]);
try {
Map<?, ?> map = BlobMetaData.decode(data);
result = map.entrySet().stream().collect(Collectors.toMap(e -> (String) e.getKey(), e -> (String) e.getValue()));
} catch (BlobMetaDataEncodingException e) {
throw ServiceException.FAILURE("failed to get decoded jwe", e);
}
return result;
}
Aggregations