1 /** 2 * 3 * Copyright 2003-2004 The Apache Software Foundation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * 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; 18 19 import java.util.Properties; 20 21 import org.apache.geronimo.gbean.GBeanInfo; 22 import org.apache.geronimo.gbean.GBeanInfoBuilder; 23 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 24 25 26 /** 27 * A GBean that wraps a LoginModule, plus options to configure the LoginModule. 28 * If you want to deploy the same LoginModule with different options, you need 29 * more than one of these GBeans. But if you want two security realms to refer 30 * to exactly the same login module configuration, you can have both realms 31 * refer to a single login module GBean. 32 * 33 * @version $Rev: 406019 $ $Date: 2006-05-12 23:08:10 -0700 (Fri, 12 May 2006) $ 34 */ 35 public class LoginModuleGBean implements LoginModuleSettings { 36 private String loginDomainName; 37 private String loginModuleClass; 38 private Properties options; 39 private final String objectName; 40 private boolean serverSide; 41 private boolean wrapPrincipals; 42 private final ClassLoader classLoader; 43 44 public LoginModuleGBean(String loginModuleClass, String objectName, boolean serverSide, boolean wrapPrincipals, ClassLoader classLoader) { 45 this.loginModuleClass = loginModuleClass; 46 this.objectName = objectName; 47 this.serverSide = serverSide; 48 this.wrapPrincipals = wrapPrincipals; 49 this.classLoader = classLoader; 50 } 51 52 public String getLoginDomainName() { 53 return loginDomainName; 54 } 55 56 public void setLoginDomainName(String loginDomainName) { 57 this.loginDomainName = loginDomainName; 58 } 59 60 public Properties getOptions() { 61 return options; 62 } 63 64 public void setOptions(Properties options) { 65 this.options = options; 66 } 67 68 public String getLoginModuleClass() { 69 return loginModuleClass; 70 } 71 72 public void setLoginModuleClass(String loginModuleClass) { 73 this.loginModuleClass = loginModuleClass; 74 } 75 76 public String getObjectName() { 77 return objectName; 78 } 79 80 public boolean isServerSide() { 81 return serverSide; 82 } 83 84 public void setServerSide(boolean serverSide) { 85 this.serverSide = serverSide; 86 } 87 88 public boolean isWrapPrincipals() { 89 return wrapPrincipals; 90 } 91 92 public void setWrapPrincipals(boolean wrapPrincipals) { 93 this.wrapPrincipals = wrapPrincipals; 94 } 95 96 public ClassLoader getClassLoader() { 97 return classLoader; 98 } 99 100 public static final GBeanInfo GBEAN_INFO; 101 102 static { 103 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(LoginModuleGBean.class, NameFactory.LOGIN_MODULE); 104 infoFactory.addAttribute("classLoader", ClassLoader.class, false); 105 infoFactory.addInterface(LoginModuleSettings.class, new String[] {"options", "loginModuleClass", "serverSide", "loginDomainName", "wrapPrincipals"}, 106 new String[] {"options", "loginModuleClass", "serverSide", "wrapPrincipals"} ); 107 infoFactory.setConstructor(new String[]{"loginModuleClass", "objectName", "serverSide", "wrapPrincipals", "classLoader"}); 108 109 GBEAN_INFO = infoFactory.getBeanInfo(); 110 } 111 112 public static GBeanInfo getGBeanInfo() { 113 return GBEAN_INFO; 114 } 115 }