Java Code Examples for javax.naming.ldap.PagedResultsResponseControl#getCookie()
The following examples show how to use
javax.naming.ldap.PagedResultsResponseControl#getCookie() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JNDIProviderImpl.java From ldapchai with GNU Lesser General Public License v2.1 | 6 votes |
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; }
Example 2
Source File: LDAPLoginManagerImpl.java From olat with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: LDAPLoginManagerImpl.java From olat with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: LdapManager.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 6 votes |
public void reactivatePagedSearch() throws NamingException, IOException{ // Examine the paged results control response Control[] controls = ((LdapContext)ctx).getResponseControls(); if (controls != null) { for (int i = 0; i < controls.length; i++) { if (controls[i] instanceof PagedResultsResponseControl) { PagedResultsResponseControl prrc = (PagedResultsResponseControl)controls[i]; // int total = prrc.getResultSize(); this.cookie = prrc.getCookie(); } } // Re-activate paged results ((LdapContext)ctx).setRequestControls(new Control[]{ new PagedResultsControl(pageSize, cookie, Control.CRITICAL) }); } }
Example 5
Source File: ReadOnlyLDAPUserStoreManager.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Parse the controls to navigate to next page. * * @param controls * @return */ private static byte[] parseControls(Control[] controls) { byte[] cookie = null; // Handle the paged results control response if (controls != null) { for (int i = 0; i < controls.length; i++) { if (controls[i] instanceof PagedResultsResponseControl) { PagedResultsResponseControl prrc = (PagedResultsResponseControl) controls[i]; cookie = prrc.getCookie(); } } } return cookie; }
Example 6
Source File: LdapService.java From lams with GNU General Public License v2.0 | 5 votes |
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; }
Example 7
Source File: LdapUserDAO.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
private static byte[] parseControls(Control[] controls) throws NamingException { byte[] cookie = null; if (controls != null) { for (int i = 0; i < controls.length; i++) { if (controls[i] instanceof PagedResultsResponseControl) { PagedResultsResponseControl prrc = (PagedResultsResponseControl) controls[i]; cookie = prrc.getCookie(); } } } return (cookie == null) ? new byte[0] : cookie; }
Example 8
Source File: OpenLdapUserManagerImpl.java From cosmic with Apache License 2.0 | 4 votes |
@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; }
Example 9
Source File: OpenLdapUserManagerImpl.java From cloudstack with Apache License 2.0 | 4 votes |
@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(String.format("ldap basedn is not configured (for domain: %s)", domainId)); } 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 { 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; }