當前位置: 首頁>>代碼示例>>Java>>正文


Java VaultTemplate類代碼示例

本文整理匯總了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();
}
 
開發者ID:pivotal-cf,項目名稱:spring-cloud-vault-connector,代碼行數:18,代碼來源:VaultTemplateCreatorUnitTests.java

示例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");
	}
 
開發者ID:spring-projects,項目名稱:spring-vault,代碼行數:18,代碼來源:VaultApp.java

示例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;
}
 
開發者ID:spring-projects,項目名稱:spring-vault,代碼行數:26,代碼來源:VaultRule.java

示例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;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-vault,代碼行數:23,代碼來源:VaultRule.java

示例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);
}
 
開發者ID:pivotal-cf,項目名稱:spring-cloud-vault-connector,代碼行數:27,代碼來源:VaultTemplateCreator.java

示例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();
}
 
開發者ID:pivotal-cf,項目名稱:spring-cloud-vault-connector,代碼行數:13,代碼來源:VaultTemplateCreatorUnitTests.java

示例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);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-vault,代碼行數:13,代碼來源:VaultBootstrapConfiguration.java

示例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();
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-vault,代碼行數:11,代碼來源:VaultConfigTests.java

示例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();
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-vault,代碼行數:11,代碼來源:VaultConfigDisabledTests.java

示例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());
}
 
開發者ID:spring-projects,項目名稱:spring-vault,代碼行數:15,代碼來源:AbstractVaultConfiguration.java


注:本文中的org.springframework.vault.core.VaultTemplate類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。