Search in sources :

Example 6 with KeyManagerConnectorConfiguration

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);
                }
            }
        }
    }
}
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 KeyManagerConnectorConfiguration

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));
                }
            }
        }
    }
}
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 KeyManagerConnectorConfiguration

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);
        }
    }
}
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)

Aggregations

KeyManagerConnectorConfiguration (org.wso2.carbon.apimgt.api.model.KeyManagerConnectorConfiguration)8 JsonObject (com.google.gson.JsonObject)5 ConfigurationDto (org.wso2.carbon.apimgt.api.model.ConfigurationDto)5 JSONObject (org.json.simple.JSONObject)4 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JsonElement (com.google.gson.JsonElement)1 JsonParser (com.google.gson.JsonParser)1 Map (java.util.Map)1 JSONObject (org.json.JSONObject)1 JSONParser (org.json.simple.parser.JSONParser)1 ParseException (org.json.simple.parser.ParseException)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 KeyManager (org.wso2.carbon.apimgt.api.model.KeyManager)1 OAuthApplicationInfo (org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo)1 AMDefaultKeyManagerImpl (org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl)1 APIManagerConfiguration (org.wso2.carbon.apimgt.impl.APIManagerConfiguration)1 KeyManagerDto (org.wso2.carbon.apimgt.impl.dto.KeyManagerDto)1