KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > security > jaas > server > JaasLoginModuleConfiguration


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.security.jaas.server;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.Map JavaDoc;
21 import javax.security.auth.spi.LoginModule JavaDoc;
22
23 import org.apache.geronimo.common.GeronimoSecurityException;
24 import org.apache.geronimo.security.jaas.LoginModuleControlFlag;
25
26
27 /**
28  * Describes the configuration of a LoginModule -- its name, class, control
29  * flag, options, and the Geronimo extension for whether it should run on
30  * the client side or server side.
31  *
32  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
33  */

34 public class JaasLoginModuleConfiguration implements Serializable JavaDoc {
35     private final boolean serverSide;
36     private final String JavaDoc loginDomainName;
37     private final LoginModuleControlFlag flag;
38     private final String JavaDoc loginModuleName;
39     private final Map JavaDoc options;
40     private final boolean wrapPrincipals;
41     private final transient ClassLoader JavaDoc classLoader;
42
43     public JaasLoginModuleConfiguration(String JavaDoc loginModuleName, LoginModuleControlFlag flag, Map JavaDoc options,
44                                         boolean serverSide, String JavaDoc loginDomainName, boolean wrapPrincipals, ClassLoader JavaDoc classLoader)
45     {
46         this.serverSide = serverSide;
47         this.flag = flag;
48         this.loginModuleName = loginModuleName;
49         this.options = options;
50         this.loginDomainName = loginDomainName;
51         this.wrapPrincipals = wrapPrincipals;
52         this.classLoader = classLoader;
53     }
54
55     public JaasLoginModuleConfiguration(String JavaDoc loginModuleName, LoginModuleControlFlag flag, Map JavaDoc options, boolean serverSide, ClassLoader JavaDoc classLoader) {
56         this(loginModuleName, flag, options, serverSide, null, false, classLoader);
57     }
58
59     public String JavaDoc getLoginModuleClassName() {
60         return loginModuleName;
61     }
62
63     public LoginModule JavaDoc getLoginModule(ClassLoader JavaDoc loader) throws GeronimoSecurityException {
64         //TODO determine if this is ever called after serialization: if not the classloader passed in is unnecessary.
65
if (classLoader != null) {
66             loader = classLoader;
67         }
68         try {
69             return (LoginModule JavaDoc) loader.loadClass(loginModuleName).newInstance();
70         } catch (Exception JavaDoc e) {
71             throw new GeronimoSecurityException("Unable to instantiate login module", e);
72         }
73     }
74
75     public boolean isServerSide() {
76         return serverSide;
77     }
78
79     public LoginModuleControlFlag getFlag() {
80         return flag;
81     }
82
83     public Map JavaDoc getOptions() {
84         return options;
85     }
86
87     public String JavaDoc getLoginDomainName() {
88         return loginDomainName;
89     }
90
91     public boolean isWrapPrincipals() {
92         return wrapPrincipals;
93     }
94 }
95
Popular Tags