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


Java LdapUtils.closeConnection方法代码示例

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


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

示例1: observe

import org.jasig.cas.util.LdapUtils; //导入方法依赖的package包/类
/**
 * Gets a connection from the underlying connection factory and attempts to validate it.
 *
 * @return  Status with code {@link StatusCode#OK} on success otherwise {@link StatusCode#ERROR}.
 */
@Override
public Status observe() {
    Connection conn = null;
    try {
        conn = this.connectionFactory.getConnection();
        if (!conn.isOpen()) {
            conn.open();
        }
        return this.validator.validate(conn) ? OK : ERROR;
    } catch (final LdapException e) {
        logger.warn("Validation failed with error.", e);
    } finally {
        LdapUtils.closeConnection(conn);
    }
    return ERROR;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:ConnectionFactoryMonitor.java

示例2: save

import org.jasig.cas.util.LdapUtils; //导入方法依赖的package包/类
@Override
public RegisteredService save(final RegisteredService rs) {
    if (rs.getId() != RegisteredService.INITIAL_IDENTIFIER_VALUE) {
        return update(rs);
    }

    Connection connection = null;
    try {
        connection = getConnection();
        final AddOperation operation = new AddOperation(connection);

        final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.searchRequest.getBaseDn(), rs);
        operation.execute(new AddRequest(entry.getDn(), entry.getAttributes()));
    } catch (final LdapException e) {
        logger.error(e.getMessage(), e);
    } finally {
        LdapUtils.closeConnection(connection);
    }
    return rs;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:LdapServiceRegistryDao.java

示例3: load

import org.jasig.cas.util.LdapUtils; //导入方法依赖的package包/类
@Override
public List<RegisteredService> load() {
    Connection connection = null;
    final List<RegisteredService> list = new LinkedList<>();
    try {
        connection = getConnection();
        final Response<SearchResult> response =
                executeSearchOperation(connection, new SearchFilter(this.loadFilter));
        if (hasResults(response)) {
            for (final LdapEntry entry : response.getResult().getEntries()) {
                final RegisteredService svc = this.ldapServiceMapper.mapToRegisteredService(entry);
                list.add(svc);
            }
        }
    } catch (final LdapException e) {
        logger.error(e.getMessage(), e);
    } finally {
        LdapUtils.closeConnection(connection);
    }
    return list;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:LdapServiceRegistryDao.java

示例4: findServiceById

import org.jasig.cas.util.LdapUtils; //导入方法依赖的package包/类
@Override
public RegisteredService findServiceById(final long id) {
    Connection connection = null;
    try {
        connection = getConnection();

        final Response<SearchResult> response = searchForServiceById(connection, id);
        if (hasResults(response)) {
            return this.ldapServiceMapper.mapToRegisteredService(response.getResult().getEntry());
        }
    } catch (final LdapException e) {
        logger.error(e.getMessage(), e);
    } finally {
        LdapUtils.closeConnection(connection);
    }

    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:LdapServiceRegistryDao.java

示例5: save

import org.jasig.cas.util.LdapUtils; //导入方法依赖的package包/类
@Override
public RegisteredService save(final RegisteredService rs) {
    if (rs.getId() != RegisteredService.INITIAL_IDENTIFIER_VALUE) {
        return update(rs);
    }

    Connection connection = null;
    try {
        connection = this.connectionFactory.getConnection();
        final AddOperation operation = new AddOperation(connection);

        final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.searchRequest.getBaseDn(), rs);
        operation.execute(new AddRequest(entry.getDn(), entry.getAttributes()));
    } catch (final LdapException e) {
        logger.error(e.getMessage(), e);
    } finally {
        LdapUtils.closeConnection(connection);
    }
    return rs;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:21,代码来源:LdapServiceRegistryDao.java

示例6: load

import org.jasig.cas.util.LdapUtils; //导入方法依赖的package包/类
@Override
public List<RegisteredService> load() {
    Connection connection = null;
    final List<RegisteredService> list = new LinkedList<RegisteredService>();
    try {
        connection = this.connectionFactory.getConnection();
        final Response<SearchResult> response =
                executeSearchOperation(connection, new SearchFilter(this.loadFilter));
        if (hasResults(response)) {
            for (final LdapEntry entry : response.getResult().getEntries()) {
                final RegisteredService svc = this.ldapServiceMapper.mapToRegisteredService(entry);
                list.add(svc);
            }
        }
    } catch (final LdapException e) {
        logger.error(e.getMessage(), e);
    } finally {
        LdapUtils.closeConnection(connection);
    }
    return list;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:22,代码来源:LdapServiceRegistryDao.java

示例7: findServiceById

import org.jasig.cas.util.LdapUtils; //导入方法依赖的package包/类
@Override
public RegisteredService findServiceById(final long id) {
    Connection connection = null;
    try {
        connection = this.connectionFactory.getConnection();

        final Response<SearchResult> response = searchForServiceById(connection, id);
        if (hasResults(response)) {
            return this.ldapServiceMapper.mapToRegisteredService(response.getResult().getEntry());
        }
    } catch (final LdapException e) {
        logger.error(e.getMessage(), e);
    } finally {
        LdapUtils.closeConnection(connection);
    }

    return null;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:19,代码来源:LdapServiceRegistryDao.java

示例8: setUp

import org.jasig.cas.util.LdapUtils; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    // Environment check
    this.enableLdapTests = System.getProperty("enableLdapTests") != null;
    Assume.assumeTrue("enableLdapTests system property not set", this.enableLdapTests);

    this.context = new ClassPathXmlApplicationContext(this.contextPaths);
    this.baseDn = this.context.getBean("baseDn", String.class);
    this.usersLdif = this.context.getBean("usersLdif", Resource.class);
    this.usernameAttribute = this.context.getBean("usernameAttribute", String.class);
    this.provisioningConnectionFactory = this.context.getBean(
            "provisioningConnectionFactory", ConnectionFactory.class);
    this.testEntries = LdapTestUtils.readLdif(this.usersLdif, this.baseDn);
    final Connection connection = getConnection();
    try {
        connection.open();
        LdapTestUtils.createLdapEntries(connection, this.directoryType, this.testEntries);
    } finally {
        LdapUtils.closeConnection(connection);
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:22,代码来源:AbstractLdapTests.java

示例9: checkPool

import org.jasig.cas.util.LdapUtils; //导入方法依赖的package包/类
@Override
protected StatusCode checkPool() throws Exception {
    final Connection conn = this.connectionFactory.getConnection();
    try {
        return this.validator.validate(conn) ? StatusCode.OK : StatusCode.ERROR;
    } finally {
        LdapUtils.closeConnection(conn);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:PooledConnectionFactoryMonitor.java

示例10: update

import org.jasig.cas.util.LdapUtils; //导入方法依赖的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

示例11: tearDown

import org.jasig.cas.util.LdapUtils; //导入方法依赖的package包/类
@After
public void tearDown() throws Exception {
    if (!this.enableLdapTests) {
        return;
    }
    final Connection connection = getConnection();
    try {
        connection.open();
        LdapTestUtils.removeLdapEntries(connection, this.testEntries);
    } finally {
        LdapUtils.closeConnection(connection);
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:14,代码来源:AbstractLdapTests.java


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