You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/08/11 07:27:21 UTC
cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy ContextEjb.java ContextEnvironment.java ContextResource.java ErrorPage.java LoginConfig.java SecurityCollection.java SecurityConstraint.java Test.java package.html
craigmcc 00/08/10 22:27:14
Added: catalina/src/share/org/apache/catalina/deploy
ContextEjb.java ContextEnvironment.java
ContextResource.java ErrorPage.java
LoginConfig.java SecurityCollection.java
SecurityConstraint.java Test.java package.html
Log:
Migrate deployment objects to Tomcat 4.0.
Revision Changes Path
1.1 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/ContextEjb.java
Index: ContextEjb.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/ContextEjb.java,v 1.1 2000/08/11 05:26:16 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2000/08/11 05:26:16 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.catalina.deploy;
/**
* Representation of an EJB resource reference for a web application, as
* represented in a <code><ejb-ref></code> element in the
* deployment descriptor.
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2000/08/11 05:26:16 $
*/
public final class ContextEjb {
// ----------------------------------------------------------- Constructors
/**
* Construct a new EJB resource reference with the specified properties
*
* @param name EJB resource reference name
* @param description EJB resource reference description
* @param type Java class name of the EJB bean implementation class
* @param home Java class name of the EJB home implementation class
* @param remote Java class name of the EJB remote implementation class
* @param link Optional link to a J2EE EJB definition
*/
public ContextEjb(String name, String description,
String type, String home,
String remote, String link) {
super();
this.name = name;
this.description = description;
this.type = type;
this.home = home;
this.remote = remote;
this.link = link;
}
// ----------------------------------------------------- Instance Variables
private String description = null;
private String home = null;
private String link = null;
private String name = null;
private String remote = null;
private String type = null;
// ------------------------------------------------------------- Properties
public String getDescription() {
return (this.description);
}
public String getHome() {
return (this.home);
}
public String getLink() {
return (this.link);
}
public String getName() {
return (this.name);
}
public String getRemote() {
return (this.remote);
}
public String getType() {
return (this.type);
}
}
1.1 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/ContextEnvironment.java
Index: ContextEnvironment.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/ContextEnvironment.java,v 1.1 2000/08/11 05:26:16 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2000/08/11 05:26:16 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.catalina.deploy;
/**
* Representation of an application environment entry, as represented in
* an <code><env-entry></code> element in the deployment descriptor.
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2000/08/11 05:26:16 $
*/
public final class ContextEnvironment {
// ----------------------------------------------------------- Constructors
/**
* Construct a new environment entry with the specified properties
*
* @param name Environment entry name
* @param description Environment entry description
* @param type Java class name of the implementation class
* @param value String representation of the entry value
*/
public ContextEnvironment(String name, String description,
String type, String value) {
super();
this.name = name;
this.description = description;
this.type = type;
this.value = value;
}
// ----------------------------------------------------- Instance Variables
private String description = null;
private String name = null;
private String type = null;
private String value = null;
// ------------------------------------------------------------- Properties
public String getDescription() {
return (this.description);
}
public String getName() {
return (this.name);
}
public String getType() {
return (this.type);
}
public String getValue() {
return (this.value);
}
}
1.1 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/ContextResource.java
Index: ContextResource.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/ContextResource.java,v 1.1 2000/08/11 05:26:16 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2000/08/11 05:26:16 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.catalina.deploy;
/**
* Representation of a resource reference for a web application, as
* represented in a <code><resource-ref></code> element in the
* deployment descriptor.
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2000/08/11 05:26:16 $
*/
public final class ContextResource {
// ----------------------------------------------------------- Constructors
/**
* Construct a new resource reference with the specified properties
*
* @param name Resource reference name
* @param description Resource reference description
* @param type Java class name of the implementation class
* @param auth Authorization requirement (SERVLET or CONTAINER)
*/
public ContextResource(String name, String description,
String type, String auth) {
super();
this.name = name;
this.description = description;
this.type = type;
this.auth = auth;
}
// ----------------------------------------------------- Instance Variables
private String auth = null;
private String description = null;
private String name = null;
private String type = null;
// ------------------------------------------------------------- Properties
public String getAuth() {
return (this.auth);
}
public String getDescription() {
return (this.description);
}
public String getName() {
return (this.name);
}
public String getType() {
return (this.type);
}
}
1.1 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/ErrorPage.java
Index: ErrorPage.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/ErrorPage.java,v 1.1 2000/08/11 05:26:16 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2000/08/11 05:26:16 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.catalina.deploy;
/**
* Representation of an error page element for a web application,
* as represented in a <code><error-page></code> element in the
* deployment descriptor.
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2000/08/11 05:26:16 $
*/
public final class ErrorPage {
// ----------------------------------------------------- Instance Variables
/**
* The error (status) code for which this error page is active.
*/
private int errorCode = 0;
/**
* The exception type for which this error page is active.
*/
private String exceptionType = null;
/**
* The context-relative location to handle this error or exception.
*/
private String location = null;
// ------------------------------------------------------------- Properties
/**
* Return the error code.
*/
public int getErrorCode() {
return (this.errorCode);
}
/**
* Set the error code.
*
* @param errorCode The new error code
*/
public void setErrorCode(int errorCode) {
this.errorCode = errorCode;
}
/**
* Set the error code (hack for default XmlMapper data type).
*
* @param errorCode The new error code
*/
public void setErrorCode(String errorCode) {
try {
this.errorCode = Integer.parseInt(errorCode);
} catch (Throwable t) {
this.errorCode = 0;
}
}
/**
* Return the exception type.
*/
public String getExceptionType() {
return (this.exceptionType);
}
/**
* Set the exception type.
*
* @param exceptionType The new exception type
*/
public void setExceptionType(String exceptionType) {
this.exceptionType = exceptionType;
}
/**
* Return the location.
*/
public String getLocation() {
return (this.location);
}
/**
* Set the location.
*
* @param location The new location
*/
public void setLocation(String location) {
this.location = location;
}
// --------------------------------------------------------- Public Methods
/**
* Render a String representation of this object.
*/
public String toString() {
StringBuffer sb = new StringBuffer("ErrorPage[");
if (exceptionType == null) {
sb.append("errorCode=");
sb.append(errorCode);
} else {
sb.append("exceptionType=");
sb.append(exceptionType);
}
sb.append(", location=");
sb.append(location);
sb.append("]");
return (sb.toString());
}
}
1.1 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/LoginConfig.java
Index: LoginConfig.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/LoginConfig.java,v 1.1 2000/08/11 05:26:17 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2000/08/11 05:26:17 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.catalina.deploy;
/**
* Representation of a login configuration element for a web application,
* as represented in a <code><login-config></code> element in the
* deployment descriptor.
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2000/08/11 05:26:17 $
*/
public final class LoginConfig {
// ----------------------------------------------------------- Constructors
/**
* Construct a new login configuration with the specified properties
*
* @param authMethod Authentication method to use, if any
* @param realmName Realm name to use in security challenges
* @param loginPage Context-relative URI of the login page
* @param errorPage Context-relative URI of the error page
*/
public LoginConfig(String authMethod, String realmName,
String loginPage, String errorPage) {
super();
if (authMethod != null)
this.authMethod = authMethod;
if (realmName != null)
this.realmName = realmName;
if (loginPage != null)
this.loginPage = loginPage;
if (errorPage != null)
this.errorPage = errorPage;
}
// ----------------------------------------------------- Instance Variables
/**
* The authentication method to use for application login. Must be
* BASIC, DIGEST, FORM, or CLIENT-CERT.
*/
private String authMethod = null;
/**
* The context-relative URI of the error page for form login.
*/
private String errorPage = null;
/**
* The context-relative URI of the login page for form login.
*/
private String loginPage = null;
/**
* The realm name used when challenging the user for authentication
* credentials.
*/
private String realmName = null;
// ------------------------------------------------------------- Properties
/**
* Return the authentication method for this web application.
*/
public String getAuthMethod() {
return (this.authMethod);
}
/**
* Return the error page URI for form login for this web application.
*/
public String getErrorPage() {
return (this.errorPage);
}
/**
* Return the login page URI for form login for this web application.
*/
public String getLoginPage() {
return (this.loginPage);
}
/**
* Return the realm name for this web application.
*/
public String getRealmName() {
return (this.realmName);
}
}
1.1 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/SecurityCollection.java
Index: SecurityCollection.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/SecurityCollection.java,v 1.1 2000/08/11 05:26:18 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2000/08/11 05:26:18 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.catalina.deploy;
/**
* Representation of a web resource collection for a web application's security
* constraint, as represented in a <code><web-resource-collection></code>
* element in the deployment descriptor.
* <p>
* <b>WARNING</b>: It is assumed that instances of this class will be created
* and modified only within the context of a single thread, before the instance
* is made visible to the remainder of the application. After that, only read
* access is expected. Therefore, none of the read and write access within
* this class is synchronized.
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2000/08/11 05:26:18 $
*/
public final class SecurityCollection {
// ----------------------------------------------------------- Constructors
/**
* Construct a new security collection instance with default values.
*/
public SecurityCollection() {
this(null, null);
}
/**
* Construct a new security collection instance with specified values.
*
* @param name Name of this security collection
*/
public SecurityCollection(String name) {
this(name, null);
}
/**
* Construct a new security collection instance with specified values.
*
* @param name Name of this security collection
* @param description Description of this security collection
*/
public SecurityCollection(String name, String description) {
super();
setName(name);
setDescription(description);
}
// ----------------------------------------------------- Instance Variables
/**
* Description of this web resource collection.
*/
private String description = null;
/**
* The HTTP methods covered by this web resource collection.
*/
private String methods[] = new String[0];
/**
* The name of this web resource collection.
*/
private String name = null;
/**
* The URL patterns protected by this security collection.
*/
private String patterns[] = new String[0];
// ------------------------------------------------------------- Properties
/**
* Return the description of this web resource collection.
*/
public String getDescription() {
return (this.description);
}
/**
* Set the description of this web resource collection.
*
* @param description The new description
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Return the name of this web resource collection.
*/
public String getName() {
return (this.name);
}
/**
* Set the name of this web resource collection
*
* @param name The new name
*/
public void setName(String name) {
this.name = name;
}
// --------------------------------------------------------- Public Methods
/**
* Add an HTTP request method to be part of this web resource collection.
*/
public void addMethod(String method) {
if (method == null)
return;
String results[] = new String[methods.length + 1];
for (int i = 0; i < methods.length; i++)
results[i] = methods[i];
results[methods.length] = method;
methods = results;
}
/**
* Add a URL pattern to be part of this web resource collection.
*/
public void addPattern(String pattern) {
if (pattern == null)
return;
String results[] = new String[patterns.length + 1];
for (int i = 0; i < patterns.length; i++)
results[i] = patterns[i];
results[patterns.length] = pattern;
patterns = results;
}
/**
* Return <code>true</code> if the specified HTTP request method is
* part of this web resource collection.
*
* @param method Request method to check
*/
public boolean findMethod(String method) {
if (methods.length == 0)
return (true);
for (int i = 0; i < methods.length; i++) {
if (methods[i].equals(method))
return (true);
}
return (false);
}
/**
* Return the set of HTTP request methods that are part of this web
* resource collection, or a zero-length array if all request methods
* are included.
*/
public String[] findMethods() {
return (methods);
}
/**
* Is the specified pattern part of this web resource collection?
*
* @param pattern Pattern to be compared
*/
public boolean findPattern(String pattern) {
for (int i = 0; i < patterns.length; i++) {
if (patterns[i].equals(pattern))
return (true);
}
return (false);
}
/**
* Return the set of URL patterns that are part of this web resource
* collection. If none have been specified, a zero-length array is
* returned.
*/
public String[] findPatterns() {
return (patterns);
}
/**
* Remove the specified HTTP request method from those that are part
* of this web resource collection.
*
* @param method Request method to be removed
*/
public void removeMethod(String method) {
if (method == null)
return;
int n = -1;
for (int i = 0; i < methods.length; i++) {
if (methods[i].equals(method)) {
n = i;
break;
}
}
if (n >= 0) {
int j = 0;
String results[] = new String[methods.length - 1];
for (int i = 0; i < methods.length; i++) {
if (i != n)
results[j++] = methods[i];
}
methods = results;
}
}
/**
* Remove the specified URL pattern from those that are part of this
* web resource collection.
*
* @param pattern Pattern to be removed
*/
public void removePattern(String pattern) {
if (pattern == null)
return;
int n = -1;
for (int i = 0; i < patterns.length; i++) {
if (patterns[i].equals(pattern)) {
n = i;
break;
}
}
if (n >= 0) {
int j = 0;
String results[] = new String[patterns.length - 1];
for (int i = 0; i < patterns.length; i++) {
if (i != n)
results[j++] = patterns[i];
}
patterns = results;
}
}
/**
* Return a String representation of this security collection.
*/
public String toString() {
StringBuffer sb = new StringBuffer("SecurityCollection[");
sb.append(name);
if (description != null) {
sb.append(", ");
sb.append(description);
}
sb.append("]");
return (sb.toString());
}
}
1.1 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/SecurityConstraint.java
Index: SecurityConstraint.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/SecurityConstraint.java,v 1.1 2000/08/11 05:26:19 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2000/08/11 05:26:19 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.catalina.deploy;
/**
* Representation of a security constraint element for a web application,
* as represented in a <code><security-constraint></code> element in the
* deployment descriptor.
* <p>
* <b>WARNING</b>: It is assumed that instances of this class will be created
* and modified only within the context of a single thread, before the instance
* is made visible to the remainder of the application. After that, only read
* access is expected. Therefore, none of the read and write access within
* this class is synchronized.
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2000/08/11 05:26:19 $
*/
public final class SecurityConstraint {
// ----------------------------------------------------------- Constructors
/**
* Construct a new security constraint instance with default values.
*/
public SecurityConstraint() {
super();
}
// ----------------------------------------------------- Instance Variables
/**
* The set of roles permitted to access resources protected by this
* security constraint.
*/
private String authRoles[] = new String[0];
/**
* The set of web resource collections protected by this security
* constraint.
*/
private SecurityCollection collections[] = new SecurityCollection[0];
/**
* The user data constraint for this security constraint. Must be NONE,
* INTEGRAL, or CONFIDENTIAL.
*/
private String userConstraint = "NONE";
// ------------------------------------------------------------- Properties
/**
* Return the user data constraint for this security constraint.
*/
public String getUserConstraint() {
return (userConstraint);
}
/**
* Set the user data constraint for this security constraint.
*
* @param userConstraint The new user data constraint
*/
public void setUserConstraint(String userConstraint) {
if (userConstraint != null)
this.userConstraint = userConstraint;
}
// --------------------------------------------------------- Public Methods
/**
* Add an authorization role, which is a role name that will be
* permitted access to the resources protected by this security constraint.
*
* @param authRole Role name to be added
*/
public void addAuthRole(String authRole) {
if (authRole == null)
return;
String results[] = new String[authRoles.length + 1];
for (int i = 0; i < authRoles.length; i++)
results[i] = authRoles[i];
results[authRoles.length] = authRole;
authRoles = results;
}
/**
* Add a new web resource collection to those protected by this
* security constraint.
*
* @param collection The new web resource collection
*/
public void addCollection(SecurityCollection collection) {
if (collection == null)
return;
SecurityCollection results[] =
new SecurityCollection[collections.length + 1];
for (int i = 0; i < collections.length; i++)
results[i] = collections[i];
results[collections.length] = collection;
collections = results;
}
/**
* Return <code>true</code> if the specified role is permitted access to
* the resources protected by this security constraint.
*
* @param role Role name to be checked
*/
public boolean findAuthRole(String role) {
if (role == null)
return (false);
for (int i = 0; i < authRoles.length; i++) {
if (role.equals(authRoles[i]))
return (true);
}
return (false);
}
/**
* Return the set of roles that are permitted access to the resources
* protected by this security constraint. If none have been defined,
* a zero-length array is returned (which implies that all authenticated
* users are permitted access).
*/
public String[] findAuthRoles() {
return (authRoles);
}
/**
* Return the web resource collection for the specified name, if any;
* otherwise, return <code>null</code>.
*
* @param name Web resource collection name to return
*/
public SecurityCollection findCollection(String name) {
if (name == null)
return (null);
for (int i = 0; i < collections.length; i++) {
if (name.equals(collections[i].getName()))
return (collections[i]);
}
return (null);
}
/**
* Return all of the web resource collections protected by this
* security constraint. If there are none, a zero-length array is
* returned.
*/
public SecurityCollection[] findCollections() {
return (collections);
}
/**
* Return <code>true</code> if the specified context-relative URI (and
* associated HTTP method) are protected by this security constraint.
*
* @param uri Context-relative URI to check
* @param method Request method being used
*/
public boolean included(String uri, String method) {
// We cannot match without a valid request method
if (method == null)
return (false);
// Check all of the collections included in this constraint
for (int i = 0; i < collections.length; i++) {
if (!collections[i].findMethod(method))
continue;
String patterns[] = collections[i].findPatterns();
for (int j = 0; j < patterns.length; j++) {
if (matchPattern(uri, patterns[j]))
return (true);
}
}
// No collection included in this constraint matches this request
return (false);
}
/**
* Remove the specified role from the set of roles permitted to access
* the resources protected by this security constraint.
*
* @param authRole Role name to be removed
*/
public void removeAuthRole(String authRole) {
if (authRole == null)
return;
int n = -1;
for (int i = 0; i < authRoles.length; i++) {
if (authRoles[i].equals(authRole)) {
n = i;
break;
}
}
if (n >= 0) {
int j = 0;
String results[] = new String[authRoles.length - 1];
for (int i = 0; i < authRoles.length; i++) {
if (i != n)
results[j++] = authRoles[i];
}
authRoles = results;
}
}
/**
* Remove the specified web resource collection from those protected by
* this security constraint.
*
* @param collection Web resource collection to be removed
*/
public void removeCollection(SecurityCollection collection) {
if (collection == null)
return;
int n = -1;
for (int i = 0; i < collections.length; i++) {
if (collections[i].equals(collection)) {
n = i;
break;
}
}
if (n >= 0) {
int j = 0;
SecurityCollection results[] =
new SecurityCollection[collections.length - 1];
for (int i = 0; i < collections.length; i++) {
if (i != n)
results[j++] = collections[i];
}
collections = results;
}
}
/**
* Return a String representation of this security constraint.
*/
public String toString() {
StringBuffer sb = new StringBuffer("SecurityConstraint[");
for (int i = 0; i < collections.length; i++) {
if (i > 0)
sb.append(", ");
sb.append(collections[i].getName());
}
sb.append("]");
return (sb.toString());
}
// -------------------------------------------------------- Private Methods
/**
* Does the specified request path match the specified URL pattern?
* This method follows the same rules (in the same order) as those used
* for mapping requests to servlets.
*
* @param path Context-relative request path to be checked
* (must start with '/')
* @param pattern URL pattern to be compared against
*/
private boolean matchPattern(String path, String pattern) {
// Normalize the argument strings
if ((path == null) || (path.length() == 0))
path = "/";
if ((pattern == null) || (pattern.length() == 0))
pattern = "/";
// Check for exact match
if (path.equals(pattern))
return (true);
// Check for path prefix matching
if (pattern.startsWith("/") && pattern.endsWith("/*")) {
pattern = pattern.substring(0, pattern.length() - 2);
if (pattern.length() == 0)
return (true); // "/*" is the same as "/"
if (path.endsWith("/"))
path = path.substring(0, path.length() - 1);
while (true) {
if (pattern.equals(path))
return (true);
int slash = path.lastIndexOf('/');
if (slash <= 0)
break;
path = path.substring(0, slash);
}
return (false);
}
// Check for suffix matching
if (pattern.startsWith("*.")) {
int slash = path.lastIndexOf('/');
int period = path.lastIndexOf('.');
if ((slash >= 0) && (period > slash) &&
path.endsWith(pattern.substring(1))) {
return (true);
}
return (false);
}
// Check for universal mapping
if (pattern.equals("/"))
return (true);
return (false);
}
}
1.1 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/Test.java
Index: Test.java
===================================================================
package org.apache.catalina.deploy;
public final class Test {
public static void main(String args[]) {
String list[] = null;
System.out.println("Creating new collection");
SecurityCollection collection = new SecurityCollection();
System.out.println("Adding GET and POST methods");
collection.addMethod("GET");
collection.addMethod("POST");
System.out.println("Currently defined methods:");
list = collection.findMethods();
for (int i = 0; i < list.length; i++)
System.out.println(" " + list[i]);
System.out.println("Is DELETE included? " +
collection.findMethod("DELETE"));
System.out.println("Is POST included? " +
collection.findMethod("POST"));
System.out.println("Removing POST method");
collection.removeMethod("POST");
System.out.println("Currently defined methods:");
list = collection.findMethods();
for (int i = 0; i < list.length; i++)
System.out.println(" " + list[i]);
System.out.println("Is DELETE included? " +
collection.findMethod("DELETE"));
System.out.println("Is POST included? " +
collection.findMethod("POST"));
}
}
1.1 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/package.html
Index: package.html
===================================================================
<body>
<p>This package contains Java objects that represent complex data structures
from the web application deployment descriptor file (<code>web.xml</code>).
It is assumed that these objects will be initialized within the context of
a single thread, and then referenced in a read-only manner subsequent to that
time. Therefore, no multi-thread synchronization is utilized within the
implementation classes.</p>
</body>