Search in sources :

Example 6 with DigestException

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;
}
Also used : DigestException(com.openmeap.digest.DigestException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) GenericRuntimeException(com.openmeap.util.GenericRuntimeException)

Aggregations

DigestException (com.openmeap.digest.DigestException)6 GenericRuntimeException (com.openmeap.util.GenericRuntimeException)5 GlobalSettings (com.openmeap.model.dto.GlobalSettings)4 ApplicationArchive (com.openmeap.model.dto.ApplicationArchive)3 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 IOException (java.io.IOException)3 Application (com.openmeap.model.dto.Application)2 BufferedInputStream (java.io.BufferedInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 FileNameMap (java.net.FileNameMap)2 MessagesEvent (com.openmeap.event.MessagesEvent)1 ModelManager (com.openmeap.model.ModelManager)1 ApplicationVersion (com.openmeap.model.dto.ApplicationVersion)1 ClusterNode (com.openmeap.model.dto.ClusterNode)1 Deployment (com.openmeap.model.dto.Deployment)1 ConnectionOpenResponse (com.openmeap.protocol.dto.ConnectionOpenResponse)1 Error (com.openmeap.protocol.dto.Error)1