Search in sources :

Example 1 with DecryptedKeyPair

use of com.walmartlabs.concord.server.org.secret.SecretManager.DecryptedKeyPair in project concord by walmartlabs.

the class SecretResource method createKeyPair.

private PublicKeyResponse createKeyPair(UUID orgId, UUID projectId, String name, String storePassword, SecretVisibility visibility, MultipartInput input, String storeType) throws IOException {
    DecryptedKeyPair k;
    InputStream publicKey = MultipartUtils.getStream(input, Constants.Multipart.PUBLIC);
    if (publicKey != null) {
        InputStream privateKey = MultipartUtils.assertStream(input, Constants.Multipart.PRIVATE);
        try {
            k = secretManager.createKeyPair(orgId, projectId, name, storePassword, publicKey, privateKey, visibility, storeType);
        } catch (IllegalArgumentException e) {
            throw new ValidationErrorsException(e.getMessage());
        }
    } else {
        k = secretManager.createKeyPair(orgId, projectId, name, storePassword, visibility, storeType);
    }
    return new PublicKeyResponse(k.getId(), OperationResult.CREATED, storePassword, new String(k.getData()));
}
Also used : DecryptedKeyPair(com.walmartlabs.concord.server.org.secret.SecretManager.DecryptedKeyPair) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ValidationErrorsException(org.sonatype.siesta.ValidationErrorsException)

Aggregations

DecryptedKeyPair (com.walmartlabs.concord.server.org.secret.SecretManager.DecryptedKeyPair)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ValidationErrorsException (org.sonatype.siesta.ValidationErrorsException)1