1 package com.sslexplorer.security; 2 3 import java.util.ArrayList ; 4 import java.util.Collection ; 5 import java.util.Iterator ; 6 import java.util.List ; 7 8 import org.apache.struts.util.LabelValueBean; 9 import org.apache.struts.util.MessageResources; 10 11 import com.sslexplorer.core.CoreUtil; 12 import com.sslexplorer.input.MultiSelectDataSource; 13 14 public class ModulesDataSource implements MultiSelectDataSource { 15 16 String key; 17 18 public ModulesDataSource(String key) { 19 this.key = key; 20 } 21 22 public Collection <LabelValueBean> getValues(SessionInfo session) { 23 List l = new ArrayList (); 24 for (Iterator i = AuthenticationModuleManager.getInstance().authenticationModuleDefinitions(); i.hasNext();) { 25 AuthenticationModuleDefinition def = (AuthenticationModuleDefinition) i.next(); 26 31 if (!def.getSystem() 32 && !def.getName().equals(HTTPAuthenticationModule.MODULE_NAME) 33 || (def.getName().equals(HTTPAuthenticationModule.MODULE_NAME) && "true".equals(System.getProperty( 34 "sslexplorer.httpBasicAuthenticationModule.enabled", "false")))) { 35 StringBuffer buf = new StringBuffer (); 36 if (def.getPrimary()) { 37 buf.append(" ("); 38 buf.append(CoreUtil.getMessageResources(session.getHttpSession(), key).getMessage("authenticationModule.primary")); 39 } else if(def.getPrimaryIfSecondardExists()) { 40 buf.append(" ("); 41 buf.append(CoreUtil.getMessageResources(session.getHttpSession(), key).getMessage("authenticationModule.primaryIfSecondaryExists")); 42 } else if (def.getSecondary()) { 43 buf.append(" ("); 44 buf.append(CoreUtil.getMessageResources(session.getHttpSession(), key).getMessage("authenticationModule.secondary")); 45 } 46 47 if (buf.length() != 0) { 48 buf.append(")"); 49 } 50 MessageResources mr = CoreUtil.getMessageResources(session.getHttpSession(), def.getMessageResourcesKey()); 51 l 52 .add(new LabelValueBean( 53 mr == null ? ("!unknown bundle " + def.getMessageResourcesKey() + " in module definition") 54 : mr.getMessage("authenticationModule." + def.getName() + ".name") 55 + buf.toString(), def.getName())); 56 } 57 } 58 return l; 59 } 60 61 } 62 | Popular Tags |