Search in sources :

Example 1 with InvalidGoCipherTextException

use of com.thoughtworks.go.apiv1.pipelineoperations.exceptions.InvalidGoCipherTextException in project gocd by gocd.

the class EnvrionmentVariableRepresenter method fromJSON.

public static EnvironmentVariableConfig fromJSON(JsonReader jsonReader) {
    String name = jsonReader.getString("name");
    Boolean secure = jsonReader.optBoolean("secure").orElse(false);
    String value = secure ? jsonReader.optString("value").orElse(null) : jsonReader.getString("value");
    String encryptedValue = jsonReader.optString("encrypted_value").orElse(null);
    try {
        EnvironmentVariableConfig environmentVariableConfig = new EnvironmentVariableConfig();
        environmentVariableConfig.deserialize(name, value, secure, encryptedValue);
        return environmentVariableConfig;
    } catch (InvalidCipherTextException e) {
        throw new InvalidGoCipherTextException(e.getMessage(), e);
    }
}
Also used : EnvironmentVariableConfig(com.thoughtworks.go.config.EnvironmentVariableConfig) InvalidCipherTextException(org.bouncycastle.crypto.InvalidCipherTextException) InvalidGoCipherTextException(com.thoughtworks.go.apiv1.pipelineoperations.exceptions.InvalidGoCipherTextException)

Aggregations

InvalidGoCipherTextException (com.thoughtworks.go.apiv1.pipelineoperations.exceptions.InvalidGoCipherTextException)1 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)1 InvalidCipherTextException (org.bouncycastle.crypto.InvalidCipherTextException)1