use of io.apiman.manager.api.beans.gateways.RestGatewayConfigBean in project apiman by apiman.
the class GatewayResourceImpl method encryptPasswords.
/**
* @param gateway
*/
private void encryptPasswords(GatewayBean gateway) {
if (gateway.getConfiguration() == null) {
return;
}
try {
if (gateway.getType() == GatewayType.REST) {
RestGatewayConfigBean config = MAPPER.readValue(gateway.getConfiguration(), RestGatewayConfigBean.class);
config.setPassword(encrypter.encrypt(config.getPassword(), new DataEncryptionContext()));
gateway.setConfiguration(MAPPER.writeValueAsString(config));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of io.apiman.manager.api.beans.gateways.RestGatewayConfigBean in project apiman by apiman.
the class GatewayResourceImpl method decryptPasswords.
/**
* @param gateway
*/
private void decryptPasswords(GatewayBean gateway) {
if (gateway.getConfiguration() == null) {
return;
}
try {
if (gateway.getType() == GatewayType.REST) {
// TODO(msavy): how was this ever working?
String workingConf = gateway.getConfiguration();
if (gateway.getConfiguration().startsWith("$CRYPT::")) {
workingConf = encrypter.decrypt(gateway.getConfiguration(), new DataEncryptionContext());
}
RestGatewayConfigBean config = MAPPER.readValue(workingConf, RestGatewayConfigBean.class);
config.setPassword(encrypter.decrypt(config.getPassword(), new DataEncryptionContext()));
gateway.setConfiguration(MAPPER.writeValueAsString(config));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations