Search in sources :

Example 1 with SignCertificateRequest

use of org.platformlayer.auth.v1.SignCertificateRequest in project platformlayer by platformlayer.

the class PlatformLayerAuthAdminClient method signCsr.

// This can actually be moved to the user-auth system
public List<X509Certificate> signCsr(String projectKey, CryptoKey projectSecret, String csr) {
    String url = "pki/csr";
    SignCertificateRequest request = new SignCertificateRequest();
    request.setProject(projectKey);
    request.setCsr(csr);
    request.setProjectSecret(FathomdbCrypto.serialize(projectSecret));
    try {
        SignCertificateResponse response = doSimpleXmlRequest(HttpMethod.POST, url, request, SignCertificateResponse.class);
        List<X509Certificate> certificates = Lists.newArrayList();
        for (String cert : response.getCertificates()) {
            certificates.addAll(CertificateUtils.fromPem(cert));
        }
        return certificates;
    } catch (RestClientException e) {
        throw new IllegalArgumentException("Error while signing certificate", e);
    }
}
Also used : SignCertificateRequest(org.platformlayer.auth.v1.SignCertificateRequest) RestClientException(org.platformlayer.rest.RestClientException) X509Certificate(java.security.cert.X509Certificate) SignCertificateResponse(org.platformlayer.auth.v1.SignCertificateResponse)

Aggregations

X509Certificate (java.security.cert.X509Certificate)1 SignCertificateRequest (org.platformlayer.auth.v1.SignCertificateRequest)1 SignCertificateResponse (org.platformlayer.auth.v1.SignCertificateResponse)1 RestClientException (org.platformlayer.rest.RestClientException)1