Search in sources :

Example 1 with SpringSsl

use of com.netflix.spinnaker.halyard.config.model.v1.security.SpringSsl in project halyard by spinnaker.

the class SpringSslEditCommand method executeThis.

@Override
protected void executeThis() {
    String currentDeployment = getCurrentDeployment();
    SpringSsl springSsl = new OperationHandler<SpringSsl>().setOperation(Daemon.getSpringSsl(currentDeployment, false)).setFailureMesssage("Failed to load SSL settings.").get();
    int originalHash = springSsl.hashCode();
    springSsl.setKeyAlias(isSet(keyAlias) ? keyAlias : springSsl.getKeyAlias());
    springSsl.setKeyStore(isSet(keyStore) ? keyStore : springSsl.getKeyStore());
    springSsl.setKeyStoreType(isSet(keyStoreType) ? keyStoreType : springSsl.getKeyStoreType());
    springSsl.setKeyStorePassword(isSet(keyStorePassword) ? keyStorePassword : springSsl.getKeyStorePassword());
    springSsl.setTrustStore(isSet(trustStore) ? trustStore : springSsl.getTrustStore());
    springSsl.setTrustStoreType(isSet(trustStoreType) ? trustStoreType : springSsl.getTrustStoreType());
    springSsl.setTrustStorePassword(isSet(trustStorePassword) ? trustStorePassword : springSsl.getTrustStorePassword());
    springSsl.setClientAuth(isSet(clientAuth) ? clientAuth : springSsl.getClientAuth());
    if (originalHash == springSsl.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setOperation(Daemon.setSpringSsl(currentDeployment, !noValidate, springSsl)).setFailureMesssage("Failed to edit SSL settings.").setFailureMesssage("Successfully updated SSL settings.").get();
}
Also used : SpringSsl(com.netflix.spinnaker.halyard.config.model.v1.security.SpringSsl) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 2 with SpringSsl

use of com.netflix.spinnaker.halyard.config.model.v1.security.SpringSsl in project halyard by spinnaker.

the class SecurityController method setSpringSSl.

@RequestMapping(value = "/api/ssl/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setSpringSSl(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawSpringSsl) {
    SpringSsl apacheSsl = objectMapper.convertValue(rawSpringSsl, SpringSsl.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> apacheSsl.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> securityService.setSpringSsl(deploymentName, apacheSsl));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> securityService.validateSpringSsl(deploymentName));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit API SSL settings");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) SpringSsl(com.netflix.spinnaker.halyard.config.model.v1.security.SpringSsl) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SpringSsl (com.netflix.spinnaker.halyard.config.model.v1.security.SpringSsl)2 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)1 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)1 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)1 Path (java.nio.file.Path)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1