Examples of PagedResultsControl


Examples of javax.naming.ldap.PagedResultsControl

   */
  public void testPagedResultsControlIntByteArrayBoolean003() {

    try {
      byte[] by={10,10};
      PagedResultsControl prc=new PagedResultsControl(10,by,true);
      assertNotNull(prc);
    } catch (IOException e) {
      fail("Failed with:"+e);
    }

View Full Code Here

Examples of javax.naming.ldap.PagedResultsControl

   */
  public void testPagedResultsControlIntByteArrayBoolean004() {

    try {
      byte[] by={10,10};
      PagedResultsControl prc=new PagedResultsControl(10,by,false);
      assertNotNull(prc);
    } catch (IOException e) {
      fail("Failed with:"+e);
    }

View Full Code Here

Examples of javax.naming.ldap.PagedResultsControl

   */
  public void testGetEncodedValue001() {

    byte[] by={10,10};
    try {
      PagedResultsControl prc=new PagedResultsControl(10,by,false);
      assertEquals("30 07 02 01 0a 04 02 0a 0a",toHexString(prc.getEncodedValue()));
    } catch (IOException e) {
      fail("Failed with:"+e);
    }
  }
View Full Code Here

Examples of javax.naming.ldap.PagedResultsControl

   * <p>The expected result is a byte array representing the control's ASN.1 BER encoded value.</p>
   */
  public void testGetEncodedValue002() {

    try {
      PagedResultsControl prc=new PagedResultsControl(0,null,false);
      assertEquals("30 05 02 01 00 04 00",toHexString(prc.getEncodedValue()));
    } catch (IOException e) {
      fail("Failed with:"+e);
    }
  }
View Full Code Here

Examples of javax.naming.ldap.PagedResultsControl

   * <p>The expected result is a byte array representing the control's ASN.1 BER encoded value.</p>
   */
  public void testGetEncodedValue003() {

    try {
      PagedResultsControl prc=new PagedResultsControl(0,null,true);
      assertEquals("30 05 02 01 00 04 00",toHexString(prc.getEncodedValue()));
    } catch (IOException e) {
      fail("Failed with:"+e);
    }
  }
View Full Code Here

Examples of javax.naming.ldap.PagedResultsControl

   */
  public void testGetEncodedValue004() {

    byte[] by={1,10,20};
    try {
      PagedResultsControl prc=new PagedResultsControl(0,by,false);
      assertEquals("30 08 02 01 00 04 03 01 0a 14",toHexString(prc.getEncodedValue()));
    } catch (IOException e) {
      fail("Failed with:"+e);
    }
  }
View Full Code Here

Examples of javax.naming.ldap.PagedResultsControl

     */
    private void encode()
    {
        try
        {
            controlValue = new PagedResultsControl( size, cookie, critical ).getEncodedValue();
        }
        catch ( IOException e )
        {
        }
    }
View Full Code Here

Examples of javax.naming.ldap.PagedResultsControl

                        //log issue and do nothing. Go with the default.
                        log.debug("LDAP Group Page Size passed '" + groupPageSize
                            + "' in is invalid. Defaulting to 1000." + nfe.getMessage());
                    }
                }
                ctx.setRequestControls(new Control[] { new PagedResultsControl(defaultPageSize, Control.CRITICAL) });
            }
            // Loop through each configured base DN.  It may be useful
            // in the future to allow for a filter to be configured for
            // each BaseDN, but for now the filter will apply to all.
            String[] baseDNs = baseDN.split(BASEDN_DELIMITER);

            for (int x = 0; x < baseDNs.length; x++) {
                //update query start time
                groupQueryStartTime = System.currentTimeMillis();

                executeGroupSearch(filter, groupDetailsMap, ctx, searchControls, baseDNs, x);

                //update queryResultCount
                groupQueryResultCount = groupDetailsMap.size();
                groupQueryCurrentTime = System.currentTimeMillis();

                // continually parsing pages of results until we're done.
                // only if they're enabled in the UI.
                if (useQueryPaging) {

                    //handle paged results if they're being used here
                    byte[] cookie = null;
                    Control[] controls = ctx.getResponseControls();
                    if (controls != null) {
                        for (Control control : controls) {
                            if (control instanceof PagedResultsResponseControl) {
                                PagedResultsResponseControl pagedResult = (PagedResultsResponseControl) control;
                                cookie = pagedResult.getCookie();
                            }
                        }
                    }
                    //continually parsing pages of results until we're done.
                    while ((groupQueryResultCount <= LDAP_GROUP_QUERY_LIMIT) && (cookie != null)) {
                        //ensure the next requests contains the session/cookie details
                        ctx.setRequestControls(new Control[] { new PagedResultsControl(defaultPageSize, cookie,
                            Control.CRITICAL) });
                        executeGroupSearch(filter, groupDetailsMap, ctx, searchControls, baseDNs, x);

                        //update Query state after each page
                        groupQueryResultCount = groupDetailsMap.size();
View Full Code Here

Examples of javax.naming.ldap.PagedResultsControl

                + "' in is invalid. Defaulting to 1000 results."
                + nfe.getMessage();
            log(msg);
          }
        }
        ctx.setRequestControls(new Control[] { new PagedResultsControl(
            defaultPageSize, Control.CRITICAL) });
      }
            // Loop through each configured base DN.  It may be useful
            // in the future to allow for a filter to be configured for
            // each BaseDN, but for now the filter will apply to all.
            String[] baseDNs = baseDN.split(BASEDN_DELIMITER);

            for (int x = 0; x < baseDNs.length; x++) {
        if (enableVerboseDebugging.isSelected()) {
          log(advdb
              + " this search was excuted against DN component '"
              + baseDNs[x] + "'.");
        }
                executeGroupSearch(filter, groupDetailsMap, ctx, searchControls, baseDNs, x);

        // continually parsing pages of results until we're done.
                // only if they're enabled in the UI.
        if (enable32xFeatures.isSelected()) {
          // handle paged results if they're being used here
          byte[] cookie = null;
          Control[] controls = ctx.getResponseControls();
          if (controls != null) {
            for (Control control : controls) {
              if (control instanceof PagedResultsResponseControl) {
                PagedResultsResponseControl pagedResult = (PagedResultsResponseControl) control;
                cookie = pagedResult.getCookie();
              }
            }
          }

          while (cookie != null) {
            String msg = "RFC 2696 is supported by the server and we are paging through the results. "+
                groupDetailsMap.size()+" results returned so far.";
            if(enableVerboseGroupParsing.isSelected()){
              log(advdb
                  + msg);
            }
            // ensure the next requests contains the session/cookie
            // details
            ctx.setRequestControls(new Control[] { new PagedResultsControl(
                defaultPageSize, cookie, Control.CRITICAL) });
            executeGroupSearch(filter, groupDetailsMap, ctx,
                searchControls, baseDNs, x);
            // empty out cookie
            cookie = null;
View Full Code Here

Examples of javax.naming.ldap.PagedResultsControl

            // Set up request controls, if appropriate.
            List<Control> baseTmpRequestControls = new ArrayList<Control>();
            if (pageSize > 0) {
                // Server side paging.
                baseTmpRequestControls.add(new PagedResultsControl(pageSize, Control.NONCRITICAL));
            }
            Control[] baseRequestControls = baseTmpRequestControls.toArray(new Control[baseTmpRequestControls.size()]);
            ctx.setRequestControls(baseRequestControls);

            SearchControls searchControls = new SearchControls();
            // See if recursive searching is enabled. Otherwise, only search one level.
            if (isSubTreeSearch()) {
                searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
            }
            else {
                searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
            }
            searchControls.setReturningAttributes(new String[] { attribute });
            byte[] cookie;
            // Run through all pages of results (one page is also possible  ;)  )
            do {
                cookie = null;
                NamingEnumeration<SearchResult> answer = ctx.search("", searchFilter, searchControls);

                // Examine all of the results on this page
                while (answer.hasMoreElements()) {
                    answer.next();
                    count++;
                }
                // Examine the paged results control response
                Control[] controls = ctx.getResponseControls();
                if (controls != null) {
                    for (Control control : controls) {
                        if (control instanceof PagedResultsResponseControl) {
                            PagedResultsResponseControl prrc = (PagedResultsResponseControl) control;
                            cookie = prrc.getCookie();
                        }
                    }
                }
                // Close the enumeration.
                answer.close();
                // Re-activate paged results; affects nothing if no paging support
                List<Control> tmpRequestControls = new ArrayList<Control>();
                if (pageSize > 0) {
                    // Server side paging.
                    tmpRequestControls.add(new PagedResultsControl(pageSize, cookie, Control.CRITICAL));
                }
                Control[] requestControls = tmpRequestControls.toArray(new Control[tmpRequestControls.size()]);
                ctx.setRequestControls(requestControls);
            } while (cookie != null);

            // Add groups found in alternate DN
            if (alternateBaseDN != null) {
                ctx2 = getContext(alternateBaseDN);
                ctx2.setRequestControls(baseRequestControls);

                // Run through all pages of results (one page is also possible  ;)  )
                do {
                    cookie = null;
                    NamingEnumeration<SearchResult> answer = ctx2.search("", searchFilter, searchControls);

                    // Examine all of the results on this page
                    while (answer.hasMoreElements()) {
                        answer.next();
                        count++;
                    }
                    // Examine the paged results control response
                    Control[] controls = ctx2.getResponseControls();
                    if (controls != null) {
                        for (Control control : controls) {
                            if (control instanceof PagedResultsResponseControl) {
                                PagedResultsResponseControl prrc = (PagedResultsResponseControl) control;
                                cookie = prrc.getCookie();
                            }
                        }
                    }
                    // Close the enumeration.
                    answer.close();
                    // Re-activate paged results; affects nothing if no paging support
                    List<Control> tmpRequestControls = new ArrayList<Control>();
                    if (pageSize > 0) {
                        // Server side paging.
                        tmpRequestControls.add(new PagedResultsControl(pageSize, cookie, Control.CRITICAL));
                    }
                    Control[] requestControls = tmpRequestControls.toArray(new Control[tmpRequestControls.size()]);
                    ctx2.setRequestControls(requestControls);
                } while (cookie != null);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.