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


Java PagedResultsResponseControl.getCookie方法代码示例

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


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

示例1: prepareNextPage

import javax.naming.ldap.PagedResultsResponseControl; //导入方法依赖的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: readResultResponsePageCookie

import javax.naming.ldap.PagedResultsResponseControl; //导入方法依赖的package包/类
private byte[] readResultResponsePageCookie( final Control[] controls )
{
    if ( controls != null )
    {
        for ( Control control : controls )
        {
            if ( control instanceof PagedResultsResponseControl )
            {
                final PagedResultsResponseControl prrc = ( PagedResultsResponseControl ) control;
                final byte[] cookie = prrc.getCookie();
                if ( cookie != null )
                {
                    return cookie;
                }
            }
        }
    }
    return null;
}
 
开发者ID:ldapchai,项目名称:ldapchai,代码行数:20,代码来源:JNDIProviderImpl.java

示例3: getCookie

import javax.naming.ldap.PagedResultsResponseControl; //导入方法依赖的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

示例4: assertDeserialized

import javax.naming.ldap.PagedResultsResponseControl; //导入方法依赖的package包/类
public void assertDeserialized(Serializable initial,
        Serializable deserialized) {

    PagedResultsResponseControl initThr = (PagedResultsResponseControl) initial;
    PagedResultsResponseControl dserThr = (PagedResultsResponseControl) deserialized;

    // verify ResultSize
    int initResultSize = initThr.getResultSize();
    int dserResultSize = dserThr.getResultSize();
    assertTrue(initResultSize == dserResultSize);
    
    // verify Cookie
    byte[] initCookie = initThr.getCookie();
    byte[] dserCookie = dserThr.getCookie();
    assertTrue(Arrays.equals(initCookie, dserCookie));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:TestPagedResultsResponseControl.java

示例5: getPagedResponseCookie

import javax.naming.ldap.PagedResultsResponseControl; //导入方法依赖的package包/类
private byte[] getPagedResponseCookie(Control[] controls) {
if (controls != null) {
    for (Control control : controls) {
	if (control instanceof PagedResultsResponseControl) {
	    PagedResultsResponseControl prrc = (PagedResultsResponseControl) control;
	    return prrc.getCookie();
	}
    }
}
return null;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:LdapService.java

示例6: testGetCookie002

import javax.naming.ldap.PagedResultsResponseControl; //导入方法依赖的package包/类
/**
 * <p>Test method for 'javax.naming.ldap.PagedResultsResponseControl.getCookie()'</p>
 * <p>Here we are testing if this method retrieves the server-generated cookie.</p>
 * <p>The expected result in this case is a not null array.</p>
 */
public void testGetCookie002() {

	byte[] b={48,7,2,1,0,4,2,1,1};
	byte[] c={1,1};
	try {
		PagedResultsResponseControl x=new PagedResultsResponseControl("",false,b);
		for (int i = 0; i < x.getCookie().length; i++) {
			assertEquals(c[i],x.getCookie()[i]);
		}	
	} catch (IOException e) {
		fail("Failed with:"+e);
	}
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:TestPagedResultsResponseControl.java

示例7: searchUsers

import javax.naming.ldap.PagedResultsResponseControl; //导入方法依赖的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

示例8: next

import javax.naming.ldap.PagedResultsResponseControl; //导入方法依赖的package包/类
/**
 * Fetch the next batch of data from the LDAP searchEnumerationr result.
 * @return the next Batch of results.
 */
// GHH 20080326 - set all batches as last batch after an exception
// is thrown calling a method on the enumeration.  Per Javadoc for
// javax.naming.NamingEnumeration, enumeration is invalid after an
// exception is thrown - by setting last batch indicator we prevent
// it from being used again.
// GHH 20080326 - also added return of explanation for generic
// NamingException
public List<?> next() throws TranslatorException {
	try {
		// The search has been executed, so process up to one batch of
		// results.
		List<?> result = null;
		while (result == null && searchEnumeration != null && searchEnumeration.hasMore())
		{
			SearchResult searchResult = (SearchResult) searchEnumeration.next();
			result = getRow(searchResult);
		}
		
		if (result == null && this.executionFactory.usePagination()) {
		    byte[] cookie = null;
			Control[] controls = ldapCtx.getResponseControls();
	        if (controls != null) {
	        	for (int i = 0; i < controls.length; i++) {
	        		if (controls[i] instanceof PagedResultsResponseControl) {
	        			PagedResultsResponseControl prrc = (PagedResultsResponseControl)controls[i];
	                    cookie = prrc.getCookie();
	        		}
	        	}
	        }
	        
	        if (cookie == null) {
	        	return null;
	        }

	        setRequestControls(cookie);
	        executeSearch();
	        return next();
		}

		if (result != null) {
			resultCount++;
		}
		return result;
	} catch (SizeLimitExceededException e) {
		if (resultCount != searchDetails.getCountLimit()) {
			String msg = LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12008);
			TranslatorException te = new TranslatorException(e, msg);
			if (executionFactory.isExceptionOnSizeLimitExceeded()) {
				throw te;
			}
			this.executionContext.addWarning(te);
			LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, msg); 
		}
		return null; // GHH 20080326 - if size limit exceeded don't try to read more results
	} catch (NamingException ne) {
		throw new TranslatorException(ne, LDAPPlugin.Util.gs("ldap_error")); //$NON-NLS-1$
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:63,代码来源:LDAPQueryExecution.java

示例9: searchUsers

import javax.naming.ldap.PagedResultsResponseControl; //导入方法依赖的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.PagedResultsResponseControl.getCookie方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。