View Javadoc

1   /**
2    *
3    *  Licensed to the Apache Software Foundation (ASF) under one or more
4    *  contributor license agreements.  See the NOTICE file distributed with
5    *  this work for additional information regarding copyright ownership.
6    *  The ASF licenses this file to You under the Apache License, Version 2.0
7    *  (the "License"); you may not use this file except in compliance with
8    *  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, software
13   *  distributed under the License is distributed on an "AS IS" BASIS,
14   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *  See the License for the specific language governing permissions and
16   *  limitations under the License.
17   */
18  package org.apache.geronimo.security.jaas;
19  
20  import org.apache.geronimo.gbean.GBeanInfo;
21  import org.apache.geronimo.gbean.GBeanInfoBuilder;
22  import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
23  import org.apache.geronimo.security.jaas.server.JaasLoginModuleConfiguration;
24  
25  
26  /**
27   * Exposes a LoginModule directly to JAAS clients, without any particular
28   * wrapping by Geronimo.  You do still need to declare the login module as a
29   * GBean, but it's not like it will be run through the login service or
30   * anything.
31   *
32   * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
33   */
34  public class DirectConfigurationEntry implements ConfigurationEntryFactory {
35      private final String applicationConfigName;
36      private final LoginModuleControlFlag controlFlag;
37      private final LoginModuleSettings module;
38  
39      public DirectConfigurationEntry() {
40          this.applicationConfigName = null;
41          this.controlFlag = null;
42          this.module = null;
43      }
44  
45      public DirectConfigurationEntry(String applicationConfigName, LoginModuleControlFlag controlFlag, LoginModuleSettings module) {
46          this.applicationConfigName = applicationConfigName;
47          this.controlFlag = controlFlag;
48          this.module = module;
49      }
50  
51      public String getConfigurationName() {
52          return applicationConfigName;
53      }
54  
55      public JaasLoginModuleConfiguration generateConfiguration() {
56          return new JaasLoginModuleConfiguration(module.getLoginModuleClass(), controlFlag, module.getOptions(), module.isServerSide(), applicationConfigName, false, module.getClassLoader());
57      }
58  
59      public static final GBeanInfo GBEAN_INFO;
60  
61      static {
62          GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(DirectConfigurationEntry.class, NameFactory.CONFIGURATION_ENTRY);
63          infoFactory.addInterface(ConfigurationEntryFactory.class);
64          infoFactory.addAttribute("applicationConfigName", String.class, true);
65          infoFactory.addAttribute("controlFlag", LoginModuleControlFlag.class, true);
66  
67          infoFactory.addReference("Module", LoginModuleSettings.class, NameFactory.LOGIN_MODULE);
68  
69          infoFactory.setConstructor(new String[]{"applicationConfigName", "controlFlag", "Module"});
70          GBEAN_INFO = infoFactory.getBeanInfo();
71      }
72  
73      public static GBeanInfo getGBeanInfo() {
74          return GBEAN_INFO;
75      }
76  }