• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ModifyOperation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.ldaptive.ModifyOperation的典型用法代码示例。如果您正苦于以下问题:Java ModifyOperation类的具体用法?Java ModifyOperation怎么用?Java ModifyOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ModifyOperation类属于org.ldaptive包,在下文中一共展示了ModifyOperation类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: modifyLdapEntry

import org.ldaptive.ModifyOperation; //导入依赖的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.ModifyOperation; //导入依赖的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.ModifyOperation; //导入依赖的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.ModifyOperation; //导入依赖的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.ModifyOperation; //导入依赖的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.ModifyOperation; //导入依赖的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.ModifyOperation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MultipartRequestWrapper类代码示例发布时间:2022-05-23
下一篇:
Java Person类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap