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


Java LdapContext.getResponseControls方法代码示例

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


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

示例1: prepareNextPage

import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
private boolean prepareNextPage(LdapContext ldapContext) throws Exception {
    Control[] responseControls = ldapContext.getResponseControls();

    byte[] cookie = null;
    if (responseControls != null) {
        for (Control responseControl : responseControls) {
            if (responseControl instanceof PagedResultsResponseControl) {
                PagedResultsResponseControl prrc = (PagedResultsResponseControl) responseControl;
                cookie = prrc.getCookie();
            }
        }
    }

    if (cookie == null) {
        return false;
    } else {
        ldapContext.setRequestControls(new Control[]{new PagedResultsControl(pageSize, cookie, Control.CRITICAL)});
        return true;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:LdapProducer.java

示例2: getCookie

import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
private byte[] getCookie(final LdapContext ctx) throws NamingException, IOException {
    byte[] cookie = null;
    // Examine the paged results control response
    final Control[] controls = ctx.getResponseControls();
    if (controls != null) {
        for (int i = 0; i < controls.length; i++) {
            if (controls[i] instanceof PagedResultsResponseControl) {
                final PagedResultsResponseControl prrc = (PagedResultsResponseControl) controls[i];
                cookie = prrc.getCookie();
            }
        }
    }
    // Re-activate paged results
    ctx.setRequestControls(new Control[] { new PagedResultsControl(PAGE_SIZE, cookie, Control.CRITICAL) });
    return cookie;
}
 
开发者ID:huihoo,项目名称:olat,代码行数:17,代码来源:LDAPLoginManagerImpl.java

示例3: postProcess

import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
public void postProcess(DirContext ctx) throws NamingException {

		LdapContext ldapContext = (LdapContext) ctx;
		Control[] responseControls = ldapContext.getResponseControls();
		if (responseControls == null) {
			responseControls = new Control[0];
		}

		// Go through response controls and get info, regardless of class
        for (Control responseControl : responseControls) {
            // check for match, try fallback otherwise
            if (responseControl.getClass().isAssignableFrom(responseControlClass)) {
                handleResponse(responseControl);
                return;
            }
        }

		log.info("No matching response control found - looking for '" + responseControlClass);
	}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:20,代码来源:AbstractFallbackRequestAndResponseControlDirContextProcessor.java

示例4: postProcess

import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
public void postProcess(DirContext ctx) throws NamingException {

		LdapContext ldapContext = (LdapContext) ctx;
		Control[] responseControls = ldapContext.getResponseControls();
		if (responseControls == null) {
			responseControls = new Control[0];
		}

		// Go through response controls and get info, regardless of class
		for (int i = 0; i < responseControls.length; i++) {
			Control responseControl = responseControls[i];

			// check for match, try fallback otherwise
			if (responseControl.getClass().isAssignableFrom(responseControlClass)) {
				Object control = responseControl;
				byte[] result = (byte[]) invokeMethod("getCookie", responseControlClass, control);
				this.cookie = new PagedResultsCookie(result);
				Integer wrapper = (Integer) invokeMethod("getResultSize", responseControlClass, control);
				this.resultSize = wrapper.intValue();
				return;
			}
		}

		log.error("No matching response control found for paged results - looking for '{}", responseControlClass);
	}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:26,代码来源:PagedResultsRequestControl.java

示例5: hasNextPage

import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
public boolean hasNextPage(DirContext ctx, int pageSize)
{
    if (pageSize > 0)
    {
        try
        {
            LdapContext ldapContext = (LdapContext) ctx;
            Control[] controls = ldapContext.getResponseControls();

            // Retrieve the paged result cookie if there is one
            if (controls != null)
            {
                for (Control control : controls)
                {
                    if (control instanceof PagedResultsResponseControl)
                    {
                        byte[] cookie = ((PagedResultsResponseControl) control).getCookie();
                        if (cookie != null)
                        {
                            // Prepare for next page
                            ldapContext.setRequestControls(new Control[]
                            {
                                new PagedResultsControl(pageSize, cookie, Control.CRITICAL)
                            });
                            return true;
                        }
                    }
                }
            }
        }
        catch (NamingException nx)
        {
            throw new AuthenticationException("Unable to connect to LDAP Server; check LDAP configuration", nx);
        }
        catch (IOException e)
        {
            throw new AuthenticationException(
                    "Unable to encode LDAP v3 request controls; check LDAP configuration", e);
        }

    }
    return false;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:44,代码来源:LDAPInitialDirContextFactoryImpl.java

示例6: searchUsers

import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
@Override
public List<LdapUser> searchUsers(final String username, final LdapContext context) throws NamingException, IOException {

    final SearchControls searchControls = new SearchControls();

    searchControls.setSearchScope(_ldapConfiguration.getScope());
    searchControls.setReturningAttributes(_ldapConfiguration.getReturnAttributes());

    final String basedn = _ldapConfiguration.getBaseDn();
    if (StringUtils.isBlank(basedn)) {
        throw new IllegalArgumentException("ldap basedn is not configured");
    }
    byte[] cookie = null;
    final int pageSize = _ldapConfiguration.getLdapPageSize();
    context.setRequestControls(new Control[]{new PagedResultsControl(pageSize, Control.NONCRITICAL)});
    final List<LdapUser> users = new ArrayList<>();
    NamingEnumeration<SearchResult> results;
    do {
        results = context.search(basedn, generateSearchFilter(username), searchControls);
        while (results.hasMoreElements()) {
            final SearchResult result = results.nextElement();
            if (!isUserDisabled(result)) {
                users.add(createUser(result));
            }
        }
        final Control[] contextControls = context.getResponseControls();
        if (contextControls != null) {
            for (final Control control : contextControls) {
                if (control instanceof PagedResultsResponseControl) {
                    final PagedResultsResponseControl prrc = (PagedResultsResponseControl) control;
                    cookie = prrc.getCookie();
                }
            }
        } else {
            s_logger.info("No controls were sent from the ldap server");
        }
        context.setRequestControls(new Control[]{new PagedResultsControl(pageSize, cookie, Control.CRITICAL)});
    } while (cookie != null);

    return users;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:42,代码来源:OpenLdapUserManagerImpl.java

示例7: hasNextPage

import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
// copied from default Alfresco class
public boolean hasNextPage(final DirContext ctx, final int pageSize)
{
    if (pageSize > 0)
    {
        try
        {
            final LdapContext ldapContext = (LdapContext) ctx;
            final Control[] controls = ldapContext.getResponseControls();

            // Retrieve the paged result cookie if there is one
            if (controls != null)
            {
                for (final Control control : controls)
                {
                    if (control instanceof PagedResultsResponseControl)
                    {
                        final byte[] cookie = ((PagedResultsResponseControl) control).getCookie();
                        if (cookie != null)
                        {
                            // Prepare for next page
                            ldapContext
                                    .setRequestControls(new Control[] { new PagedResultsControl(pageSize, cookie, Control.CRITICAL) });
                            return true;
                        }
                    }
                }
            }
        }
        catch (final NamingException nx)
        {
            throw new AuthenticationException("Unable to connect to LDAP Server; check LDAP configuration", nx);
        }
        catch (final IOException e)
        {
            throw new AuthenticationException("Unable to encode LDAP v3 request controls; check LDAP configuration", e);
        }

    }
    return false;
}
 
开发者ID:Acosix,项目名称:alfresco-mt-support,代码行数:46,代码来源:LDAPInitialDirContextFactoryImpl.java

示例8: searchUsers

import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
@Override
public List<LdapUser> searchUsers(final String username, final LdapContext context, Long domainId) throws NamingException, IOException {

    final SearchControls searchControls = new SearchControls();

    searchControls.setSearchScope(_ldapConfiguration.getScope());
    searchControls.setReturningAttributes(_ldapConfiguration.getReturnAttributes(domainId));

    String basedn = _ldapConfiguration.getBaseDn(domainId);
    if (StringUtils.isBlank(basedn)) {
        throw new IllegalArgumentException("ldap basedn is not configured");
    }
    byte[] cookie = null;
    int pageSize = _ldapConfiguration.getLdapPageSize(domainId);
    context.setRequestControls(new Control[]{new PagedResultsControl(pageSize, Control.NONCRITICAL)});
    final List<LdapUser> users = new ArrayList<LdapUser>();
    NamingEnumeration<SearchResult> results;
    do {
        results = context.search(basedn, generateSearchFilter(username, domainId), searchControls);
        while (results.hasMoreElements()) {
            final SearchResult result = results.nextElement();
            if (!isUserDisabled(result)) {
                users.add(createUser(result, domainId));
            }
        }
        Control[] contextControls = context.getResponseControls();
        if (contextControls != null) {
            for (Control control : contextControls) {
                if (control instanceof PagedResultsResponseControl) {
                    PagedResultsResponseControl prrc = (PagedResultsResponseControl) control;
                    cookie = prrc.getCookie();
                }
            }
        } else {
            s_logger.info("No controls were sent from the ldap server");
        }
        context.setRequestControls(new Control[] {new PagedResultsControl(pageSize, cookie, Control.CRITICAL)});
    } while (cookie != null);

    return users;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:42,代码来源:OpenLdapUserManagerImpl.java


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