use of org.wso2.carbon.apimgt.api.model.KeyManagerConnectorConfiguration in project carbon-apimgt by wso2.
the class APIAdminImpl method getKeyManagerEndpoints.
private void getKeyManagerEndpoints(KeyManagerConfigurationDTO keyManagerConfigurationDTO) {
Map<String, String> endpointConfigurationsMap = new HashMap<>();
keyManagerConfigurationDTO.setEndpoints(endpointConfigurationsMap);
if (!APIConstants.KeyManager.DEFAULT_KEY_MANAGER_TYPE.equals(keyManagerConfigurationDTO.getType())) {
KeyManagerConnectorConfiguration keyManagerConnectorConfiguration = ServiceReferenceHolder.getInstance().getKeyManagerConnectorConfiguration(keyManagerConfigurationDTO.getType());
List<ConfigurationDto> endpointConfigurations = keyManagerConnectorConfiguration.getEndpointConfigurations();
if (endpointConfigurations != null) {
for (ConfigurationDto endpointConfiguration : endpointConfigurations) {
Object endpointValue = keyManagerConfigurationDTO.getProperty(endpointConfiguration.getName());
if (endpointValue instanceof String && StringUtils.isNotEmpty((String) endpointValue)) {
endpointConfigurationsMap.put(endpointConfiguration.getName(), (String) endpointValue);
}
}
}
}
}
use of org.wso2.carbon.apimgt.api.model.KeyManagerConnectorConfiguration in project carbon-apimgt by wso2.
the class APIAdminImpl method encryptKeyManagerConfigurationValues.
private void encryptKeyManagerConfigurationValues(KeyManagerConfigurationDTO retrievedKeyManagerConfigurationDTO, KeyManagerConfigurationDTO updatedKeyManagerConfigurationDto) throws APIManagementException {
KeyManagerConnectorConfiguration keyManagerConnectorConfiguration = ServiceReferenceHolder.getInstance().getKeyManagerConnectorConfiguration(updatedKeyManagerConfigurationDto.getType());
if (keyManagerConnectorConfiguration != null) {
Map<String, Object> additionalProperties = updatedKeyManagerConfigurationDto.getAdditionalProperties();
for (ConfigurationDto configurationDto : keyManagerConnectorConfiguration.getConnectionConfigurations()) {
if (configurationDto.isMask()) {
String value = (String) additionalProperties.get(configurationDto.getName());
if (APIConstants.DEFAULT_MODIFIED_ENDPOINT_PASSWORD.equals(value)) {
Object unModifiedValue = retrievedKeyManagerConfigurationDTO.getAdditionalProperties().get(configurationDto.getName());
additionalProperties.replace(configurationDto.getName(), unModifiedValue);
} else if (StringUtils.isNotEmpty(value)) {
additionalProperties.replace(configurationDto.getName(), encryptValues(value));
}
}
}
}
}
use of org.wso2.carbon.apimgt.api.model.KeyManagerConnectorConfiguration in project carbon-apimgt by wso2.
the class APIAdminImpl method maskValues.
private void maskValues(KeyManagerConfigurationDTO keyManagerConfigurationDTO) {
KeyManagerConnectorConfiguration keyManagerConnectorConfiguration = ServiceReferenceHolder.getInstance().getKeyManagerConnectorConfiguration(keyManagerConfigurationDTO.getType());
Map<String, Object> additionalProperties = keyManagerConfigurationDTO.getAdditionalProperties();
List<ConfigurationDto> connectionConfigurations = keyManagerConnectorConfiguration.getConnectionConfigurations();
for (ConfigurationDto connectionConfiguration : connectionConfigurations) {
if (connectionConfiguration.isMask()) {
additionalProperties.replace(connectionConfiguration.getName(), APIConstants.DEFAULT_MODIFIED_ENDPOINT_PASSWORD);
}
}
}
Aggregations