本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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);
}
}
示例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;
}
示例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$
}
}
示例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;
}