本文整理匯總了Java中org.springframework.vault.core.VaultTemplate類的典型用法代碼示例。如果您正苦於以下問題:Java VaultTemplate類的具體用法?Java VaultTemplate怎麽用?Java VaultTemplate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
VaultTemplate類屬於org.springframework.vault.core包,在下文中一共展示了VaultTemplate類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shouldCreateVaultTemplateWithConfig
import org.springframework.vault.core.VaultTemplate; //導入依賴的package包/類
@Test
public void shouldCreateVaultTemplateWithConfig() {
VaultServiceConnectorConfig config = VaultServiceConnectorConfig.builder() //
.clientOptions(new ClientOptions(10, 20)) //
.sslConfiguration(SslConfiguration.NONE) //
.build();
VaultServiceInfo serviceInfo = new VaultServiceInfo("vault",
"http://localhost:8200", "token".toCharArray(), Collections.emptyMap(),
Collections.emptyMap());
VaultTemplate vaultTemplate = creator.create(serviceInfo, config);
vaultTemplate.afterPropertiesSet();
assertThat(vaultTemplate).isNotNull();
}
示例2: main
import org.springframework.vault.core.VaultTemplate; //導入依賴的package包/類
public static void main(String[] args) {
VaultTemplate vaultTemplate = new VaultTemplate(new VaultEndpoint(),
new TokenAuthentication("00000000-0000-0000-0000-000000000000"));
Secrets secrets = new Secrets();
secrets.username = "hello";
secrets.password = "world";
vaultTemplate.write("secret/myapp", secrets);
VaultResponseSupport<Secrets> response = vaultTemplate.read("secret/myapp",
Secrets.class);
System.out.println(response.getData().getUsername());
vaultTemplate.delete("secret/myapp");
}
示例3: VaultRule
import org.springframework.vault.core.VaultTemplate; //導入依賴的package包/類
/**
* Create a new {@link VaultRule} with the given {@link SslConfiguration} and
* {@link VaultEndpoint}.
*
* @param sslConfiguration must not be {@literal null}.
* @param vaultEndpoint must not be {@literal null}.
*/
public VaultRule(SslConfiguration sslConfiguration, VaultEndpoint vaultEndpoint) {
Assert.notNull(sslConfiguration, "SslConfiguration must not be null");
Assert.notNull(vaultEndpoint, "VaultEndpoint must not be null");
RestTemplate restTemplate = TestRestTemplateFactory.create(sslConfiguration);
WebClient webClient = TestWebClientFactory.create(sslConfiguration);
VaultTemplate vaultTemplate = new VaultTemplate(
TestRestTemplateFactory.TEST_VAULT_ENDPOINT,
restTemplate.getRequestFactory(), new PreparingSessionManager());
this.token = Settings.token();
this.prepareVault = new PrepareVault(webClient,
TestRestTemplateFactory.create(sslConfiguration), vaultTemplate);
this.vaultEndpoint = vaultEndpoint;
}
示例4: VaultRule
import org.springframework.vault.core.VaultTemplate; //導入依賴的package包/類
/**
* Create a new {@link VaultRule} with the given {@link SslConfiguration} and
* {@link VaultEndpoint}.
*
* @param sslConfiguration must not be {@literal null}.
* @param vaultEndpoint must not be {@literal null}.
*/
public VaultRule(SslConfiguration sslConfiguration, VaultEndpoint vaultEndpoint) {
Assert.notNull(sslConfiguration, "SslConfiguration must not be null");
Assert.notNull(vaultEndpoint, "VaultEndpoint must not be null");
ClientHttpRequestFactory requestFactory = TestRestTemplateFactory.create(
sslConfiguration).getRequestFactory();
VaultTemplate vaultTemplate = new VaultTemplate(vaultEndpoint, requestFactory,
new PreparingSessionManager());
this.token = Settings.token();
this.prepareVault = new PrepareVault(vaultTemplate);
this.vaultEndpoint = vaultEndpoint;
}
示例5: create
import org.springframework.vault.core.VaultTemplate; //導入依賴的package包/類
@Override
public VaultTemplate create(VaultServiceInfo serviceInfo,
ServiceConnectorConfig serviceConnectorConfig) {
TokenAuthentication tokenAuthentication = new TokenAuthentication(new String(
serviceInfo.getToken()));
SimpleSessionManager sessionManager = new SimpleSessionManager(
tokenAuthentication);
// early pre-init
assert sessionManager.getSessionToken() != null;
ClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
if (serviceConnectorConfig != null
&& serviceConnectorConfig instanceof VaultServiceConnectorConfig) {
VaultServiceConnectorConfig config = (VaultServiceConnectorConfig) serviceConnectorConfig;
requestFactory = config.getClientHttpRequestFactory();
}
VaultEndpoint endpoint = VaultEndpoint.from(URI.create(serviceInfo.getUri()));
return new VaultTemplate(endpoint, requestFactory, sessionManager);
}
示例6: shouldCreateVaultTemplate
import org.springframework.vault.core.VaultTemplate; //導入依賴的package包/類
@Test
public void shouldCreateVaultTemplate() {
VaultServiceInfo serviceInfo = new VaultServiceInfo("vault",
"http://localhost:8200", "token".toCharArray(), Collections.emptyMap(),
Collections.emptyMap());
VaultTemplate vaultTemplate = creator.create(serviceInfo, null);
vaultTemplate.afterPropertiesSet();
assertThat(vaultTemplate).isNotNull();
}
示例7: vaultTemplate
import org.springframework.vault.core.VaultTemplate; //導入依賴的package包/類
/**
* Creates a {@link VaultTemplate}.
*
* @return
* @see #clientHttpRequestFactoryWrapper()
*/
@Bean
@ConditionalOnMissingBean
public VaultTemplate vaultTemplate(SessionManager sessionManager) {
return new VaultTemplate(endpointProvider, clientHttpRequestFactoryWrapper()
.getClientHttpRequestFactory(), sessionManager);
}
示例8: shouldContainVaultBeans
import org.springframework.vault.core.VaultTemplate; //導入依賴的package包/類
@Test
public void shouldContainVaultBeans() {
// Beans are registered in parent (bootstrap) context.
ApplicationContext parent = applicationContext.getParent();
assertThat(parent.getBeanNamesForType(VaultTemplate.class)).isNotEmpty();
assertThat(parent.getBeanNamesForType(LeasingVaultPropertySourceLocator.class))
.isNotEmpty();
}
示例9: shouldNotContainVaultBeans
import org.springframework.vault.core.VaultTemplate; //導入依賴的package包/類
@Test
public void shouldNotContainVaultBeans() {
// Beans are registered in parent (bootstrap) context.
ApplicationContext parent = applicationContext.getParent();
assertThat(parent.getBeanNamesForType(VaultTemplate.class)).isEmpty();
assertThat(parent.getBeanNamesForType(VaultPropertySourceLocator.class))
.isEmpty();
}
示例10: vaultOperations
import org.springframework.vault.core.VaultTemplate; //導入依賴的package包/類
@Override
public VaultOperations vaultOperations(VaultServiceConnectorConfig config) {
return cloudConfig.cloud().getSingletonServiceConnector(VaultTemplate.class,
config);
}
開發者ID:pivotal-cf,項目名稱:spring-cloud-vault-connector,代碼行數:6,代碼來源:VaultCloudServiceConnectionFactory.java
示例11: vaultTemplate
import org.springframework.vault.core.VaultTemplate; //導入依賴的package包/類
/**
* Create a {@link VaultTemplate}.
*
* @return the {@link VaultTemplate}.
* @see #vaultEndpointProvider()
* @see #clientHttpRequestFactoryWrapper()
* @see #sessionManager()
*/
@Bean
public VaultTemplate vaultTemplate() {
return new VaultTemplate(vaultEndpointProvider(),
clientHttpRequestFactoryWrapper().getClientHttpRequestFactory(),
sessionManager());
}