1 22 package org.jboss.jmx.connector.invoker; 23 24 import java.util.HashSet ; 25 import java.util.Properties ; 26 import java.util.StringTokenizer ; 27 28 import org.jboss.logging.Logger; 29 import org.jboss.security.SimplePrincipal; 30 31 33 42 public class ExternalizableRolesAuthorization extends RolesAuthorization 43 { 44 private static Logger log = Logger.getLogger(ExternalizableRolesAuthorization.class); 45 private boolean trace = log.isTraceEnabled(); 46 47 public ExternalizableRolesAuthorization() 48 { 49 Properties props = new Properties (); 51 try 52 { 53 props.load(getTCL().getResourceAsStream("jmxinvoker-roles.properties")); 54 this.setRequiredRoles(getSetOfRoles(props.getProperty("roles"))); 55 } 56 catch (Exception e) 57 { 58 log.error("Error reading roles from jmxinvoker-roles.properties:",e); 59 } 60 } 61 62 68 private HashSet getSetOfRoles(String assignedRoles) 69 { 70 if(trace) 71 log.trace("AssignedRolesString="+assignedRoles); 72 HashSet set = new HashSet (); 73 StringTokenizer st = new StringTokenizer (assignedRoles,","); 74 while(st.hasMoreTokens()) 75 { 76 String aRole = st.nextToken(); 77 set.add(new SimplePrincipal(aRole)); 78 } 79 if(trace) 80 log.trace("roles set="+set); 81 return set; 82 } 83 84 private ClassLoader getTCL() 85 { 86 return Thread.currentThread().getContextClassLoader(); 87 } 88 } 89 | Popular Tags |