Search in sources :

Example 1 with SecretProviderConfiguration

use of alien4cloud.model.secret.SecretProviderConfiguration 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)

Example 2 with SecretProviderConfiguration

use of alien4cloud.model.secret.SecretProviderConfiguration in project alien4cloud by alien4cloud.

the class SecretProviderRegistry method usage.

@Override
public List<PluginUsage> usage(String pluginId) {
    GetMultipleDataResult<Location> locationData = alienDAO.buildQuery(Location.class).prepareSearch().search(0, Integer.MAX_VALUE);
    List<PluginUsage> usages = Lists.newArrayList();
    for (Location location : locationData.getData()) {
        SecretProviderConfiguration locationSecretProviderConfiguration = location.getSecretProviderConfiguration();
        if (locationSecretProviderConfiguration != null && locationSecretProviderConfiguration.getPluginName().equals(pluginId)) {
            usages.add(new PluginUsage(location.getId(), location.getName(), Location.class.getSimpleName()));
        }
    }
    return usages;
}
Also used : PluginUsage(alien4cloud.plugin.model.PluginUsage) Location(alien4cloud.model.orchestrators.locations.Location) SecretProviderConfiguration(alien4cloud.model.secret.SecretProviderConfiguration)

Example 3 with SecretProviderConfiguration

use of alien4cloud.model.secret.SecretProviderConfiguration in project alien4cloud by alien4cloud.

the class LocationSecretProviderSteps method iUseAsTheSecretProviderAndIUpdateTheConfigurationOfSecretProviderRelatedToTheLocationOfTheOrchestrator.

@And("^I use \"([^\"]*)\" as the secret provider and I update the configuration of secret provider related to the location \"([^\"]*)\" of the orchestrator \"([^\"]*)\"$")
public void iUseAsTheSecretProviderAndIUpdateTheConfigurationOfSecretProviderRelatedToTheLocationOfTheOrchestrator(String pluginName, String locationName, String orchestratorName, DataTable table) throws Throwable {
    String orchestratorId = Context.getInstance().getOrchestratorId(orchestratorName);
    String locationId = Context.getInstance().getLocationId(orchestratorId, locationName);
    String restUrl = String.format("/rest/v1/orchestrators/%s/locations/%s", orchestratorId, locationId);
    SecretProviderConfiguration secretProviderConfiguration = new SecretProviderConfiguration();
    secretProviderConfiguration.setPluginName(pluginName);
    Map<String, Object> configuration = DataTableUtils.dataTableToMap(table);
    // Read the certificate file by passing the path of this file
    configuration.put("certificate", new String(Files.readAllBytes(Paths.get((String) configuration.get("certificate")))));
    secretProviderConfiguration.setConfiguration(configuration);
    UpdateLocationRequest request = new UpdateLocationRequest();
    request.setName(locationName);
    request.setSecretProviderConfiguration(secretProviderConfiguration);
    String restResponse = Context.getRestClientInstance().putJSon(restUrl, JsonUtil.toString(request));
    Context.getInstance().registerRestResponse(restResponse);
}
Also used : UpdateLocationRequest(alien4cloud.rest.orchestrator.model.UpdateLocationRequest) SecretProviderConfiguration(alien4cloud.model.secret.SecretProviderConfiguration) And(cucumber.api.java.en.And)

Example 4 with SecretProviderConfiguration

use of alien4cloud.model.secret.SecretProviderConfiguration in project alien4cloud by alien4cloud.

the class RuntimeStepDefinitions method iScaleUpTheNodeByAddingInstanceSWithTheFollowingCredentialsDefinedByTheSecretProviderPlugin.

@When("^I scale up the node \"([^\"]*)\" by adding (\\d+) instance\\(s\\) with the following credentials defined by the secret provider plugin \"([^\"]*)\"$")
public void iScaleUpTheNodeByAddingInstanceSWithTheFollowingCredentialsDefinedByTheSecretProviderPlugin(String nodeName, int instancesToAdd, String pluginName, DataTable table) throws Throwable {
    log.info("Scale up the node " + nodeName + " by " + instancesToAdd);
    SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials = new SecretProviderConfigurationAndCredentials();
    secretProviderConfigurationAndCredentials.setCredentials(DataTableUtils.dataTableToMap(table));
    SecretProviderConfiguration secretProviderConfiguration = new SecretProviderConfiguration();
    secretProviderConfiguration.setPluginName(pluginName);
    secretProviderConfigurationAndCredentials.setSecretProviderConfiguration(secretProviderConfiguration);
    Context.getInstance().registerRestResponse(scale(nodeName, instancesToAdd, secretProviderConfigurationAndCredentials));
    log.info("Finished scaling up the node " + nodeName + " by " + instancesToAdd);
}
Also used : SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials) SecretProviderConfiguration(alien4cloud.model.secret.SecretProviderConfiguration) When(cucumber.api.java.en.When)

Example 5 with SecretProviderConfiguration

use of alien4cloud.model.secret.SecretProviderConfiguration in project alien4cloud by alien4cloud.

the class WorkflowStepDefinition method iLaunchTheWorkflowInTheEnvironmentViewAfterTheDeploymentWithTheFollowingSecretCredentials.

@When("^I launch the workflow \"([^\"]*)\" in the environment view after the deployment using the secret provider \"([^\"]*)\" with the following secret credentials:$")
public void iLaunchTheWorkflowInTheEnvironmentViewAfterTheDeploymentWithTheFollowingSecretCredentials(String workflowName, String pluginName, DataTable table) throws Throwable {
    String path = "/rest/v1/applications/" + ApplicationStepDefinitions.CURRENT_APPLICATION.getId() + "/environments/" + Context.getInstance().getDefaultApplicationEnvironmentId(ApplicationStepDefinitions.CURRENT_APPLICATION.getName()) + "/workflows/" + workflowName;
    SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials = new SecretProviderConfigurationAndCredentials();
    SecretProviderConfiguration secretProviderConfiguration = new SecretProviderConfiguration();
    secretProviderConfiguration.setPluginName(pluginName);
    secretProviderConfigurationAndCredentials.setSecretProviderConfiguration(secretProviderConfiguration);
    secretProviderConfigurationAndCredentials.setCredentials(DataTableUtils.dataTableToMap(table));
    String result = Context.getRestClientInstance().postJSon(path, JsonUtil.toString(secretProviderConfigurationAndCredentials));
    Context.getInstance().registerRestResponse(result);
}
Also used : SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials) SecretProviderConfiguration(alien4cloud.model.secret.SecretProviderConfiguration) When(cucumber.api.java.en.When)

Aggregations

SecretProviderConfiguration (alien4cloud.model.secret.SecretProviderConfiguration)5 SecretProviderConfigurationAndCredentials (alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials)3 When (cucumber.api.java.en.When)2 Location (alien4cloud.model.orchestrators.locations.Location)1 SecretAuthResponse (alien4cloud.model.secret.SecretAuthResponse)1 PluginUsage (alien4cloud.plugin.model.PluginUsage)1 UpdateLocationRequest (alien4cloud.rest.orchestrator.model.UpdateLocationRequest)1 And (cucumber.api.java.en.And)1 ISecretProvider (org.alien4cloud.secret.ISecretProvider)1