本文整理汇总了Java中org.ldaptive.AttributeModification类的典型用法代码示例。如果您正苦于以下问题:Java AttributeModification类的具体用法?Java AttributeModification怎么用?Java AttributeModification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeModification类属于org.ldaptive包,在下文中一共展示了AttributeModification类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: modifyLdapEntry
import org.ldaptive.AttributeModification; //导入依赖的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();
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:26,代码来源:LdapTestUtils.java
示例2: executeModifyOperation
import org.ldaptive.AttributeModification; //导入依赖的package包/类
/**
* Execute modify operation boolean.
*
* @param currentDn the current dn
* @param connectionFactory the connection factory
* @param attributes the attributes
* @return the boolean
*/
public static boolean executeModifyOperation(final String currentDn,
final ConnectionFactory connectionFactory,
final Map<String, Set<String>> attributes) {
try (Connection modifyConnection = createConnection(connectionFactory)) {
final ModifyOperation operation = new ModifyOperation(modifyConnection);
final List<AttributeModification> mods = new ArrayList<>();
for (final Map.Entry<String, Set<String>> entry : attributes.entrySet()) {
mods.add(new AttributeModification(AttributeModificationType.REPLACE,
new LdapAttribute(entry.getKey(), entry.getValue().toArray(new String[]{}))));
}
final ModifyRequest request = new ModifyRequest(currentDn,
mods.toArray(new AttributeModification[]{}));
request.setReferralHandler(new ModifyReferralHandler());
operation.execute(request);
return true;
} catch (final LdapException e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:29,代码来源:LdapUtils.java
示例3: executeModifyOperation
import org.ldaptive.AttributeModification; //导入依赖的package包/类
/**
* Execute modify operation boolean.
*
* @param currentDn the current dn
* @param connectionFactory the connection factory
* @param attributes the attributes
* @return true/false
*/
public static boolean executeModifyOperation(final String currentDn, final ConnectionFactory connectionFactory,
final Map<String, Set<String>> attributes) {
try (Connection modifyConnection = createConnection(connectionFactory)) {
final ModifyOperation operation = new ModifyOperation(modifyConnection);
final List<AttributeModification> mods = attributes.entrySet()
.stream().map(entry -> new AttributeModification(AttributeModificationType.REPLACE,
new LdapAttribute(entry.getKey(), entry.getValue().toArray(new String[]{})))).collect(Collectors.toList());
final ModifyRequest request = new ModifyRequest(currentDn,
mods.toArray(new AttributeModification[]{}));
request.setReferralHandler(new ModifyReferralHandler());
operation.execute(request);
return true;
} catch (final LdapException e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:26,代码来源:LdapUtils.java
示例4: bootstrap
import org.ldaptive.AttributeModification; //导入依赖的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;
}
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:35,代码来源:AbstractX509LdapTests.java
示例5: bootstrap
import org.ldaptive.AttributeModification; //导入依赖的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;
}
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:35,代码来源:AbstractX509LdapTests.java
示例6: update
import org.ldaptive.AttributeModification; //导入依赖的package包/类
private RegisteredService update(final RegisteredService rs) {
Connection searchConnection = null;
try {
searchConnection = this.connectionFactory.getConnection();
final Response<SearchResult> response = searchForServiceById(searchConnection, rs.getId());
if (hasResults(response)) {
final String currentDn = response.getResult().getEntry().getDn();
Connection modifyConnection = null;
try {
modifyConnection = this.connectionFactory.getConnection();
final ModifyOperation operation = new ModifyOperation(searchConnection);
final List<AttributeModification> mods = new ArrayList<AttributeModification>();
final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.searchRequest.getBaseDn(), rs);
for (final LdapAttribute attr : entry.getAttributes()) {
mods.add(new AttributeModification(AttributeModificationType.REPLACE, attr));
}
final ModifyRequest request = new ModifyRequest(currentDn, mods.toArray(new AttributeModification[] {}));
operation.execute(request);
} finally {
LdapUtils.closeConnection(modifyConnection);
}
}
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
} finally {
LdapUtils.closeConnection(searchConnection);
}
return rs;
}
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:33,代码来源:LdapServiceRegistryDao.java
注:本文中的org.ldaptive.AttributeModification类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论