Search in sources :

Example 1 with CertificateResponse

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));
}
Also used : SecurityConfig(com.sequenceiq.periscope.domain.SecurityConfig) CertificateResponse(com.sequenceiq.cloudbreak.api.model.CertificateResponse)

Example 2 with CertificateResponse

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());
}
Also used : SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) CertificateResponse(com.sequenceiq.cloudbreak.api.model.CertificateResponse) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException)

Aggregations

CertificateResponse (com.sequenceiq.cloudbreak.api.model.CertificateResponse)2 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 SecurityConfig (com.sequenceiq.cloudbreak.domain.SecurityConfig)1 SecurityConfig (com.sequenceiq.periscope.domain.SecurityConfig)1