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 2012/01/12 21:51:10 UTC
svn commit: r1230777 - in /tomcat/tc7.0.x/trunk:
java/org/apache/catalina/startup/Tomcat.java
test/org/apache/catalina/mbeans/TestRegistration.java
webapps/docs/changelog.xml
Author: markt
Date: Thu Jan 12 20:51:10 2012
New Revision: 1230777
URL: http://svn.apache.org/viewvc?rev=1230777&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52443
Move the default Realm for the embedded case to the Engine
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Tomcat.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/mbeans/TestRegistration.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Tomcat.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Tomcat.java?rev=1230777&r1=1230776&r2=1230777&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Tomcat.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Tomcat.java Thu Jan 12 20:51:10 2012
@@ -98,9 +98,9 @@ import org.apache.catalina.realm.RealmBa
* In complex cases, you may prefer to use the ordinary Tomcat API to create
* webapp contexts; for example, you might need to install a custom Loader
* before the call to {@link Host#addChild(Container)}. To replicate the basic
- * behavior of the <pre>addWebapp</pre> methods, you may want to call three
- * methods of this class: {@link #getDefaultRealm()},
- * {@link #noDefaultWebXmlPath()}, and {@link #getDefaultWebXmlListener()}.
+ * behavior of the <pre>addWebapp</pre> methods, you may want to call two
+ * methods of this class: {@link #noDefaultWebXmlPath()} and
+ * {@link #getDefaultWebXmlListener()}.
*
* {@link #getDefaultRealm()} returns the simple security realm.
*
@@ -140,9 +140,9 @@ public class Tomcat {
protected String hostname = "localhost";
protected String basedir;
- // Default in-memory realm, will be set by default on
- // created contexts. Can be replaced with setRealm() on
- // the context.
+ // Default in-memory realm, will be set by default on the Engine. Can be
+ // replaced at engine level or over-ridden at Host or Context level
+ @Deprecated // Will be removed in Tomcat 8.0.x.
protected Realm defaultRealm;
private Map<String, String> userPass = new HashMap<String, String>();
private Map<String, List<String>> userRoles =
@@ -445,7 +445,10 @@ public class Tomcat {
* default will be used, using an internal map.
*
* Must be called before adding a context.
+ *
+ * @deprecated Will be removed in Tomcat 8.0.x.
*/
+ @Deprecated
public void setDefaultRealm(Realm realm) {
defaultRealm = realm;
}
@@ -460,6 +463,10 @@ public class Tomcat {
engine = new StandardEngine();
engine.setName( "Tomcat" );
engine.setDefaultHost(hostname);
+ if (defaultRealm == null) {
+ initSimpleAuth();
+ }
+ engine.setRealm(defaultRealm);
service.setContainer(engine);
}
return engine;
@@ -520,10 +527,6 @@ public class Tomcat {
ctx.setName(name);
ctx.setPath(url);
ctx.setDocBase(path);
- if (defaultRealm == null) {
- initSimpleAuth();
- }
- ctx.setRealm(defaultRealm);
ctx.addLifecycleListener(new DefaultWebXmlListener());
@@ -567,7 +570,9 @@ public class Tomcat {
* For complex configurations, this accessor allows callers of this class
* to obtain the simple realm created by default.
* @return the simple in-memory realm created by default.
+ * @deprecated Will be removed in Tomcat 8.0.x
*/
+ @Deprecated
public Realm getDefaultRealm() {
if (defaultRealm == null) {
initSimpleAuth();
@@ -579,9 +584,13 @@ public class Tomcat {
// ---------- Helper methods and classes -------------------
/**
- * Initialize an in-memory realm. You can replace it
- * for contexts with a real one.
+ * Create an in-memory realm. You can replace it for contexts with a real
+ * one. The Realm created here will be added to the Engine by default and
+ * may be replaced at the Engine level or over-ridden (as per normal Tomcat
+ * behaviour) at the Host or Context level.
+ * @deprecated Will be removed in Tomcat 8.0.x
*/
+ @Deprecated
protected void initSimpleAuth() {
defaultRealm = new RealmBase() {
@Override
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/mbeans/TestRegistration.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/mbeans/TestRegistration.java?rev=1230777&r1=1230776&r2=1230777&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/mbeans/TestRegistration.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/mbeans/TestRegistration.java Thu Jan 12 20:51:10 2012
@@ -63,6 +63,7 @@ public class TestRegistration extends To
private static String[] basicMBeanNames() {
return new String[] {
"Tomcat:type=Engine",
+ "Tomcat:type=Realm,realmPath=/realm0",
"Tomcat:type=MBeanFactory",
"Tomcat:type=NamingResources",
"Tomcat:type=Server",
Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1230777&r1=1230776&r2=1230777&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Jan 12 20:51:10 2012
@@ -144,6 +144,12 @@
Move destruction of <code>ContainerBase</code> objects to
<code>ContainerBase</code> to ensure that they are destroyed. (markt)
</scode>
+ <fix>
+ <bug>52443</bug>: Change the behaviour of the default Realm in the
+ embedded use case so it is set once on the Engine rather than on every
+ Context thereby avoiding the Lifecycle issues with having the same Realm
+ set on multiple Contexts. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org