Example usage for org.springframework.vault.core VaultOperations opsForPki

List of usage examples for org.springframework.vault.core VaultOperations opsForPki

Introduction

In this page you can find the example usage for org.springframework.vault.core VaultOperations opsForPki.

Prototype

VaultPkiOperations opsForPki(String path);

Source Link

Document

Return VaultPkiOperations if the PKI backend is mounted on a different path than pki .

Usage

From source file:example.pki.CertificateUtil.java

private static VaultCertificateResponse requestCertificate(VaultOperations vaultOperations,
        VaultPkiProperties pkiProperties) {

    logger.info("Requesting SSL certificate from Vault for: {}", pkiProperties.getCommonName());

    VaultCertificateRequest certificateRequest = VaultCertificateRequest.builder()
            .commonName(pkiProperties.getCommonName())
            .altNames(pkiProperties.getAltNames() != null ? pkiProperties.getAltNames()
                    : Collections.<String>emptyList())
            .build();// w  w  w.  ja va2  s.co m

    VaultCertificateResponse certificateResponse = vaultOperations.opsForPki(pkiProperties.getBackend())
            .issueCertificate(pkiProperties.getRole(), certificateRequest);

    return certificateResponse;
}