use of org.wso2.carbon.apimgt.api.model.ConfigurationDto 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.ConfigurationDto 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.ConfigurationDto 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);
}
}
}
use of org.wso2.carbon.apimgt.api.model.ConfigurationDto in project carbon-apimgt by wso2.
the class SettingsMappingUtil method fromKeyManagerConfigurationToSettingsKeyManagerConfigurationDTO.
private static SettingsKeyManagerConfigurationDTO fromKeyManagerConfigurationToSettingsKeyManagerConfigurationDTO(String name, String displayName, String scopesClaim, String consumerKeyClaim, List<ConfigurationDto> connectionConfigurationDtoList, List<ConfigurationDto> endpointConfigurations) {
SettingsKeyManagerConfigurationDTO settingsKeyManagerConfigurationDTO = new SettingsKeyManagerConfigurationDTO();
settingsKeyManagerConfigurationDTO.setDisplayName(displayName);
settingsKeyManagerConfigurationDTO.setType(name);
settingsKeyManagerConfigurationDTO.setDefaultScopesClaim(scopesClaim);
settingsKeyManagerConfigurationDTO.setDefaultConsumerKeyClaim(consumerKeyClaim);
if (connectionConfigurationDtoList != null) {
for (ConfigurationDto configurationDto : connectionConfigurationDtoList) {
KeyManagerConfigurationDTO keyManagerConfigurationDTO = new KeyManagerConfigurationDTO();
keyManagerConfigurationDTO.setName(configurationDto.getName());
keyManagerConfigurationDTO.setLabel(configurationDto.getLabel());
keyManagerConfigurationDTO.setType(configurationDto.getType());
keyManagerConfigurationDTO.setRequired(configurationDto.isRequired());
keyManagerConfigurationDTO.setMask(configurationDto.isMask());
keyManagerConfigurationDTO.setMultiple(configurationDto.isMultiple());
keyManagerConfigurationDTO.setTooltip(configurationDto.getTooltip());
keyManagerConfigurationDTO.setDefault(configurationDto.getDefaultValue());
keyManagerConfigurationDTO.setValues(configurationDto.getValues());
settingsKeyManagerConfigurationDTO.getConfigurations().add(keyManagerConfigurationDTO);
}
}
if (endpointConfigurations != null) {
for (ConfigurationDto configurationDto : endpointConfigurations) {
KeyManagerConfigurationDTO keyManagerConfigurationDTO = new KeyManagerConfigurationDTO();
keyManagerConfigurationDTO.setName(configurationDto.getName());
keyManagerConfigurationDTO.setLabel(configurationDto.getLabel());
keyManagerConfigurationDTO.setType(configurationDto.getType());
keyManagerConfigurationDTO.setRequired(configurationDto.isRequired());
keyManagerConfigurationDTO.setMask(configurationDto.isMask());
keyManagerConfigurationDTO.setMultiple(configurationDto.isMultiple());
keyManagerConfigurationDTO.setTooltip(configurationDto.getTooltip());
keyManagerConfigurationDTO.setDefault(configurationDto.getDefaultValue());
keyManagerConfigurationDTO.setValues(configurationDto.getValues());
settingsKeyManagerConfigurationDTO.getEndpointConfigurations().add(keyManagerConfigurationDTO);
}
}
return settingsKeyManagerConfigurationDTO;
}
Aggregations