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