1 2 8 package org.jboss.security.auth.login; 9 10 import java.util.Iterator ; 11 import java.util.Map ; 12 import java.util.Map.Entry; 13 import java.io.IOException ; 14 import java.net.URL ; 15 import javax.security.auth.login.Configuration ; 16 import javax.security.auth.login.AppConfigurationEntry ; 17 18 import org.jboss.system.ServiceMBeanSupport; 19 20 25 public class XMLLoginConfig extends ServiceMBeanSupport 26 implements XMLLoginConfigMBean 27 { 28 private XMLLoginConfigImpl config; 29 private boolean passSecurityDomainName; 30 31 public XMLLoginConfig() 32 { 33 config = new XMLLoginConfigImpl(); 34 } 35 36 38 41 public URL getConfigURL() 42 { 43 return config.getConfigURL(); 44 } 45 48 public void setConfigURL(URL configURL) 49 { 50 config.setConfigURL(configURL); 51 } 52 53 56 public void setConfigResource(String resourceName) 57 throws IOException 58 { 59 config.setConfigResource(resourceName); 60 } 61 62 64 public boolean getValidateDTD() 65 { 66 return config.getValidateDTD(); 67 } 68 70 public void setValidateDTD(boolean flag) 71 { 72 config.setValidateDTD(flag); 73 } 74 75 public boolean getPassSecurityDomainName() 76 { 77 return passSecurityDomainName; 78 } 79 public void setPassSecurityDomainName(boolean flag) 80 { 81 this.passSecurityDomainName = flag; 82 } 83 84 87 public void addAppConfig(String appName, AppConfigurationEntry [] entries) 88 { 89 config.addAppConfig(appName, entries); 90 } 91 93 public void removeAppConfig(String appName) 94 { 95 config.removeAppConfig(appName); 96 } 97 98 101 public Configuration getConfiguration(Configuration prevConfig) 102 { 103 config.setParentConfig(prevConfig); 104 return config; 105 } 106 107 111 public String [] loadConfig(URL configURL) throws Exception 112 { 113 return config.loadConfig(configURL); 114 } 115 116 public void removeConfigs(String [] appNames) 117 { 118 int count = appNames == null ? 0 : appNames.length; 119 for(int a = 0; a < count; a ++) 120 removeAppConfig(appNames[a]); 121 } 122 123 125 public String displayAppConfig(String appName) 126 { 127 StringBuffer buffer = new StringBuffer ("<h2>"+appName+" LoginConfiguration</h2>\n"); 128 AppConfigurationEntry [] appEntry = config.getAppConfigurationEntry(appName); 129 if( appEntry == null ) 130 buffer.append("No Entry\n"); 131 else 132 { 133 for(int c = 0; c < appEntry.length; c ++) 134 { 135 AppConfigurationEntry entry = appEntry[c]; 136 buffer.append("LoginModule Class: "+entry.getLoginModuleName()); 137 buffer.append("\n<br>ControlFlag: "+entry.getControlFlag()); 138 buffer.append("\n<br>Options:<ul>"); 139 Map options = entry.getOptions(); 140 Iterator iter = options.entrySet().iterator(); 141 while( iter.hasNext() ) 142 { 143 Entry e = (Entry) iter.next(); 144 buffer.append("<li>"); 145 buffer.append("name="+e.getKey()); 146 buffer.append(", value="+e.getValue()); 147 buffer.append("</li>\n"); 148 } 149 buffer.append("</ul>\n"); 150 } 151 } 152 return buffer.toString(); 153 } 154 156 158 160 protected void startService() throws Exception 161 { 162 config.loadConfig(); 163 } 164 165 167 protected void destroyService() 168 { 169 config.clear(); 170 } 171 172 174 } 175 | Popular Tags |