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

Java LdapUtils类代码示例

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

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



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

示例1: submit

import org.jasig.cas.util.LdapUtils; //导入依赖的package包/类
@Override
public boolean submit(final RequestContext requestContext, final Credential credential) {

    String currentDn = null;
    try (Connection searchConnection = LdapUtils.createConnection(this.connectionFactory)) {
        final Response<SearchResult> response = searchForId(searchConnection, credential.getId());
        if (LdapUtils.containsResultEntry(response)) {
            currentDn = response.getResult().getEntry().getDn();
        }
    } catch (final Exception e) {
        logger.error(e.getMessage(), e);
    }

    if (StringUtils.isNotBlank(currentDn)) {
        logger.debug("Updating {}", currentDn);
        return LdapUtils.executeModifyOperation(currentDn, this.connectionFactory,
                Collections.singletonMap(this.aupAttributeName, 
                        Collections.singleton(Boolean.TRUE.toString())));
    }
    return false;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:LdapAcceptableUsagePolicyRepository.java


示例2: save

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

        try {
            final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.baseDn, rs);
            LdapUtils.executeAddOperation(this.connectionFactory, entry);
        } catch (final LdapException e) {
            logger.error(e.getMessage(), e);
        }
        return rs;
    }
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:LdapServiceRegistryDao.java


示例3: update

import org.jasig.cas.util.LdapUtils; //导入依赖的package包/类
/**
 * Update the ldap entry with the given registered service.
 *
 * @param rs the rs
 * @return the registered service
 */
private RegisteredService update(final RegisteredService rs) {
    String currentDn = null;

    if (ldapServiceMapper == null) {
        return null;
    }

    try {
        final Response<SearchResult> response = searchForServiceById(rs.getId());
        if (LdapUtils.containsResultEntry(response)) {
            currentDn = response.getResult().getEntry().getDn();
        }
    } catch (final Exception e) {
        logger.error(e.getMessage(), e);
    }

    if (StringUtils.isNotBlank(currentDn)) {
        logger.debug("Updating registered service at {}", currentDn);
        final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.baseDn, rs);
        LdapUtils.executeModifyOperation(currentDn, this.connectionFactory, entry);
    }

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


示例4: load

import org.jasig.cas.util.LdapUtils; //导入依赖的package包/类
@Override
public List<RegisteredService> load() {
    final List<RegisteredService> list = new LinkedList<>();
    if (ldapServiceMapper == null) {
        return list;
    }

    try {
        final Response<SearchResult> response = LdapUtils.executeSearchOperation(this.connectionFactory,
                this.baseDn, new SearchFilter(this.loadFilter));
        if (LdapUtils.containsResultEntry(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);
    }
    return list;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:LdapServiceRegistryDao.java


示例5: mapFromRegisteredService

import org.jasig.cas.util.LdapUtils; //导入依赖的package包/类
@Override
public LdapEntry mapFromRegisteredService(final String dn, final RegisteredService svc) {
    try {
        if (svc.getId() == RegisteredService.INITIAL_IDENTIFIER_VALUE) {
            ((AbstractRegisteredService) svc).setId(System.nanoTime());
        }
        final String newDn = getDnForRegisteredService(dn, svc);
        LOGGER.debug("Creating entry {}", newDn);

        final Collection<LdapAttribute> attrs = new ArrayList<>();
        attrs.add(new LdapAttribute(this.idAttribute, String.valueOf(svc.getId())));

        final StringWriter writer = new StringWriter();
        this.jsonSerializer.toJson(writer, svc);
        attrs.add(new LdapAttribute(this.serviceDefinitionAttribute, writer.toString()));
        attrs.add(new LdapAttribute(LdapUtils.OBJECTCLASS_ATTRIBUTE, "top", this.objectClass));

        return new LdapEntry(newDn, attrs);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:DefaultLdapRegisteredServiceMapper.java


示例6: 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


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: 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


示例13: 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


示例14: delete

import org.jasig.cas.util.LdapUtils; //导入依赖的package包/类
@Override
public boolean delete(final RegisteredService registeredService) {
    try {
        final Response<SearchResult> response = searchForServiceById(registeredService.getId());
        if (LdapUtils.containsResultEntry(response)) {
            final LdapEntry entry = response.getResult().getEntry();
            return LdapUtils.executeDeleteOperation(this.connectionFactory, entry);
        }
    } catch (final LdapException e) {
        logger.error(e.getMessage(), e);
    }
    return false;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:LdapServiceRegistryDao.java


示例15: findServiceById

import org.jasig.cas.util.LdapUtils; //导入依赖的package包/类
@Override
public RegisteredService findServiceById(final long id) {
    try {
        if (this.ldapServiceMapper != null) {
            final Response<SearchResult> response = searchForServiceById(id);
            if (LdapUtils.containsResultEntry(response)) {
                return this.ldapServiceMapper.mapToRegisteredService(response.getResult().getEntry());
            }
        }
    } catch (final LdapException e) {
        logger.error(e.getMessage(), e);
    }
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:15,代码来源:LdapServiceRegistryDao.java


示例16: mapToRegisteredService

import org.jasig.cas.util.LdapUtils; //导入依赖的package包/类
@Override
public RegisteredService mapToRegisteredService(final LdapEntry entry) {
    try {
        final String value = LdapUtils.getString(entry, this.serviceDefinitionAttribute);
        if (StringUtils.hasText(value)) {
            final RegisteredService service = this.jsonSerializer.fromJson(value);
            return service;
        }

        return null;
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:15,代码来源:DefaultLdapRegisteredServiceMapper.java


示例17: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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