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


Java LdapUtils类代码示例

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


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


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