KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > authentication > AbstractAuthenticationFactory


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
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.outerj.daisy.authentication;
17
18 import org.apache.avalon.framework.service.ServiceManager;
19 import org.apache.avalon.framework.service.Serviceable;
20 import org.apache.avalon.framework.service.ServiceException;
21 import org.apache.avalon.framework.logger.Logger;
22 import org.apache.avalon.framework.logger.LogEnabled;
23 import org.apache.avalon.framework.activity.Disposable;
24 import org.apache.avalon.framework.activity.Initializable;
25
26 import java.util.List JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.Iterator JavaDoc;
29
30 public class AbstractAuthenticationFactory implements LogEnabled, Serviceable, Disposable, Initializable {
31     private ServiceManager serviceManager;
32     private AuthenticationSchemeRegistrar authenticationSchemeRegistrar;
33     protected Logger logger;
34     protected List JavaDoc schemes = new ArrayList JavaDoc();
35
36     public void enableLogging(Logger logger) {
37         this.logger = logger;
38     }
39
40     /**
41      * @avalon.dependency key="auth-scheme-registrar" type="org.outerj.daisy.authentication.AuthenticationSchemeRegistrar"
42      */

43     public void service(ServiceManager serviceManager) throws ServiceException {
44         this.serviceManager = serviceManager;
45         this.authenticationSchemeRegistrar = (AuthenticationSchemeRegistrar)serviceManager.lookup("auth-scheme-registrar");
46     }
47
48     public void initialize() throws Exception JavaDoc {
49         Iterator JavaDoc schemesIt = schemes.iterator();
50         while (schemesIt.hasNext()) {
51             authenticationSchemeRegistrar.registerAuthenticationScheme((AuthenticationScheme)schemesIt.next());
52         }
53     }
54
55     public void dispose() {
56         Iterator JavaDoc schemesIt = schemes.iterator();
57         while (schemesIt.hasNext()) {
58             authenticationSchemeRegistrar.unregisterAuthenticationScheme((AuthenticationScheme)schemesIt.next());
59         }
60         serviceManager.release(authenticationSchemeRegistrar);
61     }
62 }
63
Popular Tags