use of com.openmeap.digest.DigestException in project OpenMEAP by OpenMEAP.
the class ApplicationArchive method substituteArchiveVariables.
@Transient
private String substituteArchiveVariables(GlobalSettings settings, String url) {
String externalServiceUrlPrefix = settings.getExternalServiceUrlPrefix();
String authSalt = this.getApplication().getProxyAuthSalt();
String newAuthToken;
try {
newAuthToken = AuthTokenProvider.newAuthToken(authSalt != null ? authSalt : "");
} catch (DigestException e) {
throw new GenericRuntimeException(e);
}
String replUrl = url;
try {
// TODO: replace these with constants
replUrl = replUrl.replace("${globalSettings.externalServiceUrlPrefix}", externalServiceUrlPrefix != null ? externalServiceUrlPrefix : "");
replUrl = replUrl.replace("${appName}", URLEncoder.encode(getApplication().getName(), FormConstants.CHAR_ENC_DEFAULT));
replUrl = replUrl.replace("${newAuthToken}", URLEncoder.encode(newAuthToken, FormConstants.CHAR_ENC_DEFAULT));
replUrl = replUrl.replace("${hash}", URLEncoder.encode(hash, FormConstants.CHAR_ENC_DEFAULT));
replUrl = replUrl.replace("${hashAlgorithm}", URLEncoder.encode(hashAlgorithm, FormConstants.CHAR_ENC_DEFAULT));
} catch (UnsupportedEncodingException uee) {
logger.error("Exception thrown encoding url parameters for url: {}", uee);
}
return replUrl;
}
Aggregations