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