本文整理汇总了Java中org.springframework.security.saml.key.KeyManager类的典型用法代码示例。如果您正苦于以下问题:Java KeyManager类的具体用法?Java KeyManager怎么用?Java KeyManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyManager类属于org.springframework.security.saml.key包,在下文中一共展示了KeyManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Before
public void setup() {
SAMLSSOProperties properties = mock(SAMLSSOProperties.class);
keyManagerProperties = mock(KeyManagerProperties.class);
when(properties.getKeyManager()).thenReturn(keyManagerProperties);
// when(keyManagerProperties.getDefaultKey()).thenReturn("default");
// when(keyManagerProperties.getKeyPasswords()).thenReturn(Collections.singletonMap("default", "password"));
// when(keyManagerProperties.getPrivateKeyDerLocation()).thenReturn("classpath:localhost:key.der");
// when(keyManagerProperties.getPublicKeyPemLocation()).thenReturn("classpath:localhost.cert");
// when(keyManagerProperties.getStoreLocation()).thenReturn("classpath:KeyStore.jks");
// when(keyManagerProperties.getStorePass()).thenReturn("storePass");
builder = mock(ServiceProviderBuilder.class);
when(builder.getSharedObject(KeyManager.class)).thenReturn(null);
when(builder.getSharedObject(SAMLSSOProperties.class)).thenReturn(properties);
when(builder.getSharedObject(ResourceLoader.class)).thenReturn(new DefaultResourceLoader());
}
示例2: testArguments_keystore
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Test
public void testArguments_keystore() throws Exception {
KeyManagerConfigurer configurer = new KeyManagerConfigurer();
configurer
.keyStore(new KeystoreFactory(new DefaultResourceLoader()).createEmptyKeystore());
configurer.init(builder);
configurer.configure(builder);
ArgumentCaptor<KeyManager> providerCaptor = ArgumentCaptor.forClass(KeyManager.class);
verify(builder).setSharedObject(eq(KeyManager.class), providerCaptor.capture());
verify(keyManagerProperties).getDefaultKey();
verify(keyManagerProperties).getKeyPasswords();
verify(keyManagerProperties).getPrivateKeyDerLocation();
verify(keyManagerProperties).getPublicKeyPemLocation();
verify(keyManagerProperties).getStoreLocation();
verify(keyManagerProperties).getStorePass();
assertThat(providerCaptor.getValue()).isNotNull();
KeyManager keyManager = providerCaptor.getValue();
assertThat(keyManager.getAvailableCredentials()).isEmpty();
}
示例3: testArguments_keystore_location
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Test
public void testArguments_keystore_location() throws Exception {
KeyManagerConfigurer configurer = new KeyManagerConfigurer();
configurer
.storeLocation("classpath:KeyStore.jks")
.storePass("password")
.defaultKey("default")
.keyPassword("default", "password");
configurer.init(builder);
configurer.configure(builder);
ArgumentCaptor<KeyManager> providerCaptor = ArgumentCaptor.forClass(KeyManager.class);
verify(builder).setSharedObject(eq(KeyManager.class), providerCaptor.capture());
verify(keyManagerProperties, never()).getDefaultKey();
verify(keyManagerProperties, never()).getKeyPasswords();
verify(keyManagerProperties, never()).getStoreLocation();
verify(keyManagerProperties, never()).getStorePass();
verify(keyManagerProperties).getPrivateKeyDerLocation();
verify(keyManagerProperties).getPublicKeyPemLocation();
assertThat(providerCaptor.getValue()).isNotNull();
KeyManager keyManager = providerCaptor.getValue();
assertThat(keyManager.getAvailableCredentials()).containsExactly("default");
assertThat(keyManager.getDefaultCredential().getEntityId()).isEqualTo("default");
assertThat(keyManager.getDefaultCredentialName()).isEqualTo("default");
}
示例4: testArguments_der_and_pem
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Test
public void testArguments_der_and_pem() throws Exception {
KeyManagerConfigurer configurer = new KeyManagerConfigurer();
configurer
.publicKeyPEMLocation("classpath:localhost.cert")
.privateKeyDERLocation("classpath:localhost.key.der")
.defaultKey("localhost")
.keyPassword("localhost", "");
configurer.init(builder);
configurer.configure(builder);
ArgumentCaptor<KeyManager> providerCaptor = ArgumentCaptor.forClass(KeyManager.class);
verify(builder).setSharedObject(eq(KeyManager.class), providerCaptor.capture());
verify(keyManagerProperties, never()).getDefaultKey();
verify(keyManagerProperties, never()).getKeyPasswords();
verify(keyManagerProperties, never()).getPrivateKeyDerLocation();
verify(keyManagerProperties, never()).getPublicKeyPemLocation();
verify(keyManagerProperties).getStoreLocation();
verify(keyManagerProperties).getStorePass();
assertThat(providerCaptor.getValue()).isNotNull();
KeyManager keyManager = providerCaptor.getValue();
assertThat(keyManager.getAvailableCredentials()).containsExactly("localhost");
assertThat(keyManager.getDefaultCredential().getEntityId()).isEqualTo("localhost");
assertThat(keyManager.getDefaultCredentialName()).isEqualTo("localhost");
}
示例5: testArguments_der_and_pem_error
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testArguments_der_and_pem_error() throws Exception {
KeyManagerConfigurer configurer = new KeyManagerConfigurer();
configurer
.publicKeyPEMLocation("classpath:localhost.cert")
.privateKeyDERLocation("classpath:localhost.key.der");
configurer.init(builder);
configurer.configure(builder);
ArgumentCaptor<KeyManager> providerCaptor = ArgumentCaptor.forClass(KeyManager.class);
verify(builder).setSharedObject(eq(KeyManager.class), providerCaptor.capture());
verify(keyManagerProperties, never()).getDefaultKey();
verify(keyManagerProperties, never()).getKeyPasswords();
verify(keyManagerProperties, never()).getPrivateKeyDerLocation();
verify(keyManagerProperties, never()).getPublicKeyPemLocation();
verify(keyManagerProperties).getStoreLocation();
verify(keyManagerProperties).getStorePass();
assertThat(providerCaptor.getValue()).isNotNull();
KeyManager keyManager = providerCaptor.getValue();
assertThat(keyManager.getAvailableCredentials()).containsExactly("localhost");
assertThat(keyManager.getDefaultCredential().getEntityId()).isEqualTo("localhost");
assertThat(keyManager.getDefaultCredentialName()).isEqualTo("localhost");
}
示例6: keyManager
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Bean
public KeyManager keyManager() {
DefaultResourceLoader loader = new DefaultResourceLoader();
Resource storeFile = loader.getResource("classpath:/saml/colombia.jks");
Map<String, String> passwords = new HashMap<>();
passwords.put("colombia", "colombia-password");
String defaultKey = "colombia";
return new JKSKeyManager(storeFile, "colombia-password", passwords, defaultKey);
}
示例7: configure
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Override
public void configure(ServiceProviderBuilder builder) throws Exception {
KeyManager keyManager = builder.getSharedObject(KeyManager.class);
TLSProtocolConfigurer configurer = createDefaultTlsProtocolConfigurer();
configurer.setProtocolName(Optional.ofNullable(protocolName).orElseGet(config::getProtocolName));
configurer.setProtocolPort(Optional.ofNullable(protocolPort).orElseGet(config::getProtocolPort));
configurer.setSslHostnameVerification(Optional.ofNullable(sslHostnameVerification).orElseGet(config::getSslHostnameVerification));
configurer.setTrustedKeys(Optional.ofNullable(trustedKeys).orElseGet(config::getTrustedKeys));
configurer.setKeyManager(keyManager);
configurer.afterPropertiesSet();
builder.setSharedObject(TLSProtocolConfigurer.class, configurer);
}
示例8: init
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Override
public void init(ServiceProviderBuilder builder) throws Exception {
keyManagerBean = builder.getSharedObject(KeyManager.class);
config = builder.getSharedObject(SAMLSSOProperties.class).getKeyManager();
resourceLoader = builder.getSharedObject(ResourceLoader.class);
keystoreFactory = new KeystoreFactory(resourceLoader);
}
示例9: afterPropertiesSet
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Override
public void afterPropertiesSet() {
//All existing beans are thrown as shared objects to the ServiceProviderSecurityBuilder, which will wire all
//beans/objects related to spring security SAML.
serviceProviderBuilder.setSharedObject(ParserPool.class, ParserPoolHolder.getPool());
serviceProviderBuilder.setSharedObject(WebSSOProfileConsumerImpl.class, (WebSSOProfileConsumerImpl) webSSOProfileConsumer);
serviceProviderBuilder.setSharedObject(WebSSOProfileConsumerHoKImpl.class, hokWebSSOProfileConsumer);
serviceProviderBuilder.setSharedObject(ServiceProviderEndpoints.class, new ServiceProviderEndpoints());
serviceProviderBuilder.setSharedObject(ResourceLoader.class, resourceLoader);
serviceProviderBuilder.setSharedObject(SAMLSSOProperties.class, sAMLSsoProperties);
serviceProviderBuilder.setSharedObject(ExtendedMetadata.class, extendedMetadata);
serviceProviderBuilder.setSharedObject(LocalExtendedMetadata.class, localExtendedMetadata);
serviceProviderBuilder.setSharedObject(SAMLAuthenticationProvider.class, samlAuthenticationProvider);
serviceProviderBuilder.setSharedObject(SAMLContextProvider.class, samlContextProvider);
serviceProviderBuilder.setSharedObject(KeyManager.class, keyManager);
serviceProviderBuilder.setSharedObject(MetadataManager.class, metadataManager);
serviceProviderBuilder.setSharedObject(MetadataGenerator.class, metadataGenerator);
serviceProviderBuilder.setSharedObject(SAMLProcessor.class, samlProcessor);
serviceProviderBuilder.setSharedObject(WebSSOProfile.class, webSSOProfile);
serviceProviderBuilder.setSharedObject(WebSSOProfileECPImpl.class, ecpProfile);
serviceProviderBuilder.setSharedObject(WebSSOProfileHoKImpl.class, hokWebSSOProfile);
serviceProviderBuilder.setSharedObject(SingleLogoutProfile.class, sloProfile);
serviceProviderBuilder.setSharedObject(WebSSOProfileConsumer.class, webSSOProfileConsumer);
serviceProviderBuilder.setSharedObject(WebSSOProfileConsumerHoKImpl.class, hokWebSSOProfileConsumer);
serviceProviderBuilder.setSharedObject(SAMLLogger.class, samlLogger);
}
开发者ID:ulisesbocchio,项目名称:spring-boot-security-saml,代码行数:27,代码来源:SAMLServiceProviderSecurityConfiguration.java
示例10: init
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Test
public void init() throws Exception {
KeyManagerConfigurer configurer = new KeyManagerConfigurer();
configurer.init(builder);
verify(builder).getSharedObject(eq(KeyManager.class));
verify(builder).getSharedObject(eq(SAMLSSOProperties.class));
}
示例11: configure
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Test
public void configure() throws Exception {
KeyManagerConfigurer configurer = new KeyManagerConfigurer();
configurer.init(builder);
configurer.configure(builder);
verify(builder).setSharedObject(eq(KeyManager.class), any(KeyManager.class));
}
示例12: configure_forBean
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Test
public void configure_forBean() throws Exception {
KeyManager keyManager = mock(KeyManager.class);
when(builder.getSharedObject(KeyManager.class)).thenReturn(keyManager);
KeyManagerConfigurer configurer = new KeyManagerConfigurer();
configurer.init(builder);
configurer.configure(builder);
verify(builder, never()).setSharedObject(any(), any());
verifyZeroInteractions(keyManager, keyManagerProperties);
}
示例13: configure_forConstructor
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Test
public void configure_forConstructor() throws Exception {
KeyManager keyManager = mock(KeyManager.class);
KeyManagerConfigurer configurer = new KeyManagerConfigurer(keyManager);
configurer.init(builder);
configurer.configure(builder);
verify(builder).setSharedObject(eq(KeyManager.class), eq(keyManager));
verifyZeroInteractions(keyManager, keyManagerProperties);
}
示例14: testProperties
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Test
public void testProperties() throws Exception {
KeyManagerConfigurer configurer = new KeyManagerConfigurer();
configurer.init(builder);
configurer.configure(builder);
ArgumentCaptor<KeyManager> providerCaptor = ArgumentCaptor.forClass(KeyManager.class);
verify(builder).setSharedObject(eq(KeyManager.class), providerCaptor.capture());
assertThat(providerCaptor.getValue()).isNotNull();
KeyManager keyManager = providerCaptor.getValue();
assertThat(keyManager).isExactlyInstanceOf(EmptyKeyManager.class);
}
示例15: keyManager
import org.springframework.security.saml.key.KeyManager; //导入依赖的package包/类
@Bean
public KeyManager keyManager() {
DefaultResourceLoader loader = new DefaultResourceLoader();
Resource storeFile = loader
.getResource("classpath:/saml/samlKeystore.jks");
String storePass = "nalle123";
Map<String, String> passwords = new HashMap<String, String>();
passwords.put("apollo", "nalle123");
String defaultKey = "apollo";
return new JKSKeyManager(storeFile, storePass, passwords, defaultKey);
}