use of com.sequenceiq.cloudbreak.api.model.CertificateResponse 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.cloudbreak.api.model.CertificateResponse in project cloudbreak by hortonworks.
the class TlsSecurityService method getCertificates.
public CertificateResponse getCertificates(Long stackId) {
SecurityConfig securityConfig = securityConfigRepository.findOneByStackId(stackId);
if (securityConfig == null) {
throw new NotFoundException("Security config doesn't exist.");
}
String serverCert = instanceMetaDataRepository.getServerCertByStackId(stackId);
if (serverCert == null) {
throw new NotFoundException("Server certificate was not found.");
}
return new CertificateResponse(decodeBase64(serverCert), securityConfig.getClientKeyDecoded().getBytes(), securityConfig.getClientCertDecoded().getBytes());
}
Aggregations