Search in sources :

Example 1 with ISecretProvider

use of org.alien4cloud.secret.ISecretProvider in project alien4cloud by alien4cloud.

the class SecretProviderService method internalGenerateToken.

/**
 * Generate a token wrapped in an instance of SecretProviderConfigurationAndCredentials by authenticating the credentials (username, password) with ldap
 *
 * @param locationConfiguration
 * @param credentials
 * @return SecretProviderConfigurationAndCredentials wrapping a token
 */
private SecretProviderConfigurationAndCredentials internalGenerateToken(SecretProviderConfiguration locationConfiguration, Object credentials) {
    // Instead of saving the credentials username and password, we transform the username and password to a client token
    ISecretProvider secretProvider = this.getPluginBean(locationConfiguration.getPluginName());
    Object configuration = this.getPluginConfiguration(locationConfiguration.getPluginName(), locationConfiguration.getConfiguration());
    SecretAuthResponse authResponse = secretProvider.auth(configuration, this.getCredentials(locationConfiguration.getPluginName(), configuration, credentials));
    SecretProviderConfigurationAndCredentials result = new SecretProviderConfigurationAndCredentials();
    SecretProviderConfiguration secretProviderConfiguration = new SecretProviderConfiguration();
    secretProviderConfiguration.setPluginName(locationConfiguration.getPluginName());
    secretProviderConfiguration.setConfiguration(authResponse.getConfiguration());
    result.setSecretProviderConfiguration(secretProviderConfiguration);
    result.setCredentials(authResponse.getCredentials());
    return result;
}
Also used : ISecretProvider(org.alien4cloud.secret.ISecretProvider) SecretAuthResponse(alien4cloud.model.secret.SecretAuthResponse) SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials) SecretProviderConfiguration(alien4cloud.model.secret.SecretProviderConfiguration)

Aggregations

SecretProviderConfigurationAndCredentials (alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials)1 SecretAuthResponse (alien4cloud.model.secret.SecretAuthResponse)1 SecretProviderConfiguration (alien4cloud.model.secret.SecretProviderConfiguration)1 ISecretProvider (org.alien4cloud.secret.ISecretProvider)1