本文整理汇总了Java中com.unboundid.ldap.sdk.LDAPConnection.getConnectedPort方法的典型用法代码示例。如果您正苦于以下问题:Java LDAPConnection.getConnectedPort方法的具体用法?Java LDAPConnection.getConnectedPort怎么用?Java LDAPConnection.getConnectedPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.unboundid.ldap.sdk.LDAPConnection
的用法示例。
在下文中一共展示了LDAPConnection.getConnectedPort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modifyLdapEntry
import com.unboundid.ldap.sdk.LDAPConnection; //导入方法依赖的package包/类
/**
* Modify ldap entry.
*
* @param serverCon the server con
* @param dn the dn
* @param attr the attr
* @param add the add
*/
public static void modifyLdapEntry(final LDAPConnection serverCon, final String dn, final LdapAttribute attr,
final AttributeModificationType add) {
try {
final String address = "ldap://" + serverCon.getConnectedAddress() + ':' + serverCon.getConnectedPort();
try (Connection conn = DefaultConnectionFactory.getConnection(address)) {
try {
conn.open();
final ModifyOperation modify = new ModifyOperation(conn);
modify.execute(new ModifyRequest(dn, new AttributeModification(add, attr)));
} catch (final Exception e) {
LOGGER.debug(e.getMessage(), e);
}
}
} finally {
serverCon.close();
}
}
示例2: bootstrap
import com.unboundid.ldap.sdk.LDAPConnection; //导入方法依赖的package包/类
public static void bootstrap() throws Exception {
initDirectoryServer();
getDirectory().populateEntries(new ClassPathResource("ldif/users-x509.ldif").getInputStream());
/**
* Dynamically set the attribute value to the crl content.
* Encode it as base64 first. Doing this in the code rather
* than in the ldif file to ensure the attribute can be populated
* without dependencies on the classpath and or filesystem.
*/
final Collection<LdapEntry> col = getDirectory().getLdapEntries();
for (final LdapEntry ldapEntry : col) {
if (ldapEntry.getDn().equals(DN)) {
final LdapAttribute attr = new LdapAttribute(true);
byte[] value = new byte[1024];
IOUtils.read(new ClassPathResource("userCA-valid.crl").getInputStream(), value);
value = CompressionUtils.encodeBase64ToByteArray(value);
attr.setName("certificateRevocationList");
attr.addBinaryValue(value);
final LDAPConnection serverCon = getDirectory().getConnection();
final String address = "ldap://" + serverCon.getConnectedAddress() + ':' + serverCon.getConnectedPort();
final Connection conn = DefaultConnectionFactory.getConnection(address);
conn.open();
final ModifyOperation modify = new ModifyOperation(conn);
modify.execute(new ModifyRequest(ldapEntry.getDn(),
new AttributeModification(AttributeModificationType.ADD, attr)));
conn.close();
serverCon.close();
return;
}
}
}
示例3: bootstrap
import com.unboundid.ldap.sdk.LDAPConnection; //导入方法依赖的package包/类
public static void bootstrap() throws Exception {
initDirectoryServer();
getDirectory().populateEntries(new ClassPathResource("ldif/users-x509.ldif").getInputStream());
/**
* Dynamically set the attribute value to the crl content.
* Encode it as base64 first. Doing this in the code rather
* than in the ldif file to ensure the attribute can be populated
* without dependencies on the classpath and or filesystem.
*/
final Collection<LdapEntry> col = getDirectory().getLdapEntries();
for (final LdapEntry ldapEntry : col) {
if (ldapEntry.getDn().equals(DN)) {
final LdapAttribute attr = new LdapAttribute(true);
byte[] value = new byte[1024];
IOUtils.read(new ClassPathResource("userCA-valid.crl").getInputStream(), value);
value = CompressionUtils.encodeBase64ToByteArray(value);
attr.setName("certificateRevocationList");
attr.addBinaryValue(value);
final LDAPConnection serverCon = getDirectory().getConnection();
final String address = "ldap://" + serverCon.getConnectedAddress() + ":" + serverCon.getConnectedPort();
final Connection conn = DefaultConnectionFactory.getConnection(address);
conn.open();
final ModifyOperation modify = new ModifyOperation(conn);
modify.execute(new ModifyRequest(ldapEntry.getDn(),
new AttributeModification(AttributeModificationType.ADD, attr)));
conn.close();
serverCon.close();
return;
}
}
}