当前位置: 首页>>代码示例>>Java>>正文


Java DefaultConnectionFactory.getConnection方法代码示例

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


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

示例1: modifyLdapEntry

import org.ldaptive.DefaultConnectionFactory; //导入方法依赖的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: bootstrap

import org.ldaptive.DefaultConnectionFactory; //导入方法依赖的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

示例3: bootstrap

import org.ldaptive.DefaultConnectionFactory; //导入方法依赖的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


注:本文中的org.ldaptive.DefaultConnectionFactory.getConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。