View Javadoc
1   /*
2    * Copyright 2024 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.bremersee.spring.security.ldaptive.authentication;
18  
19  import java.util.function.Function;
20  import org.bremersee.spring.security.ldaptive.authentication.UsernameToBindDnConverter.ByDomainEmail;
21  import org.bremersee.spring.security.ldaptive.authentication.UsernameToBindDnConverter.ByUserRdnAttribute;
22  
23  /**
24   * The enum UsernameToBindDnConverterReference.
25   *
26   * @author Christian Bremer
27   */
28  public enum UsernameToBindDnConverterProperty
29      implements Function<LdaptiveAuthenticationProperties, UsernameToBindDnConverter> {
30  
31    /**
32     * By user rdn attribute username to bind dn converter property.
33     */
34    BY_USER_RDN_ATTRIBUTE(ByUserRdnAttribute::new),
35  
36    /**
37     * By domain email username to bind dn converter property.
38     */
39    BY_DOMAIN_EMAIL(ByDomainEmail::new);
40  
41    private final Function<LdaptiveAuthenticationProperties, UsernameToBindDnConverter> resolverFn;
42  
43    UsernameToBindDnConverterProperty(
44        Function<LdaptiveAuthenticationProperties, UsernameToBindDnConverter> resolverFn) {
45      this.resolverFn = resolverFn;
46    }
47  
48    @Override
49    public UsernameToBindDnConverter apply(LdaptiveAuthenticationProperties properties) {
50      return resolverFn.apply(properties);
51    }
52  }