Search in sources :

Example 1 with SecurityConfig

use of com.sequenceiq.periscope.domain.SecurityConfig in project cloudbreak by hortonworks.

the class ClusterCreationEvaluator method createAmbariStack.

private AmbariStack createAmbariStack(AutoscaleStackResponse stack) {
    String host = stack.getAmbariServerIp();
    String gatewayPort = String.valueOf(stack.getGatewayPort());
    SecurityConfig securityConfig = tlsSecurityService.prepareSecurityConfig(stack.getStackId());
    return new AmbariStack(new Ambari(host, gatewayPort, stack.getUserName(), stack.getPassword()), stack.getStackId(), securityConfig);
}
Also used : AmbariStack(com.sequenceiq.periscope.model.AmbariStack) SecurityConfig(com.sequenceiq.periscope.domain.SecurityConfig) Ambari(com.sequenceiq.periscope.domain.Ambari)

Example 2 with SecurityConfig

use of com.sequenceiq.periscope.domain.SecurityConfig in project cloudbreak by hortonworks.

the class TlsSecurityService method getConfiguration.

public TlsConfiguration getConfiguration(Cluster cluster) {
    SecurityConfig securityConfig = cluster.getSecurityConfig();
    if (securityConfig != null) {
        return new TlsConfiguration(securityConfig.getClientKeyDecoded(), securityConfig.getClientCertDecoded(), securityConfig.getServerCertDecoded());
    }
    securityConfig = securityConfigRepository.findByClusterId(cluster.getId());
    if (securityConfig == null) {
        securityConfig = prepareSecurityConfig(cluster.getStackId());
    }
    return new TlsConfiguration(securityConfig.getClientKeyDecoded(), securityConfig.getClientCertDecoded(), securityConfig.getServerCertDecoded());
}
Also used : SecurityConfig(com.sequenceiq.periscope.domain.SecurityConfig) TlsConfiguration(com.sequenceiq.periscope.model.TlsConfiguration)

Example 3 with SecurityConfig

use of com.sequenceiq.periscope.domain.SecurityConfig in project cloudbreak by hortonworks.

the class TlsSecurityService method prepareSecurityConfig.

public SecurityConfig prepareSecurityConfig(Long stackId) {
    CertificateResponse response = cloudbreakClient.stackV1Endpoint().getCertificate(stackId);
    byte[] serverCert = Base64.encode(response.getServerCert());
    byte[] clientKey = Base64.encode(response.getClientKey());
    byte[] clientCert = Base64.encode(response.getClientCert());
    return new SecurityConfig(new String(clientKey), new String(clientCert), new String(serverCert));
}
Also used : SecurityConfig(com.sequenceiq.periscope.domain.SecurityConfig) CertificateResponse(com.sequenceiq.cloudbreak.api.model.CertificateResponse)

Example 4 with SecurityConfig

use of com.sequenceiq.periscope.domain.SecurityConfig in project cloudbreak by hortonworks.

the class ClusterService method create.

public Cluster create(Cluster cluster, PeriscopeUser user, AmbariStack stack, ClusterState clusterState) {
    PeriscopeUser periscopeUser = createUserIfAbsent(user);
    validateClusterUniqueness(stack);
    cluster.setUser(periscopeUser);
    cluster.setAmbari(stack.getAmbari());
    cluster.setStackId(stack.getStackId());
    if (clusterState != null) {
        cluster.setState(clusterState);
    }
    cluster = save(cluster);
    if (stack.getSecurityConfig() != null) {
        SecurityConfig securityConfig = stack.getSecurityConfig();
        securityConfig.setCluster(cluster);
        securityConfigRepository.save(securityConfig);
    }
    return cluster;
}
Also used : SecurityConfig(com.sequenceiq.periscope.domain.SecurityConfig) PeriscopeUser(com.sequenceiq.periscope.domain.PeriscopeUser)

Example 5 with SecurityConfig

use of com.sequenceiq.periscope.domain.SecurityConfig in project cloudbreak by hortonworks.

the class ClusterSecurityService method tryResolve.

public AmbariStack tryResolve(Ambari ambari) {
    try {
        String host = ambari.getHost();
        String user = ambari.getUser();
        String pass = ambari.getPass();
        AmbariAddressJson ambariAddressJson = new AmbariAddressJson();
        ambariAddressJson.setAmbariAddress(host);
        StackResponse stack = cloudbreakClient.stackV1Endpoint().getStackForAmbari(ambariAddressJson);
        Long id = stack.getId();
        SecurityConfig securityConfig = tlsSecurityService.prepareSecurityConfig(id);
        if (user == null || pass == null) {
            AutoscaleClusterResponse clusterResponse = cloudbreakClient.clusterEndpoint().getForAutoscale(id);
            return new AmbariStack(new Ambari(host, ambari.getPort(), clusterResponse.getUserName(), clusterResponse.getPassword()), id, securityConfig);
        } else {
            return new AmbariStack(ambari, id, securityConfig);
        }
    } catch (RuntimeException ignored) {
        return new AmbariStack(ambari);
    }
}
Also used : AmbariStack(com.sequenceiq.periscope.model.AmbariStack) AutoscaleClusterResponse(com.sequenceiq.cloudbreak.api.model.AutoscaleClusterResponse) AmbariAddressJson(com.sequenceiq.cloudbreak.api.model.AmbariAddressJson) SecurityConfig(com.sequenceiq.periscope.domain.SecurityConfig) Ambari(com.sequenceiq.periscope.domain.Ambari) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse)

Aggregations

SecurityConfig (com.sequenceiq.periscope.domain.SecurityConfig)6 Ambari (com.sequenceiq.periscope.domain.Ambari)2 AmbariStack (com.sequenceiq.periscope.model.AmbariStack)2 AmbariAddressJson (com.sequenceiq.cloudbreak.api.model.AmbariAddressJson)1 AutoscaleClusterResponse (com.sequenceiq.cloudbreak.api.model.AutoscaleClusterResponse)1 CertificateResponse (com.sequenceiq.cloudbreak.api.model.CertificateResponse)1 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)1 ClusterState (com.sequenceiq.periscope.api.model.ClusterState)1 Cluster (com.sequenceiq.periscope.domain.Cluster)1 PeriscopeUser (com.sequenceiq.periscope.domain.PeriscopeUser)1 TlsConfiguration (com.sequenceiq.periscope.model.TlsConfiguration)1