} else {
// load latest user profile from network
NetworkContent content = dataManager.get(parameters);
if (content == null) {
logger.warn("Did not find user profile. user id = '{}'", credentials.getUserId());
entry.setGetError(new GetFailedException("User profile not found. Got null."));
} else {
try {
logger.trace("Decrypting user profile with 256-bit AES key from password. user id = '{}'",
credentials.getUserId());
EncryptedNetworkContent encrypted = (EncryptedNetworkContent) content;
NetworkContent decrypted = H2HEncryptionUtil.decryptAES(encrypted, userProfileEncryptionKey);
UserProfile userProfile = (UserProfile) decrypted;
userProfile.setVersionKey(content.getVersionKey());
userProfile.setBasedOnKey(content.getBasedOnKey());
// cache user profile
cachedUserProfile = userProfile;
// provide loaded user profile
entry.setUserProfile(userProfile);
} catch (DataLengthException | IllegalStateException | InvalidCipherTextException e) {
logger.error("Cannot decrypt the user profile. reason = '{}'", e.getMessage());
entry.setGetError(new GetFailedException(String.format("Cannot decrypt the user profile. reason = '%s'",
e.getMessage())));
} catch (Exception e) {
logger.error("Cannot get the user profile. reason = '{}'", e.getMessage());
entry.setGetError(new GetFailedException(String.format("Cannot get the user profile. reason = '%s'",
e.getMessage())));
}
}
}
}