001 /** 002 * 003 * Copyright 2003-2004 The Apache Software Foundation 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.security.jaas; 018 019 import java.util.Properties; 020 021 import org.apache.geronimo.gbean.GBeanInfo; 022 import org.apache.geronimo.gbean.GBeanInfoBuilder; 023 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 024 025 026 /** 027 * A GBean that wraps a LoginModule, plus options to configure the LoginModule. 028 * If you want to deploy the same LoginModule with different options, you need 029 * more than one of these GBeans. But if you want two security realms to refer 030 * to exactly the same login module configuration, you can have both realms 031 * refer to a single login module GBean. 032 * 033 * @version $Rev: 406019 $ $Date: 2006-05-12 23:08:10 -0700 (Fri, 12 May 2006) $ 034 */ 035 public class LoginModuleGBean implements LoginModuleSettings { 036 private String loginDomainName; 037 private String loginModuleClass; 038 private Properties options; 039 private final String objectName; 040 private boolean serverSide; 041 private boolean wrapPrincipals; 042 private final ClassLoader classLoader; 043 044 public LoginModuleGBean(String loginModuleClass, String objectName, boolean serverSide, boolean wrapPrincipals, ClassLoader classLoader) { 045 this.loginModuleClass = loginModuleClass; 046 this.objectName = objectName; 047 this.serverSide = serverSide; 048 this.wrapPrincipals = wrapPrincipals; 049 this.classLoader = classLoader; 050 } 051 052 public String getLoginDomainName() { 053 return loginDomainName; 054 } 055 056 public void setLoginDomainName(String loginDomainName) { 057 this.loginDomainName = loginDomainName; 058 } 059 060 public Properties getOptions() { 061 return options; 062 } 063 064 public void setOptions(Properties options) { 065 this.options = options; 066 } 067 068 public String getLoginModuleClass() { 069 return loginModuleClass; 070 } 071 072 public void setLoginModuleClass(String loginModuleClass) { 073 this.loginModuleClass = loginModuleClass; 074 } 075 076 public String getObjectName() { 077 return objectName; 078 } 079 080 public boolean isServerSide() { 081 return serverSide; 082 } 083 084 public void setServerSide(boolean serverSide) { 085 this.serverSide = serverSide; 086 } 087 088 public boolean isWrapPrincipals() { 089 return wrapPrincipals; 090 } 091 092 public void setWrapPrincipals(boolean wrapPrincipals) { 093 this.wrapPrincipals = wrapPrincipals; 094 } 095 096 public ClassLoader getClassLoader() { 097 return classLoader; 098 } 099 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 }