Java源码示例:javax.naming.ldap.SortControl

示例1
@Test
public void testCreateRequestControl() throws Exception {
    SortControl result = (SortControl) tested.createRequestControl();
    assertThat(result).isNotNull();
    assertThat(result.getID()).isEqualTo("1.2.840.113556.1.4.473");
    assertThat(result.getEncodedValue().length).isEqualTo(9);
}
 
示例2
protected void applyRequestControls(AbstractQuery<?, ?> query) {

    try {
      List<Control> controls = new ArrayList<>();

      List<QueryOrderingProperty> orderBy = query.getOrderingProperties();
      if(orderBy != null) {
        for (QueryOrderingProperty orderingProperty : orderBy) {
          String propertyName = orderingProperty.getQueryProperty().getName();
          if(UserQueryProperty.USER_ID.getName().equals(propertyName)) {
            controls.add(new SortControl(ldapConfiguration.getUserIdAttribute(), Control.CRITICAL));

          } else if(UserQueryProperty.EMAIL.getName().equals(propertyName)) {
            controls.add(new SortControl(ldapConfiguration.getUserEmailAttribute(), Control.CRITICAL));

          } else if(UserQueryProperty.FIRST_NAME.getName().equals(propertyName)) {
            controls.add(new SortControl(ldapConfiguration.getUserFirstnameAttribute(), Control.CRITICAL));

          } else if(UserQueryProperty.LAST_NAME.getName().equals(propertyName)) {
            controls.add(new SortControl(ldapConfiguration.getUserLastnameAttribute(), Control.CRITICAL));
          }
        }
      }

      initialContext.setRequestControls(controls.toArray(new Control[0]));

    } catch (Exception e) {
      throw new IdentityProviderException("Exception while setting paging settings", e);
    }
  }