import java.util.LinkedList;
import java.util.List;
+import javax.management.ObjectName;
+
import org.apache.catalina.Container;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
}
+ /**
+ * Return the set of Realms that this Realm is wrapping
+ */
+ public ObjectName[] getRealms() {
+ ObjectName[] result = new ObjectName[realms.size()];
+ for (Realm realm : realms) {
+ if (realm instanceof RealmBase) {
+ result[realms.indexOf(realm)] =
+ ((RealmBase) realm).getObjectName();
+ }
+ }
+ return result;
+ }
+
+
/**
* Return the Principal associated with the specified username and
* credentials, if there is one; otherwise return <code>null</code>.
* @param container The associated Container
*/
public void setContainer(Container container) {
- // Set the container for sub-realms. Mainly so logging works.
for(Realm realm : realms) {
+ // Set the realmPath for JMX naming
+ if (realm instanceof RealmBase) {
+ ((RealmBase) realm).setRealmPath(
+ getRealmPath() + "/realm" + realms.indexOf(realm));
+ }
+
+ // Set the container for sub-realms. Mainly so logging works.
realm.setContainer(container);
}
super.setContainer(container);
protected String domain;
protected String host;
protected String path;
+ protected String realmPath = "/realm0";
protected ObjectName oname;
protected ObjectName controller;
protected MBeanServer mserver;
return type;
}
+ public String getRealmPath() {
+ return realmPath;
+ }
+
+ public void setRealmPath(String theRealmPath) {
+ realmPath = theRealmPath;
+ }
+
public ObjectName preRegister(MBeanServer server,
ObjectName name) throws Exception {
oname=name;
// register
try {
ContainerBase cb=(ContainerBase)container;
- oname=new ObjectName(cb.getDomain()+":type=Realm" + cb.getContainerSuffix());
+ oname=new ObjectName(cb.getDomain()+":type=Realm" +
+ getRealmSuffix() + cb.getContainerSuffix());
Registry.getRegistry(null, null).registerComponent(this, oname, null );
if(log.isDebugEnabled())
log.debug("Register Realm "+oname);
}
+ protected String getRealmSuffix() {
+ return ",realmPath=" + getRealmPath();
+ }
+
+
protected static class AllRolesMode {
private String name;