]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.core/src/org/argeo/security/core/AuthenticationProvidersRegister.java
Reduce CMS size
[lgpl/argeo-commons.git] / org.argeo.security.core / src / org / argeo / security / core / AuthenticationProvidersRegister.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
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 package org.argeo.security.core;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.springframework.beans.factory.InitializingBean;
25
26 /**
27 * Maintains a list of authentication providers injected in to a provider
28 * manager, in order to avoid issues with OSGi services and use packages.
29 */
30 public class AuthenticationProvidersRegister implements InitializingBean {
31 private Log log = LogFactory.getLog(AuthenticationProvidersRegister.class);
32
33 private List<Object> providers = new ArrayList<Object>();
34 private List<Object> defaultProviders = new ArrayList<Object>();
35
36 public void register(Object authenticationProvider,
37 Map<String, String> parameters) {
38 providers.add(authenticationProvider);
39 if (log.isTraceEnabled())
40 log.trace("Registered authentication provider " + parameters);
41 }
42
43 public void unregister(Object authenticationProvider,
44 Map<String, String> parameters) {
45 providers.remove(authenticationProvider);
46 if (log.isTraceEnabled())
47 log.trace("Unregistered authentication provider " + parameters);
48 }
49
50 public List<Object> getProviders() {
51 return providers;
52 }
53
54 public void setDefaultProviders(
55 List<Object> defaultProviders) {
56 this.defaultProviders = defaultProviders;
57 }
58
59 public void afterPropertiesSet() throws Exception {
60 providers.addAll(defaultProviders);
61 }
62
63 }