View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.client.console.init;
20  
21  import java.util.Optional;
22  import org.apache.syncope.common.lib.attr.AttrRepoConf;
23  import org.apache.syncope.common.lib.auth.AuthModuleConf;
24  import org.apache.syncope.common.lib.clientapps.UsernameAttributeProviderConf;
25  import org.apache.syncope.common.lib.policy.AccessPolicyConf;
26  import org.apache.syncope.common.lib.policy.AttrReleasePolicyConf;
27  import org.apache.syncope.common.lib.policy.AuthPolicyConf;
28  import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
29  import org.springframework.core.type.filter.AssignableTypeFilter;
30  
31  public class AMClassPathScanImplementationContributor implements ClassPathScanImplementationContributor {
32  
33      private static final long serialVersionUID = 2493303413513242525L;
34  
35      @Override
36      public void extend(final ClassPathScanningCandidateComponentProvider scanner) {
37          scanner.addIncludeFilter(new AssignableTypeFilter(AuthModuleConf.class));
38          scanner.addIncludeFilter(new AssignableTypeFilter(AttrRepoConf.class));
39          scanner.addIncludeFilter(new AssignableTypeFilter(AccessPolicyConf.class));
40          scanner.addIncludeFilter(new AssignableTypeFilter(AttrReleasePolicyConf.class));
41          scanner.addIncludeFilter(new AssignableTypeFilter(AuthPolicyConf.class));
42          scanner.addIncludeFilter(new AssignableTypeFilter(UsernameAttributeProviderConf.class));
43      }
44  
45      @Override
46      public Optional<String> getLabel(final Class<?> clazz) {
47          if (AuthModuleConf.class.isAssignableFrom(clazz)) {
48              return Optional.of(AuthModuleConf.class.getName());
49          }
50          if (AttrRepoConf.class.isAssignableFrom(clazz)) {
51              return Optional.of(AttrRepoConf.class.getName());
52          }
53          if (AccessPolicyConf.class.isAssignableFrom(clazz)) {
54              return Optional.of(AccessPolicyConf.class.getName());
55          }
56          if (AttrReleasePolicyConf.class.isAssignableFrom(clazz)) {
57              return Optional.of(AttrReleasePolicyConf.class.getName());
58          }
59          if (AuthPolicyConf.class.isAssignableFrom(clazz)) {
60              return Optional.of(AuthPolicyConf.class.getName());
61          }
62          if (UsernameAttributeProviderConf.class.isAssignableFrom(clazz)) {
63              return Optional.of(UsernameAttributeProviderConf.class.getName());
64          }
65          return Optional.empty();
66      }
67  }