本文整理汇总了Java中com.unboundid.util.ssl.KeyStoreKeyManager类的典型用法代码示例。如果您正苦于以下问题:Java KeyStoreKeyManager类的具体用法?Java KeyStoreKeyManager怎么用?Java KeyStoreKeyManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyStoreKeyManager类属于com.unboundid.util.ssl包,在下文中一共展示了KeyStoreKeyManager类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: InMemoryTestLdapDirectoryServer
import com.unboundid.util.ssl.KeyStoreKeyManager; //导入依赖的package包/类
/**
* Instantiates a new Ldap directory server.
* Parameters need to be streams so they can be read from JARs.
*/
public InMemoryTestLdapDirectoryServer(final InputStream properties,
final InputStream ldifFile,
final InputStream schemaFile) {
try {
final Properties p = new Properties();
p.load(properties);
final InMemoryDirectoryServerConfig config =
new InMemoryDirectoryServerConfig(p.getProperty("ldap.rootDn"));
config.addAdditionalBindCredentials(p.getProperty("ldap.managerDn"), p.getProperty("ldap.managerPassword"));
final File keystoreFile = File.createTempFile("key", "store");
try (OutputStream outputStream = new FileOutputStream(keystoreFile)) {
IOUtils.copy(new ClassPathResource("/ldapServerTrustStore").getInputStream(), outputStream);
}
final String serverKeyStorePath = keystoreFile.getCanonicalPath();
final SSLUtil serverSSLUtil = new SSLUtil(
new KeyStoreKeyManager(serverKeyStorePath, "changeit".toCharArray()), new TrustStoreTrustManager(serverKeyStorePath));
final SSLUtil clientSSLUtil = new SSLUtil(new TrustStoreTrustManager(serverKeyStorePath));
config.setListenerConfigs(
InMemoryListenerConfig.createLDAPConfig("LDAP", // Listener name
null, // Listen address. (null = listen on all interfaces)
1389, // Listen port (0 = automatically choose an available port)
serverSSLUtil.createSSLSocketFactory()), // StartTLS factory
InMemoryListenerConfig.createLDAPSConfig("LDAPS", // Listener name
null, // Listen address. (null = listen on all interfaces)
1636, // Listen port (0 = automatically choose an available port)
serverSSLUtil.createSSLServerSocketFactory(), // Server factory
clientSSLUtil.createSSLSocketFactory())); // Client factory
config.setEnforceSingleStructuralObjectClass(false);
config.setEnforceAttributeSyntaxCompliance(true);
final File file = File.createTempFile("ldap", "schema");
try (OutputStream outputStream = new FileOutputStream(file)) {
IOUtils.copy(schemaFile, outputStream);
}
final Schema s = Schema.mergeSchemas(Schema.getSchema(file));
config.setSchema(s);
this.directoryServer = new InMemoryDirectoryServer(config);
LOGGER.debug("Populating directory...");
final File ldif = File.createTempFile("ldiff", "file");
try (OutputStream outputStream = new FileOutputStream(ldif)) {
IOUtils.copy(ldifFile, outputStream);
}
this.directoryServer.importFromLDIF(true, ldif.getCanonicalPath());
this.directoryServer.restartServer();
final LDAPConnection c = getConnection();
LOGGER.debug("Connected to {}:{}", c.getConnectedAddress(), c.getConnectedPort());
populateDefaultEntries(c);
c.close();
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:70,代码来源:InMemoryTestLdapDirectoryServer.java
示例2: InMemoryTestLdapDirectoryServer
import com.unboundid.util.ssl.KeyStoreKeyManager; //导入依赖的package包/类
/**
* Instantiates a new Ldap directory server.
* Parameters need to be streams so they can be read from JARs.
*/
public InMemoryTestLdapDirectoryServer(final InputStream properties,
final InputStream ldifFile,
final InputStream schemaFile) {
try {
final Properties p = new Properties();
p.load(properties);
final InMemoryDirectoryServerConfig config =
new InMemoryDirectoryServerConfig(p.getProperty("ldap.rootDn"));
config.addAdditionalBindCredentials(p.getProperty("ldap.managerDn"), p.getProperty("ldap.managerPassword"));
final File keystoreFile = File.createTempFile("key", "store");
try (final OutputStream outputStream = new FileOutputStream(keystoreFile)) {
IOUtils.copy(new ClassPathResource("/ldapServerTrustStore").getInputStream(), outputStream);
}
final String serverKeyStorePath = keystoreFile.getCanonicalPath();
final SSLUtil serverSSLUtil = new SSLUtil(
new KeyStoreKeyManager(serverKeyStorePath, "changeit".toCharArray()), new TrustStoreTrustManager(serverKeyStorePath));
final SSLUtil clientSSLUtil = new SSLUtil(new TrustStoreTrustManager(serverKeyStorePath));
config.setListenerConfigs(
InMemoryListenerConfig.createLDAPConfig("LDAP", // Listener name
null, // Listen address. (null = listen on all interfaces)
1389, // Listen port (0 = automatically choose an available port)
serverSSLUtil.createSSLSocketFactory()), // StartTLS factory
InMemoryListenerConfig.createLDAPSConfig("LDAPS", // Listener name
null, // Listen address. (null = listen on all interfaces)
1636, // Listen port (0 = automatically choose an available port)
serverSSLUtil.createSSLServerSocketFactory(), // Server factory
clientSSLUtil.createSSLSocketFactory())); // Client factory
config.setEnforceSingleStructuralObjectClass(false);
config.setEnforceAttributeSyntaxCompliance(true);
final File file = File.createTempFile("ldap", "schema");
try (final OutputStream outputStream = new FileOutputStream(file)) {
IOUtils.copy(schemaFile, outputStream);
}
final Schema s = Schema.mergeSchemas(Schema.getSchema(file));
config.setSchema(s);
this.directoryServer = new InMemoryDirectoryServer(config);
LOGGER.debug("Populating directory...");
final File ldif = File.createTempFile("ldiff", "file");
try (final OutputStream outputStream = new FileOutputStream(ldif)) {
IOUtils.copy(ldifFile, outputStream);
}
this.directoryServer.importFromLDIF(true, ldif.getCanonicalPath());
this.directoryServer.restartServer();
final LDAPConnection c = getConnection();
LOGGER.debug("Connected to {}:{}", c.getConnectedAddress(), c.getConnectedPort());
populateDefaultEntries(c);
c.close();
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:70,代码来源:InMemoryTestLdapDirectoryServer.java
示例3: LdapServer
import com.unboundid.util.ssl.KeyStoreKeyManager; //导入依赖的package包/类
/**
* Instantiates a new Ldap directory server.
* Parameters need to be streams so they can be read from JARs.
*/
public LdapServer(final InputStream properties,
final InputStream ldifFile,
final InputStream schemaFile) {
try {
final Properties p = new Properties();
p.load(properties);
final InMemoryDirectoryServerConfig config =
new InMemoryDirectoryServerConfig(p.getProperty("ldap.rootDn"));
config.addAdditionalBindCredentials(p.getProperty("ldap.managerDn"), p.getProperty("ldap.managerPassword"));
final File keystoreFile = File.createTempFile("key", "store");
try (final OutputStream outputStream = new FileOutputStream(keystoreFile)) {
IOUtils.copy(new ClassPathResource("/ldapServerTrustStore").getInputStream(), outputStream);
}
final String serverKeyStorePath = keystoreFile.getCanonicalPath();
final SSLUtil serverSSLUtil = new SSLUtil(
new KeyStoreKeyManager(serverKeyStorePath, "changeit".toCharArray()), new TrustStoreTrustManager(serverKeyStorePath));
final SSLUtil clientSSLUtil = new SSLUtil(new TrustStoreTrustManager(serverKeyStorePath));
config.setListenerConfigs(
InMemoryListenerConfig.createLDAPConfig("LDAP", // Listener name
null, // Listen address. (null = listen on all interfaces)
1389, // Listen port (0 = automatically choose an available port)
serverSSLUtil.createSSLSocketFactory()), // StartTLS factory
InMemoryListenerConfig.createLDAPSConfig("LDAPS", // Listener name
null, // Listen address. (null = listen on all interfaces)
1636, // Listen port (0 = automatically choose an available port)
serverSSLUtil.createSSLServerSocketFactory(), // Server factory
clientSSLUtil.createSSLSocketFactory())); // Client factory
config.setEnforceSingleStructuralObjectClass(false);
config.setEnforceAttributeSyntaxCompliance(true);
config.setMaxConnections(-1);
final File file = File.createTempFile("ldap", "schema");
try (final OutputStream outputStream = new FileOutputStream(file)) {
IOUtils.copy(schemaFile, outputStream);
}
final Schema s = Schema.mergeSchemas(Schema.getSchema(file));
config.setSchema(s);
this.directoryServer = new InMemoryDirectoryServer(config);
LOGGER.debug("Populating directory...");
final File ldif = File.createTempFile("ldiff", "file");
try (final OutputStream outputStream = new FileOutputStream(ldif)) {
IOUtils.copy(ldifFile, outputStream);
}
this.directoryServer.importFromLDIF(true, ldif.getCanonicalPath());
this.directoryServer.restartServer();
final LDAPConnection c = getConnection();
LOGGER.debug("Connected to {}:{}", c.getConnectedAddress(), c.getConnectedPort());
LOGGER.debug("Bind DN: {}", p.getProperty("ldap.managerDn"));
LOGGER.debug("Bind credential: {}", p.getProperty("ldap.managerPassword"));
populateDefaultEntries(c);
c.close();
} catch (final Exception e) {
throw new RuntimeException(e);
}
}