本文整理汇总了Java中org.ldaptive.LdapAttribute.addBinaryValue方法的典型用法代码示例。如果您正苦于以下问题:Java LdapAttribute.addBinaryValue方法的具体用法?Java LdapAttribute.addBinaryValue怎么用?Java LdapAttribute.addBinaryValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ldaptive.LdapAttribute
的用法示例。
在下文中一共展示了LdapAttribute.addBinaryValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateCertificateRevocationListAttribute
import org.ldaptive.LdapAttribute; //导入方法依赖的package包/类
/**
* Populate certificate revocation list attribute.
* 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.
* @throws Exception the exception
*/
private static void populateCertificateRevocationListAttribute() throws Exception {
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 = EncodingUtils.encodeBase64ToByteArray(value);
attr.setName("certificateRevocationList");
attr.addBinaryValue(value);
LdapTestUtils.modifyLdapEntry(getDirectory().getConnection(), ldapEntry, attr);
}
}
}
示例2: bootstrap
import org.ldaptive.LdapAttribute; //导入方法依赖的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 org.ldaptive.LdapAttribute; //导入方法依赖的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;
}
}
}