本文整理汇总了Java中com.unboundid.util.ssl.TrustStoreTrustManager类的典型用法代码示例。如果您正苦于以下问题:Java TrustStoreTrustManager类的具体用法?Java TrustStoreTrustManager怎么用?Java TrustStoreTrustManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TrustStoreTrustManager类属于com.unboundid.util.ssl包,在下文中一共展示了TrustStoreTrustManager类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLDAPConnection
import com.unboundid.util.ssl.TrustStoreTrustManager; //导入依赖的package包/类
public LDAPConnection getLDAPConnection(String userDN, String password)
throws LDAPException, GeneralSecurityException {
TrustStoreTrustManager trust = new TrustStoreTrustManager(trustStorePath, trustStorePassword.toCharArray(), trustStoreType, false);
LDAPConnectionOptions options = new LDAPConnectionOptions();
options.setSSLSocketVerifier(new HostNameSSLSocketVerifier(false));
SSLUtil sslUtil = new SSLUtil(trust);
SocketFactory factory = new EndpointIdentificationSocketFactory(sslUtil.createSSLSocketFactory("TLSv1.2"));
LDAPConnection ldapConnection = new LDAPConnection(factory, options);
// Connect, retrieve the DN of the user (if any)
ldapConnection.connect(server, port);
ldapConnection.bind(userDN, password);
return ldapConnection;
}
示例2: InMemoryTestLdapDirectoryServer
import com.unboundid.util.ssl.TrustStoreTrustManager; //导入依赖的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
示例3: InMemoryTestLdapDirectoryServer
import com.unboundid.util.ssl.TrustStoreTrustManager; //导入依赖的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
示例4: LdapServer
import com.unboundid.util.ssl.TrustStoreTrustManager; //导入依赖的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);
}
}