LdapQuery.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.utils.transport.ldap;

  21. import java.util.ArrayList;
  22. import java.util.List;

  23. import javax.naming.ldap.LdapName;

  24. /**
  25.  * Query generica per la funzionalita di ricerca ldap
  26.  * viene definito un filtro, gli attributi da ritornare e una quantita di risultati
  27.  *
  28.  * @author Tommaso Burlon (tommaso.burlon@link.it)
  29.  * @author $Author$  
  30.  * @version $Rev$, $Date$
  31.  *
  32.  */
  33. public class LdapQuery {
  34.     private Integer limit;
  35.     private List<String> attributes;
  36.     private LdapFilter filter;
  37.     private LdapName base;
  38.    
  39.     public LdapQuery() {
  40.         this.attributes = new ArrayList<>();
  41.         this.limit = null;
  42.         this.filter = LdapFilter.isPresent("cn");
  43.         this.base = null;
  44.     }
  45.    
  46.    
  47.     public Integer getLimit() {
  48.         return this.limit;
  49.     }
  50.    
  51.     public List<String> getAttributes() {
  52.         return this.attributes;
  53.     }
  54.    
  55.     public LdapFilter getFilter() {
  56.         return this.filter;
  57.     }
  58.    
  59.     public LdapName getBase() {
  60.         return this.base;
  61.     }
  62.    
  63.     public LdapQuery filter(LdapFilter filter) {
  64.         this.filter = filter;
  65.         return this;
  66.     }
  67.    
  68.     public LdapQuery limit(Integer limit) {
  69.         this.limit = limit;
  70.         return this;
  71.     }
  72.    
  73.     public LdapQuery attributes(String ...attributes) {
  74.         this.attributes = List.of(attributes);
  75.         return this;
  76.     }
  77.    
  78.     public LdapQuery base(LdapName base) {
  79.         this.base = base;
  80.         return this;
  81.     }
  82.    
  83.    
  84. }