List of usage examples for org.springframework.vault.core VaultOperations write
@Nullable VaultResponse write(String path, @Nullable Object body);
From source file:example.helloworld.PropertySourceTests.java
/** * Write some data to Vault before Vault can be used as * {@link org.springframework.vault.annotation.VaultPropertySource}. *///ww w . jav a 2s. co m @BeforeClass public static void beforeClass() { VaultOperations vaultOperations = new VaultTestConfiguration().vaultTemplate(); vaultOperations.write("secret/myapp/configuration", Collections.singletonMap("configuration.key", "value")); }
From source file:example.helloworld.CubbyholeAuthenticationTests.java
/** * Write some data to Vault before Vault can be used as {@link VaultPropertySource}. *//* w w w . j av a 2 s .c o m*/ @BeforeClass public static void beforeClass() { VaultOperations vaultOperations = new VaultTestConfiguration().vaultTemplate(); vaultOperations.write("secret/myapp/configuration", Collections.singletonMap("configuration.key", "value")); VaultResponse response = vaultOperations.doWithSession(new RestOperationsCallback<VaultResponse>() { @Override public VaultResponse doWithRestOperations(RestOperations restOperations) { HttpHeaders headers = new HttpHeaders(); headers.add("X-Vault-Wrap-TTL", "10m"); return restOperations.postForObject("auth/token/create", new HttpEntity<Object>(headers), VaultResponse.class); } }); // Response Wrapping requires Vault 0.6.0+ Map<String, String> wrapInfo = response.getWrapInfo(); initialToken = VaultToken.of(wrapInfo.get("token")); }
From source file:example.pki.CertificateUtil.java
private static void storeCertificate(String cacheKey, VaultOperations vaultOperations, VaultHealth health, VaultCertificateResponse certificateResponse) { CertificateBundle certificateBundle = certificateResponse.getData(); long expires = (health.getServerTimeUtc() + certificateResponse.getLeaseDuration()) - REFRESH_PERIOD_BEFORE_EXPIRY; CachedCertificateBundle cachedCertificateBundle = new CachedCertificateBundle(); cachedCertificateBundle.setExpires(expires); cachedCertificateBundle.setTimeRequested(health.getServerTimeUtc()); cachedCertificateBundle.setPrivateKey(certificateBundle.getPrivateKey()); cachedCertificateBundle.setCertificate(certificateBundle.getCertificate()); cachedCertificateBundle.setIssuingCaCertificate(certificateBundle.getIssuingCaCertificate()); cachedCertificateBundle.setSerialNumber(certificateBundle.getSerialNumber()); vaultOperations.write(cacheKey, cachedCertificateBundle); }