1 22 package org.jboss.test.xml.mbeanserver; 23 24 import java.util.HashMap ; 25 import javax.security.auth.login.AppConfigurationEntry ; 26 import javax.xml.namespace.QName ; 27 28 import org.jboss.xb.binding.GenericValueContainer; 29 30 34 public class AppConfigurationEntryHolder 35 implements GenericValueContainer 36 { 37 String code; 38 AppConfigurationEntry.LoginModuleControlFlag controlFlag; 39 HashMap options = new HashMap (); 40 41 public AppConfigurationEntryHolder() 43 { 44 } 45 46 AppConfigurationEntryHolder(String code, String flag) 47 { 48 this.code = code; 49 controlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED; 50 if (flag != null) 51 { 52 flag = flag.toLowerCase(); 54 if (AppConfigurationEntry.LoginModuleControlFlag.REQUIRED.toString().indexOf(flag) > 0) 55 controlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED; 56 else if (AppConfigurationEntry.LoginModuleControlFlag.REQUISITE.toString().indexOf(flag) > 0) 57 controlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUISITE; 58 else if (AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT.toString().indexOf(flag) > 0) 59 controlFlag = AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT; 60 else if (AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL.toString().indexOf(flag) > 0) 61 controlFlag = AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL; 62 } 63 } 64 65 public AppConfigurationEntry getEntry() 66 { 67 AppConfigurationEntry entry = new AppConfigurationEntry (code, controlFlag, options); 68 return entry; 69 } 70 71 public void addOption(ModuleOption option) 72 { 73 options.put(option.name, option.value); 74 } 75 76 78 public void addChild(QName name, Object value) 79 { 80 if("code".equals(name.getLocalPart())) 81 { 82 this.code = (String )value; 83 } 84 else if("flag".equals(name.getLocalPart())) 85 { 86 String flag = ((String )value).toLowerCase(); 88 if (AppConfigurationEntry.LoginModuleControlFlag.REQUIRED.toString().indexOf(flag) > 0) 89 controlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED; 90 else if (AppConfigurationEntry.LoginModuleControlFlag.REQUISITE.toString().indexOf(flag) > 0) 91 controlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUISITE; 92 else if (AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT.toString().indexOf(flag) > 0) 93 controlFlag = AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT; 94 else if (AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL.toString().indexOf(flag) > 0) 95 controlFlag = AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL; 96 } 97 else if("module-option".equals(name.getLocalPart())) 98 { 99 addOption((ModuleOption)value); 100 } 101 } 102 103 public Object instantiate() 104 { 105 return new AppConfigurationEntry (code, controlFlag, options); 106 } 107 108 public Class getTargetClass() 109 { 110 return AppConfigurationEntry .class; 111 } 112 } 113 | Popular Tags |