LdapProviderConfig { public static String encodeFilterValue(String value) { StringBuilder sb = null; for (int i = 0; i < value.length(); i++) { char ch = value.charAt(i); String replace; switch (ch) { case '*': replace = "\\2A"; break; case '(': replace = "\\28"; break; case ')': replace = "\\29"; break; case '\\': replace = "\\5C"; break; case '\0': replace = "\\00"; break; default: replace = null; } if (replace != null) { if (sb == null) { sb = new StringBuilder(value.length() * 2); sb.append(value.substring(0, i)); } sb.append(replace); } else if (sb != null) { sb.append(ch); } } return (sb == null ? value : sb.toString()); }  static LdapProviderConfig of(ConfigurationParameters params); @NotNull String getName(); @NotNull LdapProviderConfig setName(@NotNull String name); @NotNull String getHostname(); @NotNull LdapProviderConfig setHostname(@NotNull String hostname); int getPort(); @NotNull LdapProviderConfig setPort(int port); boolean useSSL(); @NotNull LdapProviderConfig setUseSSL(boolean useSSL); boolean useTLS(); @NotNull LdapProviderConfig setUseTLS(boolean useTLS); boolean noCertCheck(); @NotNull LdapProviderConfig setNoCertCheck(boolean noCertCheck); @Nullable String getBindDN(); @NotNull LdapProviderConfig setBindDN(@Nullable String bindDN); @Nullable String getBindPassword(); @NotNull LdapProviderConfig setBindPassword(@Nullable String bindPassword); long getSearchTimeout(); @NotNull LdapProviderConfig setSearchTimeout(long searchTimeout); @NotNull String getGroupMemberAttribute(); @NotNull LdapProviderConfig setGroupMemberAttribute(@NotNull String groupMemberAttribute); @NotNull boolean getUseUidForExtId(); @NotNull LdapProviderConfig setUseUidForExtId(boolean useUidForExtId); @NotNull String[] getCustomAttributes(); @NotNull LdapProviderConfig setCustomAttributes(@NotNull String[] customAttributes); String getMemberOfSearchFilter(@NotNull String dn); @NotNull Identity getUserConfig(); @NotNull Identity getGroupConfig(); @NotNull PoolConfig getAdminPoolConfig(); @NotNull PoolConfig getUserPoolConfig(); static String encodeFilterValue(String value); @Override String toString(); static final String PARAM_NAME_DEFAULT; @Property(
            label = "LDAP Provider Name",
            description = "Name of this LDAP provider configuration. This is used to reference this provider by the login modules.",
            value = PARAM_NAME_DEFAULT
    )
    static final String PARAM_NAME; static final String PARAM_LDAP_HOST_DEFAULT; @Property(
            label = "LDAP Server Hostname",
            description = "Hostname of the LDAP server",
            value = PARAM_LDAP_HOST_DEFAULT
    )
    static final String PARAM_LDAP_HOST; static final int PARAM_LDAP_PORT_DEFAULT; @Property(
            label = "LDAP Server Port",
            description = "Port of the LDAP server",
            intValue = PARAM_LDAP_PORT_DEFAULT
    )
    static final String PARAM_LDAP_PORT; static final boolean PARAM_USE_SSL_DEFAULT; @Property(
            label = "Use SSL",
            description = "Indicates if an SSL (LDAPs) connection should be used.",
            boolValue = PARAM_USE_SSL_DEFAULT
    )
    static final String PARAM_USE_SSL; static final boolean PARAM_USE_TLS_DEFAULT; @Property(
            label = "Use TLS",
            description = "Indicates if TLS should be started on connections.",
            boolValue = PARAM_USE_TLS_DEFAULT
    )
    static final String PARAM_USE_TLS; static final boolean PARAM_NO_CERT_CHECK_DEFAULT; @Property(
            label = "Disable certificate checking",
            description = "Indicates if server certificate validation should be disabled.",
            boolValue = PARAM_NO_CERT_CHECK_DEFAULT
    )
    static final String PARAM_NO_CERT_CHECK; static final String PARAM_BIND_DN_DEFAULT; @Property(
            label = "Bind DN",
            description = "DN of the user for authentication. Leave empty for anonymous bind.",
            value = PARAM_BIND_DN_DEFAULT
    )
    static final String PARAM_BIND_DN; static final String PARAM_BIND_PASSWORD_DEFAULT; @Property(
            label = "Bind Password",
            description = "Password of the user for authentication.",
            passwordValue = PARAM_BIND_PASSWORD_DEFAULT
    )
    static final String PARAM_BIND_PASSWORD; static final String PARAM_SEARCH_TIMEOUT_DEFAULT; @Property(
            label = "Search Timeout",
            description = "Time in until a search times out (eg: '1s' or '1m 30s').",
            value = PARAM_SEARCH_TIMEOUT_DEFAULT
    )
    static final String PARAM_SEARCH_TIMEOUT; static final int PARAM_ADMIN_POOL_MAX_ACTIVE_DEFAULT; @Property(
            label = "Admin pool max active",
            description = "The max active size of the admin connection pool.",
            longValue = PARAM_ADMIN_POOL_MAX_ACTIVE_DEFAULT
    )
    static final String PARAM_ADMIN_POOL_MAX_ACTIVE; static final boolean PARAM_ADMIN_POOL_LOOKUP_ON_VALIDATE_DEFAULT; @Property(
            label = "Admin pool lookup on validate",
            description = "Indicates an ROOT DSE lookup is performed to test if the connection is still valid when taking it out of the pool.",
            boolValue = PARAM_ADMIN_POOL_LOOKUP_ON_VALIDATE_DEFAULT
    )
    static final String PARAM_ADMIN_POOL_LOOKUP_ON_VALIDATE; static final String PARAM_ADMIN_POOL_MIN_EVICTABLE_IDLE_TIME_DEFAULT; @Property(
            label = "Admin pool min evictable idle time",
            description = "The minimum amount of time a connection from the admin pool must be idle before becoming eligible for eviction by the idle object evictor, if running (eg: '1m 30s'). When non-positive, no connections will be evicted from the pool due to idle time alone.",
            value = PARAM_ADMIN_POOL_MIN_EVICTABLE_IDLE_TIME_DEFAULT
    )
    static final String PARAM_ADMIN_POOL_MIN_EVICTABLE_IDLE_TIME; static final String PARAM_ADMIN_POOL_TIME_BETWEEN_EVICTION_RUNS_DEFAULT; @Property(
            label = "Time interval to sleep between evictor runs for the admin pool",
            description = "Time interval to sleep between runs of the idle object evictor thread for the admin pool (eg: '1m 30s'). When non-positive, no idle object evictor thread will be run.",
            value = PARAM_ADMIN_POOL_TIME_BETWEEN_EVICTION_RUNS_DEFAULT
    )
    static final String PARAM_ADMIN_POOL_TIME_BETWEEN_EVICTION_RUNS; static final int PARAM_ADMIN_POOL_NUM_TESTS_PER_EVICTION_RUN_DEFAULT; @Property(
            label = "Max number of objects to be tested per run of the idle object evictor for the admin pool",
            description = "The max number of objects to examine during each run of the idle object evictor thread for the admin pool (if any)",
            intValue = PARAM_ADMIN_POOL_NUM_TESTS_PER_EVICTION_RUN_DEFAULT
    )
    static final String PARAM_ADMIN_POOL_NUM_TESTS_PER_EVICTION_RUN; static final int PARAM_USER_POOL_MAX_ACTIVE_DEFAULT; @Property(
            label = "User pool max active",
            description = "The max active size of the user connection pool.",
            longValue = PARAM_USER_POOL_MAX_ACTIVE_DEFAULT
    )
    static final String PARAM_USER_POOL_MAX_ACTIVE; static final boolean PARAM_USER_POOL_LOOKUP_ON_VALIDATE_DEFAULT; @Property(
            label = "User pool lookup on validate",
            description = "Indicates an ROOT DSE lookup is performed to test if the connection is still valid when taking it out of the pool.",
            boolValue = PARAM_USER_POOL_LOOKUP_ON_VALIDATE_DEFAULT
    )
    static final String PARAM_USER_POOL_LOOKUP_ON_VALIDATE; static final String PARAM_USER_POOL_MIN_EVICTABLE_IDLE_TIME_DEFAULT; @Property(
            label = "User pool min evictable idle time",
            description = "The minimum amount of time a connection from the user pool must be idle before becoming eligible for eviction by the idle object evictor, if running (eg: '1m 30s'). When non-positive, no connections will be evicted from the pool due to idle time alone.",
            value = PARAM_USER_POOL_MIN_EVICTABLE_IDLE_TIME_DEFAULT
    )
    static final String PARAM_USER_POOL_MIN_EVICTABLE_IDLE_TIME; static final String PARAM_USER_POOL_TIME_BETWEEN_EVICTION_RUNS_DEFAULT; @Property(
            label = "Time interval to sleep between evictor runs for the user pool",
            description = "Time interval to sleep between runs of the idle object evictor thread for the user pool (eg: '1m 30s'). When non-positive, no idle object evictor thread will be run.",
            value = PARAM_USER_POOL_TIME_BETWEEN_EVICTION_RUNS_DEFAULT
    )
    static final String PARAM_USER_POOL_TIME_BETWEEN_EVICTION_RUNS; static final int PARAM_USER_POOL_NUM_TESTS_PER_EVICTION_RUN_DEFAULT; @Property(
            label = "Max number of objects to be tested per run of the idle object evictor for the user pool",
            description = "The max number of objects to examine during each run of the idle object evictor thread for the user pool (if any)",
            intValue = PARAM_USER_POOL_NUM_TESTS_PER_EVICTION_RUN_DEFAULT
    )
    static final String PARAM_USER_POOL_NUM_TESTS_PER_EVICTION_RUN; static final String PARAM_USER_BASE_DN_DEFAULT; @Property(
            label = "User base DN",
            description = "The base DN for user searches.",
            value = PARAM_USER_BASE_DN_DEFAULT
    )
    static final String PARAM_USER_BASE_DN; static final String[] PARAM_USER_OBJECTCLASS_DEFAULT; @Property(
            label = "User object classes",
            description = "The list of object classes an user entry must contain.",
            value = {"person"},
            cardinality = Integer.MAX_VALUE
    )
    static final String PARAM_USER_OBJECTCLASS; static final String PARAM_USER_ID_ATTRIBUTE_DEFAULT; @Property(
            label = "User id attribute",
            description = "Name of the attribute that contains the user id.",
            value = PARAM_USER_ID_ATTRIBUTE_DEFAULT
    )
    static final String PARAM_USER_ID_ATTRIBUTE; static final String PARAM_USER_EXTRA_FILTER_DEFAULT; @Property(
            label = "User extra filter",
            description = "Extra LDAP filter to use when searching for users. The final filter is" +
                    "formatted like: '(&(<idAttr>=<userId>)(objectclass=<objectclass>)<extraFilter>)'",
            value = PARAM_USER_EXTRA_FILTER_DEFAULT
    )
    static final String PARAM_USER_EXTRA_FILTER; static final boolean PARAM_USER_MAKE_DN_PATH_DEFAULT; @Property(
            label = "User DN paths",
            description = "Controls if the DN should be used for calculating a portion of the intermediate path.",
            boolValue = PARAM_USER_MAKE_DN_PATH_DEFAULT
    )
    static final String PARAM_USER_MAKE_DN_PATH; static final String PARAM_GROUP_BASE_DN_DEFAULT; @Property(
            label = "Group base DN",
            description = "The base DN for group searches.",
            value = PARAM_GROUP_BASE_DN_DEFAULT
    )
    static final String PARAM_GROUP_BASE_DN; static final String[] PARAM_GROUP_OBJECTCLASS_DEFAULT; @Property(
            label = "Group object classes",
            description = "The list of object classes a group entry must contain.",
            value = {"groupOfUniqueNames"},
            cardinality = Integer.MAX_VALUE
    )
    static final String PARAM_GROUP_OBJECTCLASS; static final String PARAM_GROUP_NAME_ATTRIBUTE_DEFAULT; @Property(
            label = "Group name attribute",
            description = "Name of the attribute that contains the group name.",
            value = PARAM_GROUP_NAME_ATTRIBUTE_DEFAULT
    )
    static final String PARAM_GROUP_NAME_ATTRIBUTE; static final String PARAM_GROUP_EXTRA_FILTER_DEFAULT; @Property(
            label = "Group extra filter",
            description = "Extra LDAP filter to use when searching for groups. The final filter is" +
                    "formatted like: '(&(<nameAttr>=<groupName>)(objectclass=<objectclass>)<extraFilter>)'",
            value = PARAM_GROUP_EXTRA_FILTER_DEFAULT
    )
    static final String PARAM_GROUP_EXTRA_FILTER; static final boolean PARAM_GROUP_MAKE_DN_PATH_DEFAULT; @Property(
            label = "Group DN paths",
            description = "Controls if the DN should be used for calculating a portion of the intermediate path.",
            boolValue = PARAM_GROUP_MAKE_DN_PATH_DEFAULT
    )
    static final String PARAM_GROUP_MAKE_DN_PATH; static final String PARAM_GROUP_MEMBER_ATTRIBUTE_DEFAULT; @Property(
            label = "Group member attribute",
            description = "Group attribute that contains the member(s) of a group.",
            value = PARAM_GROUP_MEMBER_ATTRIBUTE_DEFAULT
    )
    static final String PARAM_GROUP_MEMBER_ATTRIBUTE; static final boolean PARAM_USE_UID_FOR_EXT_ID_DEFAULT; @Property(
            label = "Use user id for external ids",
            description = "If enabled, the value of the user id (resp. group name) attribute will be used to create external identifiers. Leave disabled to use the DN instead.",
            boolValue = PARAM_USE_UID_FOR_EXT_ID_DEFAULT
    )
    static final String PARAM_USE_UID_FOR_EXT_ID; static final String[] PARAM_CUSTOM_ATTRIBUTES_DEFAULT; @Property(
            label = "Custom Attributes",
            description = "Attributes retrieved when looking up LDAP entries. Leave empty to retrieve all attributes.",
            value = {},
            cardinality = Integer.MAX_VALUE
    )
    static final String PARAM_CUSTOM_ATTRIBUTES; }
@Test public void testEncodeFilterValueEscaped() { String value = "\u0000*()\\"; String encodedValue = "\\00\\2A\\28\\29\\5C"; assertEquals(encodedValue, LdapProviderConfig.encodeFilterValue(value)); }