You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2008/09/23 18:35:42 UTC
svn commit: r698227 - in /tomcat/trunk/java/org/apache/catalina/realm:
CombinedRealm.java RealmBase.java
Author: markt
Date: Tue Sep 23 09:35:42 2008
New Revision: 698227
URL: http://svn.apache.org/viewvc?rev=698227&view=rev
Log:
Now containers can have multiple realms, need to make sure we don't get duplicate names for the realms in jmx.
Modified:
tomcat/trunk/java/org/apache/catalina/realm/CombinedRealm.java
tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java
Modified: tomcat/trunk/java/org/apache/catalina/realm/CombinedRealm.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/CombinedRealm.java?rev=698227&r1=698226&r2=698227&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/CombinedRealm.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/CombinedRealm.java Tue Sep 23 09:35:42 2008
@@ -23,6 +23,8 @@
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;
@@ -67,6 +69,21 @@
}
+ /**
+ * 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>.
@@ -180,8 +197,14 @@
* @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);
Modified: tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java?rev=698227&r1=698226&r2=698227&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java Tue Sep 23 09:35:42 2008
@@ -1285,6 +1285,7 @@
protected String domain;
protected String host;
protected String path;
+ protected String realmPath = "/realm0";
protected ObjectName oname;
protected ObjectName controller;
protected MBeanServer mserver;
@@ -1309,6 +1310,14 @@
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;
@@ -1370,7 +1379,8 @@
// 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);
@@ -1382,6 +1392,11 @@
}
+ protected String getRealmSuffix() {
+ return ",realmPath=" + getRealmPath();
+ }
+
+
protected static class AllRolesMode {
private String name;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org