1 18 package org.apache.activemq.security; 19 20 import org.apache.activemq.broker.Broker; 21 import org.apache.activemq.broker.BrokerPlugin; 22 23 import java.net.URL ; 24 25 32 public class JaasAuthenticationPlugin implements BrokerPlugin { 33 protected String configuration = "activemq-domain"; 34 protected boolean discoverLoginConfig = true; 35 36 public Broker installPlugin(Broker broker) { 37 initialiseJaas(); 38 return new JaasAuthenticationBroker(broker, configuration); 39 } 40 41 42 public String getConfiguration() { 45 return configuration; 46 } 47 48 51 public void setConfiguration(String jaasConfiguration) { 52 this.configuration = jaasConfiguration; 53 } 54 55 56 public boolean isDiscoverLoginConfig() { 57 return discoverLoginConfig; 58 } 59 60 65 public void setDiscoverLoginConfig(boolean discoverLoginConfig) { 66 this.discoverLoginConfig = discoverLoginConfig; 67 } 68 69 protected void initialiseJaas() { 72 if (discoverLoginConfig) { 73 String path = System.getProperty("java.security.auth.login.config"); 74 if (path == null) { 75 URL resource = null; 77 if (resource == null) { 78 resource = getClass().getClassLoader().getResource("login.config"); 79 } 80 if (resource != null) { 81 path = resource.getFile(); 82 System.setProperty("java.security.auth.login.config", path); 83 } 84 } 85 } 86 } 87 } 88 | Popular Tags |