Search in sources :

Example 6 with ConfigurationDto

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);
                }
            }
        }
    }
}
Also used : KeyManagerConnectorConfiguration(org.wso2.carbon.apimgt.api.model.KeyManagerConnectorConfiguration) ConfigurationDto(org.wso2.carbon.apimgt.api.model.ConfigurationDto) HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.simple.JSONObject)

Example 7 with ConfigurationDto

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));
                }
            }
        }
    }
}
Also used : KeyManagerConnectorConfiguration(org.wso2.carbon.apimgt.api.model.KeyManagerConnectorConfiguration) ConfigurationDto(org.wso2.carbon.apimgt.api.model.ConfigurationDto) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.simple.JSONObject)

Example 8 with ConfigurationDto

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);
        }
    }
}
Also used : KeyManagerConnectorConfiguration(org.wso2.carbon.apimgt.api.model.KeyManagerConnectorConfiguration) ConfigurationDto(org.wso2.carbon.apimgt.api.model.ConfigurationDto) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.simple.JSONObject)

Example 9 with ConfigurationDto

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;
}
Also used : KeyManagerConfigurationDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO) SettingsKeyManagerConfigurationDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.SettingsKeyManagerConfigurationDTO) ConfigurationDto(org.wso2.carbon.apimgt.api.model.ConfigurationDto) SettingsKeyManagerConfigurationDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.SettingsKeyManagerConfigurationDTO)

Aggregations

ConfigurationDto (org.wso2.carbon.apimgt.api.model.ConfigurationDto)8 KeyManagerConnectorConfiguration (org.wso2.carbon.apimgt.api.model.KeyManagerConnectorConfiguration)5 JsonObject (com.google.gson.JsonObject)4 JSONObject (org.json.simple.JSONObject)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 Gson (com.google.gson.Gson)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 Type (java.lang.reflect.Type)1 Map (java.util.Map)1 JSONParser (org.json.simple.parser.JSONParser)1 ParseException (org.json.simple.parser.ParseException)1 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 KeyManagerConfigurationDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO)1 SettingsKeyManagerConfigurationDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.SettingsKeyManagerConfigurationDTO)1 KeyManagerInfoDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.KeyManagerInfoDTO)1 KeyManagerApplicationConfigurationDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.KeyManagerApplicationConfigurationDTO)1