init
This commit is contained in:
25
java/org/apache/tomcat/util/descriptor/Constants.java
Normal file
25
java/org/apache/tomcat/util/descriptor/Constants.java
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String PACKAGE_NAME =
|
||||
Constants.class.getPackage().getName();
|
||||
|
||||
public static final boolean IS_SECURITY_ENABLED = (System.getSecurityManager() != null);
|
||||
}
|
||||
186
java/org/apache/tomcat/util/descriptor/DigesterFactory.java
Normal file
186
java/org/apache/tomcat/util/descriptor/DigesterFactory.java
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.digester.Digester;
|
||||
import org.apache.tomcat.util.digester.RuleSet;
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
import org.xml.sax.ext.EntityResolver2;
|
||||
|
||||
/**
|
||||
* Wrapper class around the Digester that hide Digester's initialization
|
||||
* details.
|
||||
*/
|
||||
public class DigesterFactory {
|
||||
|
||||
private static final StringManager sm =
|
||||
StringManager.getManager(Constants.PACKAGE_NAME);
|
||||
|
||||
private static final Class<ServletContext> CLASS_SERVLET_CONTEXT;
|
||||
private static final Class<?> CLASS_JSP_CONTEXT;
|
||||
|
||||
static {
|
||||
CLASS_SERVLET_CONTEXT = ServletContext.class;
|
||||
Class<?> jspContext = null;
|
||||
try {
|
||||
jspContext = Class.forName("javax.servlet.jsp.JspContext");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Ignore - JSP API is not present.
|
||||
}
|
||||
CLASS_JSP_CONTEXT = jspContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mapping of well-known public IDs used by the Servlet API to the matching
|
||||
* local resource.
|
||||
*/
|
||||
public static final Map<String,String> SERVLET_API_PUBLIC_IDS;
|
||||
|
||||
/**
|
||||
* Mapping of well-known system IDs used by the Servlet API to the matching
|
||||
* local resource.
|
||||
*/
|
||||
public static final Map<String,String> SERVLET_API_SYSTEM_IDS;
|
||||
|
||||
static {
|
||||
Map<String, String> publicIds = new HashMap<>();
|
||||
Map<String, String> systemIds = new HashMap<>();
|
||||
|
||||
// W3C
|
||||
add(publicIds, XmlIdentifiers.XSD_10_PUBLIC, locationFor("XMLSchema.dtd"));
|
||||
add(publicIds, XmlIdentifiers.DATATYPES_PUBLIC, locationFor("datatypes.dtd"));
|
||||
add(systemIds, XmlIdentifiers.XML_2001_XSD, locationFor("xml.xsd"));
|
||||
|
||||
// from J2EE 1.2
|
||||
add(publicIds, XmlIdentifiers.WEB_22_PUBLIC, locationFor("web-app_2_2.dtd"));
|
||||
add(publicIds, XmlIdentifiers.TLD_11_PUBLIC, locationFor("web-jsptaglibrary_1_1.dtd"));
|
||||
|
||||
// from J2EE 1.3
|
||||
add(publicIds, XmlIdentifiers.WEB_23_PUBLIC, locationFor("web-app_2_3.dtd"));
|
||||
add(publicIds, XmlIdentifiers.TLD_12_PUBLIC, locationFor("web-jsptaglibrary_1_2.dtd"));
|
||||
|
||||
// from J2EE 1.4
|
||||
add(systemIds, "http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd",
|
||||
locationFor("j2ee_web_services_1_1.xsd"));
|
||||
add(systemIds, "http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd",
|
||||
locationFor("j2ee_web_services_client_1_1.xsd"));
|
||||
add(systemIds, XmlIdentifiers.WEB_24_XSD, locationFor("web-app_2_4.xsd"));
|
||||
add(systemIds, XmlIdentifiers.TLD_20_XSD, locationFor("web-jsptaglibrary_2_0.xsd"));
|
||||
addSelf(systemIds, "j2ee_1_4.xsd");
|
||||
addSelf(systemIds, "jsp_2_0.xsd");
|
||||
|
||||
// from JavaEE 5
|
||||
add(systemIds, XmlIdentifiers.WEB_25_XSD, locationFor("web-app_2_5.xsd"));
|
||||
add(systemIds, XmlIdentifiers.TLD_21_XSD, locationFor("web-jsptaglibrary_2_1.xsd"));
|
||||
addSelf(systemIds, "javaee_5.xsd");
|
||||
addSelf(systemIds, "jsp_2_1.xsd");
|
||||
addSelf(systemIds, "javaee_web_services_1_2.xsd");
|
||||
addSelf(systemIds, "javaee_web_services_client_1_2.xsd");
|
||||
|
||||
// from JavaEE 6
|
||||
add(systemIds, XmlIdentifiers.WEB_30_XSD, locationFor("web-app_3_0.xsd"));
|
||||
add(systemIds, XmlIdentifiers.WEB_FRAGMENT_30_XSD, locationFor("web-fragment_3_0.xsd"));
|
||||
addSelf(systemIds, "web-common_3_0.xsd");
|
||||
addSelf(systemIds, "javaee_6.xsd");
|
||||
addSelf(systemIds, "jsp_2_2.xsd");
|
||||
addSelf(systemIds, "javaee_web_services_1_3.xsd");
|
||||
addSelf(systemIds, "javaee_web_services_client_1_3.xsd");
|
||||
|
||||
// from JavaEE 7
|
||||
add(systemIds, XmlIdentifiers.WEB_31_XSD, locationFor("web-app_3_1.xsd"));
|
||||
add(systemIds, XmlIdentifiers.WEB_FRAGMENT_31_XSD, locationFor("web-fragment_3_1.xsd"));
|
||||
addSelf(systemIds, "web-common_3_1.xsd");
|
||||
addSelf(systemIds, "javaee_7.xsd");
|
||||
addSelf(systemIds, "jsp_2_3.xsd");
|
||||
addSelf(systemIds, "javaee_web_services_1_4.xsd");
|
||||
addSelf(systemIds, "javaee_web_services_client_1_4.xsd");
|
||||
|
||||
SERVLET_API_PUBLIC_IDS = Collections.unmodifiableMap(publicIds);
|
||||
SERVLET_API_SYSTEM_IDS = Collections.unmodifiableMap(systemIds);
|
||||
}
|
||||
|
||||
private static void addSelf(Map<String, String> ids, String id) {
|
||||
String location = locationFor(id);
|
||||
if (location != null) {
|
||||
ids.put(id, location);
|
||||
ids.put(location, location);
|
||||
}
|
||||
}
|
||||
|
||||
private static void add(Map<String,String> ids, String id, String location) {
|
||||
if (location != null) {
|
||||
ids.put(id, location);
|
||||
// BZ 63311
|
||||
// Support http and https locations as the move away from http and
|
||||
// towards https continues.
|
||||
if (id.startsWith("http://")) {
|
||||
String httpsId = "https://" + id.substring(7);
|
||||
ids.put(httpsId, location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String locationFor(String name) {
|
||||
URL location = CLASS_SERVLET_CONTEXT.getResource("resources/" + name);
|
||||
if (location == null && CLASS_JSP_CONTEXT != null) {
|
||||
location = CLASS_JSP_CONTEXT.getResource("resources/" + name);
|
||||
}
|
||||
if (location == null) {
|
||||
Log log = LogFactory.getLog(DigesterFactory.class);
|
||||
log.warn(sm.getString("digesterFactory.missingSchema", name));
|
||||
return null;
|
||||
}
|
||||
return location.toExternalForm();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a <code>Digester</code> parser.
|
||||
* @param xmlValidation turn on/off xml validation
|
||||
* @param xmlNamespaceAware turn on/off namespace validation
|
||||
* @param rule an instance of <code>RuleSet</code> used for parsing the xml.
|
||||
* @param blockExternal turn on/off the blocking of external resources
|
||||
* @return a new digester
|
||||
*/
|
||||
public static Digester newDigester(boolean xmlValidation,
|
||||
boolean xmlNamespaceAware,
|
||||
RuleSet rule,
|
||||
boolean blockExternal) {
|
||||
Digester digester = new Digester();
|
||||
digester.setNamespaceAware(xmlNamespaceAware);
|
||||
digester.setValidating(xmlValidation);
|
||||
digester.setUseContextClassLoader(true);
|
||||
EntityResolver2 resolver = new LocalResolver(SERVLET_API_PUBLIC_IDS,
|
||||
SERVLET_API_SYSTEM_IDS, blockExternal);
|
||||
digester.setEntityResolver(resolver);
|
||||
if (rule != null) {
|
||||
digester.addRuleSet(rule);
|
||||
}
|
||||
|
||||
return digester;
|
||||
}
|
||||
}
|
||||
47
java/org/apache/tomcat/util/descriptor/InputSourceUtil.java
Normal file
47
java/org/apache/tomcat/util/descriptor/InputSourceUtil.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.tomcat.util.ExceptionUtils;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
public final class InputSourceUtil {
|
||||
|
||||
private InputSourceUtil() {
|
||||
// Utility class. Hide default constructor.
|
||||
}
|
||||
|
||||
|
||||
public static void close(InputSource inputSource) {
|
||||
if (inputSource == null) {
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
InputStream is = inputSource.getByteStream();
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (Throwable t) {
|
||||
ExceptionUtils.handleThrowable(t);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
165
java/org/apache/tomcat/util/descriptor/LocalResolver.java
Normal file
165
java/org/apache/tomcat/util/descriptor/LocalResolver.java
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.ext.EntityResolver2;
|
||||
|
||||
/**
|
||||
* A resolver for locally cached XML resources.
|
||||
*/
|
||||
public class LocalResolver implements EntityResolver2 {
|
||||
|
||||
private static final StringManager sm =
|
||||
StringManager.getManager(Constants.PACKAGE_NAME);
|
||||
|
||||
private static final String[] JAVA_EE_NAMESPACES = {
|
||||
XmlIdentifiers.JAVAEE_1_4_NS,
|
||||
XmlIdentifiers.JAVAEE_5_NS,
|
||||
XmlIdentifiers.JAVAEE_7_NS};
|
||||
|
||||
|
||||
private final Map<String,String> publicIds;
|
||||
private final Map<String,String> systemIds;
|
||||
private final boolean blockExternal;
|
||||
|
||||
/**
|
||||
* Constructor providing mappings of public and system identifiers to local
|
||||
* resources. Each map contains a mapping from a well-known identifier to a
|
||||
* URL for a local resource path.
|
||||
*
|
||||
* @param publicIds mapping of well-known public identifiers to local
|
||||
* resources
|
||||
* @param systemIds mapping of well-known system identifiers to local
|
||||
* resources
|
||||
* @param blockExternal are external resources blocked that are not
|
||||
* well-known
|
||||
*/
|
||||
public LocalResolver(Map<String,String> publicIds,
|
||||
Map<String,String> systemIds, boolean blockExternal) {
|
||||
this.publicIds = publicIds;
|
||||
this.systemIds = systemIds;
|
||||
this.blockExternal = blockExternal;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InputSource resolveEntity(String publicId, String systemId)
|
||||
throws SAXException, IOException {
|
||||
return resolveEntity(null, publicId, null, systemId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InputSource resolveEntity(String name, String publicId,
|
||||
String base, String systemId) throws SAXException, IOException {
|
||||
|
||||
// First try resolving using the publicId
|
||||
String resolved = publicIds.get(publicId);
|
||||
if (resolved != null) {
|
||||
InputSource is = new InputSource(resolved);
|
||||
is.setPublicId(publicId);
|
||||
return is;
|
||||
}
|
||||
|
||||
// If there is no systemId, can't try anything else
|
||||
if (systemId == null) {
|
||||
throw new FileNotFoundException(sm.getString("localResolver.unresolvedEntity",
|
||||
name, publicId, null, base));
|
||||
}
|
||||
|
||||
// Try resolving with the supplied systemId
|
||||
resolved = systemIds.get(systemId);
|
||||
if (resolved != null) {
|
||||
InputSource is = new InputSource(resolved);
|
||||
is.setPublicId(publicId);
|
||||
return is;
|
||||
}
|
||||
|
||||
// Work-around for XML documents that use just the file name for the
|
||||
// location to refer to a JavaEE schema
|
||||
for (String javaEENamespace : JAVA_EE_NAMESPACES) {
|
||||
String javaEESystemId = javaEENamespace + '/' + systemId;
|
||||
resolved = systemIds.get(javaEESystemId);
|
||||
if (resolved != null) {
|
||||
InputSource is = new InputSource(resolved);
|
||||
is.setPublicId(publicId);
|
||||
return is;
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve the supplied systemId against the base
|
||||
URI systemUri;
|
||||
try {
|
||||
if (base == null) {
|
||||
systemUri = new URI(systemId);
|
||||
} else {
|
||||
// Can't use URI.resolve() because "jar:..." URLs are not valid
|
||||
// hierarchical URIs so resolve() does not work. new URL()
|
||||
// delegates to the jar: stream handler and it manages to figure
|
||||
// it out.
|
||||
URI baseUri = new URI(base);
|
||||
systemUri = new URL(baseUri.toURL(), systemId).toURI();
|
||||
}
|
||||
systemUri = systemUri.normalize();
|
||||
} catch (URISyntaxException e) {
|
||||
// May be caused by a | being used instead of a : in an absolute
|
||||
// file URI on Windows.
|
||||
if (blockExternal) {
|
||||
// Absolute paths aren't allowed so block it
|
||||
throw new MalformedURLException(e.getMessage());
|
||||
} else {
|
||||
// See if the URLHandler can resolve it
|
||||
return new InputSource(systemId);
|
||||
}
|
||||
}
|
||||
if (systemUri.isAbsolute()) {
|
||||
// Try the resolved systemId
|
||||
resolved = systemIds.get(systemUri.toString());
|
||||
if (resolved != null) {
|
||||
InputSource is = new InputSource(resolved);
|
||||
is.setPublicId(publicId);
|
||||
return is;
|
||||
}
|
||||
if (!blockExternal) {
|
||||
InputSource is = new InputSource(systemUri.toString());
|
||||
is.setPublicId(publicId);
|
||||
return is;
|
||||
}
|
||||
}
|
||||
|
||||
throw new FileNotFoundException(sm.getString("localResolver.unresolvedEntity",
|
||||
name, publicId, systemId, base));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InputSource getExternalSubset(String name, String baseURI)
|
||||
throws SAXException, IOException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
digesterFactory.missingSchema=The XML schema [{0}] could not be found. This is very likely to break XML validation if XML validation is enabled.
|
||||
|
||||
localResolver.unresolvedEntity=Could not resolve XML resource [{0}] with public ID [{1}], system ID [{2}] and base URI [{3}] to a known, local entity.
|
||||
|
||||
xmlErrorHandler.error=Non-fatal error [{0}] reported processing [{1}].
|
||||
xmlErrorHandler.warning=Warning [{0}] reported processing [{1}].
|
||||
@@ -0,0 +1,17 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
xmlErrorHandler.error=Error no fatal [{0}] reportado por el proceso [{1}].
|
||||
xmlErrorHandler.warning=Aviso [{0}] reportado por el proceso [{1}].
|
||||
@@ -0,0 +1,21 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
digesterFactory.missingSchema=Le schema XML [{0}] n''a pu être trouvé, cela empêchera certainement la validation de fonctionner si elle est activée
|
||||
|
||||
localResolver.unresolvedEntity=Impossible de résoudre vers une entité locale connue la ressource XML [{0}] avec un identifiant public [{1}], un identifiant système [{2}] et une URI de base [{3}]
|
||||
|
||||
xmlErrorHandler.error=L''erreur non fatale [{0}] a été retournée lors du traitement [{1}]
|
||||
xmlErrorHandler.warning=L''avertissement [{0}] a été retournée en traitant [{1}]
|
||||
@@ -0,0 +1,21 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
digesterFactory.missingSchema=XMLスキーマ[{0}]が見つかりませんでした。 これは、XML検証が有効な場合、XML検証を中断する可能性が非常に高いです。
|
||||
|
||||
localResolver.unresolvedEntity=publicID [{1}]、system ID [{2}]、およびベースURI [{3}]を持つXMLリソース[{0}]を既知のローカルエンティティに解決できませんでした。
|
||||
|
||||
xmlErrorHandler.error=致命的ではないエラー[{0}]は処理[{1}]を報告しました。
|
||||
xmlErrorHandler.warning=警告[{0}]が報告されました。[{1}]を処理中
|
||||
@@ -0,0 +1,21 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
digesterFactory.missingSchema=XML 스키머 [{0}]을(를) 찾을 수 없었습니다. XML validation이 사용 가능 상태라면, 이는 XML validation 실패를 일으킬 가능성이 큽니다.
|
||||
|
||||
localResolver.unresolvedEntity=Public ID가 [{1}]이고 system ID가 [{2}]이며 base URI가 [{3}]인 XML 리소스 [{0}]을(를), 알려진 로컬 엔티티로 결정할 수 없습니다.
|
||||
|
||||
xmlErrorHandler.error=[{1}]을(를) 처리 중, 치명적이지 않은 오류 [{0}]이(가) 보고되었습니다.
|
||||
xmlErrorHandler.warning=[{1}]을(를) 처리 중 경고가 보고됨: [{0}]
|
||||
@@ -0,0 +1,16 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
digesterFactory.missingSchema=XML模型[{0}]未找到,如果XML校验功能开启了的话,这很可能终止XML校验
|
||||
75
java/org/apache/tomcat/util/descriptor/XmlErrorHandler.java
Normal file
75
java/org/apache/tomcat/util/descriptor/XmlErrorHandler.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
public class XmlErrorHandler implements ErrorHandler {
|
||||
|
||||
private static final StringManager sm =
|
||||
StringManager.getManager(Constants.PACKAGE_NAME);
|
||||
|
||||
private final List<SAXParseException> errors = new ArrayList<>();
|
||||
|
||||
private final List<SAXParseException> warnings = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void error(SAXParseException exception) throws SAXException {
|
||||
// Collect non-fatal errors
|
||||
errors.add(exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatalError(SAXParseException exception) throws SAXException {
|
||||
// Re-throw fatal errors
|
||||
throw exception;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(SAXParseException exception) throws SAXException {
|
||||
// Collect warnings
|
||||
warnings.add(exception);
|
||||
}
|
||||
|
||||
public List<SAXParseException> getErrors() {
|
||||
// Internal use only - don't worry about immutability
|
||||
return errors;
|
||||
}
|
||||
|
||||
public List<SAXParseException> getWarnings() {
|
||||
// Internal use only - don't worry about immutability
|
||||
return warnings;
|
||||
}
|
||||
|
||||
public void logFindings(Log log, String source) {
|
||||
for (SAXParseException e : getWarnings()) {
|
||||
log.warn(sm.getString(
|
||||
"xmlErrorHandler.warning", e.getMessage(), source));
|
||||
}
|
||||
for (SAXParseException e : getErrors()) {
|
||||
log.warn(sm.getString(
|
||||
"xmlErrorHandler.error", e.getMessage(), source));
|
||||
}
|
||||
}
|
||||
}
|
||||
78
java/org/apache/tomcat/util/descriptor/XmlIdentifiers.java
Normal file
78
java/org/apache/tomcat/util/descriptor/XmlIdentifiers.java
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor;
|
||||
|
||||
/**
|
||||
* Defines constants for well-known Public and System identifiers documented by
|
||||
* the Servlet and JSP specifications.
|
||||
*/
|
||||
public final class XmlIdentifiers {
|
||||
|
||||
// from W3C
|
||||
public static final String XML_2001_XSD = "http://www.w3.org/2001/xml.xsd";
|
||||
public static final String DATATYPES_PUBLIC = "datatypes";
|
||||
public static final String XSD_10_PUBLIC =
|
||||
"-//W3C//DTD XMLSCHEMA 200102//EN";
|
||||
|
||||
// from J2EE 1.2
|
||||
public static final String WEB_22_PUBLIC =
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
|
||||
public static final String WEB_22_SYSTEM =
|
||||
"http://java.sun.com/dtd/web-app_2_2.dtd";
|
||||
public static final String TLD_11_PUBLIC =
|
||||
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
|
||||
public static final String TLD_11_SYSTEM =
|
||||
"http://java.sun.com/dtd/web-jsptaglibrary_1_1.dtd";
|
||||
|
||||
// from J2EE 1.3
|
||||
public static final String WEB_23_PUBLIC =
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
|
||||
public static final String WEB_23_SYSTEM =
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd";
|
||||
public static final String TLD_12_PUBLIC =
|
||||
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
|
||||
public static final String TLD_12_SYSTEM =
|
||||
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd";
|
||||
|
||||
// from J2EE 1.4
|
||||
public static final String JAVAEE_1_4_NS = "http://java.sun.com/xml/ns/j2ee";
|
||||
public static final String WEB_24_XSD = JAVAEE_1_4_NS + "/web-app_2_4.xsd";
|
||||
public static final String TLD_20_XSD = JAVAEE_1_4_NS + "/web-jsptaglibrary_2_0.xsd";
|
||||
public static final String WEBSERVICES_11_XSD =
|
||||
"http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd";
|
||||
|
||||
// from JavaEE 5
|
||||
public static final String JAVAEE_5_NS = "http://java.sun.com/xml/ns/javaee";
|
||||
public static final String WEB_25_XSD = JAVAEE_5_NS + "/web-app_2_5.xsd";
|
||||
public static final String TLD_21_XSD = JAVAEE_5_NS + "/web-jsptaglibrary_2_1.xsd";
|
||||
public static final String WEBSERVICES_12_XSD = JAVAEE_5_NS + "javaee_web_services_1_2.xsd";
|
||||
|
||||
// from JavaEE 6
|
||||
public static final String JAVAEE_6_NS = JAVAEE_5_NS;
|
||||
public static final String WEB_30_XSD = JAVAEE_6_NS + "/web-app_3_0.xsd";
|
||||
public static final String WEB_FRAGMENT_30_XSD = JAVAEE_6_NS + "/web-fragment_3_0.xsd";
|
||||
public static final String WEBSERVICES_13_XSD = JAVAEE_6_NS + "/javaee_web_services_1_3.xsd";
|
||||
|
||||
// from JavaEE 7
|
||||
public static final String JAVAEE_7_NS = "http://xmlns.jcp.org/xml/ns/javaee";
|
||||
public static final String WEB_31_XSD = JAVAEE_7_NS + "/web-app_3_1.xsd";
|
||||
public static final String WEB_FRAGMENT_31_XSD = JAVAEE_7_NS + "/web-fragment_3_1.xsd";
|
||||
public static final String WEBSERVICES_14_XSD = JAVAEE_7_NS + "/javaee_web_services_1_4.xsd";
|
||||
|
||||
private XmlIdentifiers() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.tagplugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.descriptor.DigesterFactory;
|
||||
import org.apache.tomcat.util.descriptor.XmlErrorHandler;
|
||||
import org.apache.tomcat.util.digester.Digester;
|
||||
import org.apache.tomcat.util.digester.RuleSetBase;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Parser for Tag Plugin descriptors.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class TagPluginParser {
|
||||
private final Log log = LogFactory.getLog(TagPluginParser.class); // must not be static
|
||||
private static final String PREFIX = "tag-plugins/tag-plugin";
|
||||
private final Digester digester;
|
||||
private final Map<String, String> plugins = new HashMap<>();
|
||||
|
||||
public TagPluginParser(ServletContext context, boolean blockExternal) {
|
||||
digester = DigesterFactory.newDigester(
|
||||
false, false, new TagPluginRuleSet(), blockExternal);
|
||||
digester.setClassLoader(context.getClassLoader());
|
||||
}
|
||||
|
||||
public void parse(URL url) throws IOException, SAXException {
|
||||
try (InputStream is = url.openStream()) {
|
||||
XmlErrorHandler handler = new XmlErrorHandler();
|
||||
digester.setErrorHandler(handler);
|
||||
|
||||
digester.push(this);
|
||||
|
||||
InputSource source = new InputSource(url.toExternalForm());
|
||||
source.setByteStream(is);
|
||||
digester.parse(source);
|
||||
if (!handler.getWarnings().isEmpty() || !handler.getErrors().isEmpty()) {
|
||||
handler.logFindings(log, source.getSystemId());
|
||||
if (!handler.getErrors().isEmpty()) {
|
||||
// throw the first to indicate there was an error during processing
|
||||
throw handler.getErrors().iterator().next();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
digester.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlugin(String tagClass, String pluginClass) {
|
||||
plugins.put(tagClass, pluginClass);
|
||||
}
|
||||
|
||||
public Map<String, String> getPlugins() {
|
||||
return plugins;
|
||||
}
|
||||
|
||||
private static class TagPluginRuleSet extends RuleSetBase {
|
||||
@Override
|
||||
public void addRuleInstances(Digester digester) {
|
||||
digester.addCallMethod(PREFIX, "addPlugin", 2);
|
||||
digester.addCallParam(PREFIX + "/tag-class", 0);
|
||||
digester.addCallParam(PREFIX + "/plugin-class", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.tld;
|
||||
|
||||
import org.apache.tomcat.util.digester.Digester;
|
||||
import org.apache.tomcat.util.digester.Rule;
|
||||
import org.apache.tomcat.util.digester.RuleSetBase;
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
* RulesSet for digesting implicit.tld files.
|
||||
*
|
||||
* Only version information used and short names are allowed.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ImplicitTldRuleSet extends RuleSetBase {
|
||||
|
||||
private static final StringManager sm = StringManager.getManager(ImplicitTldRuleSet.class);
|
||||
|
||||
private static final String PREFIX = "taglib";
|
||||
private static final String VALIDATOR_PREFIX = PREFIX + "/validator";
|
||||
private static final String TAG_PREFIX = PREFIX + "/tag";
|
||||
private static final String TAGFILE_PREFIX = PREFIX + "/tag-file";
|
||||
private static final String FUNCTION_PREFIX = PREFIX + "/function";
|
||||
|
||||
|
||||
@Override
|
||||
public void addRuleInstances(Digester digester) {
|
||||
|
||||
digester.addCallMethod(PREFIX + "/tlibversion", "setTlibVersion", 0);
|
||||
digester.addCallMethod(PREFIX + "/tlib-version", "setTlibVersion", 0);
|
||||
digester.addCallMethod(PREFIX + "/jspversion", "setJspVersion", 0);
|
||||
digester.addCallMethod(PREFIX + "/jsp-version", "setJspVersion", 0);
|
||||
digester.addRule(PREFIX, new Rule() {
|
||||
// for TLD 2.0 and later, jsp-version is set by version attribute
|
||||
@Override
|
||||
public void begin(String namespace, String name, Attributes attributes) {
|
||||
TaglibXml taglibXml = (TaglibXml) digester.peek();
|
||||
taglibXml.setJspVersion(attributes.getValue("version"));
|
||||
}
|
||||
});
|
||||
digester.addCallMethod(PREFIX + "/shortname", "setShortName", 0);
|
||||
digester.addCallMethod(PREFIX + "/short-name", "setShortName", 0);
|
||||
|
||||
// Elements not permitted
|
||||
digester.addRule(PREFIX + "/uri", new ElementNotAllowedRule());
|
||||
digester.addRule(PREFIX + "/info", new ElementNotAllowedRule());
|
||||
digester.addRule(PREFIX + "/description", new ElementNotAllowedRule());
|
||||
digester.addRule(PREFIX + "/listener/listener-class", new ElementNotAllowedRule());
|
||||
|
||||
digester.addRule(VALIDATOR_PREFIX, new ElementNotAllowedRule());
|
||||
digester.addRule(TAG_PREFIX, new ElementNotAllowedRule());
|
||||
digester.addRule(TAGFILE_PREFIX, new ElementNotAllowedRule());
|
||||
digester.addRule(FUNCTION_PREFIX, new ElementNotAllowedRule());
|
||||
}
|
||||
|
||||
|
||||
private static class ElementNotAllowedRule extends Rule {
|
||||
@Override
|
||||
public void begin(String namespace, String name, Attributes attributes) throws Exception {
|
||||
throw new IllegalArgumentException(
|
||||
sm.getString("implicitTldRule.elementNotAllowed", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
implicitTldRule.elementNotAllowed=The element [{0}] is not permitted in an implicit.tld file
|
||||
@@ -0,0 +1,16 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
implicitTldRule.elementNotAllowed=L''élément [{0}] n''est pas autorisé dans un fichier TLD implicite
|
||||
@@ -0,0 +1,16 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
implicitTldRule.elementNotAllowed=要素[{0}]は、implicit.tldファイルでは許可されていません。
|
||||
@@ -0,0 +1,16 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
implicitTldRule.elementNotAllowed=implicit.tld 파일 내에서, 엘리먼트 [{0}]은(는) 허용되지 않습니다.
|
||||
79
java/org/apache/tomcat/util/descriptor/tld/TagFileXml.java
Normal file
79
java/org/apache/tomcat/util/descriptor/tld/TagFileXml.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.tld;
|
||||
|
||||
/**
|
||||
* Bare-bone model of a tag file loaded from a TLD.
|
||||
* This does not contain the tag-specific attributes that requiring parsing
|
||||
* the actual tag file to derive.
|
||||
*/
|
||||
public class TagFileXml {
|
||||
private String name;
|
||||
private String path;
|
||||
private String displayName;
|
||||
private String smallIcon;
|
||||
private String largeIcon;
|
||||
private String info;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getSmallIcon() {
|
||||
return smallIcon;
|
||||
}
|
||||
|
||||
public void setSmallIcon(String smallIcon) {
|
||||
this.smallIcon = smallIcon;
|
||||
}
|
||||
|
||||
public String getLargeIcon() {
|
||||
return largeIcon;
|
||||
}
|
||||
|
||||
public void setLargeIcon(String largeIcon) {
|
||||
this.largeIcon = largeIcon;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
}
|
||||
124
java/org/apache/tomcat/util/descriptor/tld/TagXml.java
Normal file
124
java/org/apache/tomcat/util/descriptor/tld/TagXml.java
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.tld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.jsp.tagext.TagAttributeInfo;
|
||||
import javax.servlet.jsp.tagext.TagInfo;
|
||||
import javax.servlet.jsp.tagext.TagVariableInfo;
|
||||
|
||||
/**
|
||||
* Model of a tag define in a tag library descriptor.
|
||||
* This represents the information as parsed from the XML but differs from
|
||||
* TagInfo in that is does not provide a link back to the tag library that
|
||||
* defined it.
|
||||
*/
|
||||
public class TagXml {
|
||||
private String name;
|
||||
private String tagClass;
|
||||
private String teiClass;
|
||||
private String bodyContent = TagInfo.BODY_CONTENT_JSP;
|
||||
private String displayName;
|
||||
private String smallIcon;
|
||||
private String largeIcon;
|
||||
private String info;
|
||||
private boolean dynamicAttributes;
|
||||
private final List<TagAttributeInfo> attributes = new ArrayList<>();
|
||||
private final List<TagVariableInfo> variables = new ArrayList<>();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTagClass() {
|
||||
return tagClass;
|
||||
}
|
||||
|
||||
public void setTagClass(String tagClass) {
|
||||
this.tagClass = tagClass;
|
||||
}
|
||||
|
||||
public String getTeiClass() {
|
||||
return teiClass;
|
||||
}
|
||||
|
||||
public void setTeiClass(String teiClass) {
|
||||
this.teiClass = teiClass;
|
||||
}
|
||||
|
||||
public String getBodyContent() {
|
||||
return bodyContent;
|
||||
}
|
||||
|
||||
public void setBodyContent(String bodyContent) {
|
||||
this.bodyContent = bodyContent;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getSmallIcon() {
|
||||
return smallIcon;
|
||||
}
|
||||
|
||||
public void setSmallIcon(String smallIcon) {
|
||||
this.smallIcon = smallIcon;
|
||||
}
|
||||
|
||||
public String getLargeIcon() {
|
||||
return largeIcon;
|
||||
}
|
||||
|
||||
public void setLargeIcon(String largeIcon) {
|
||||
this.largeIcon = largeIcon;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public boolean hasDynamicAttributes() {
|
||||
return dynamicAttributes;
|
||||
}
|
||||
|
||||
public void setDynamicAttributes(boolean dynamicAttributes) {
|
||||
this.dynamicAttributes = dynamicAttributes;
|
||||
}
|
||||
|
||||
public List<TagAttributeInfo> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public List<TagVariableInfo> getVariables() {
|
||||
return variables;
|
||||
}
|
||||
}
|
||||
124
java/org/apache/tomcat/util/descriptor/tld/TaglibXml.java
Normal file
124
java/org/apache/tomcat/util/descriptor/tld/TaglibXml.java
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.tld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.jsp.tagext.FunctionInfo;
|
||||
|
||||
/**
|
||||
* Common representation of a Tag Library Descriptor (TLD) XML file.
|
||||
* <p>
|
||||
* This stores the raw result of parsing an TLD XML file, flattening different
|
||||
* version of the descriptors to a common format. This is different to a
|
||||
* TagLibraryInfo instance that would be passed to a tag validator in that it
|
||||
* does not contain the uri and prefix values used by a JSP to reference this
|
||||
* tag library.
|
||||
*/
|
||||
public class TaglibXml {
|
||||
private String tlibVersion;
|
||||
private String jspVersion;
|
||||
private String shortName;
|
||||
private String uri;
|
||||
private String info;
|
||||
private ValidatorXml validator;
|
||||
private final List<TagXml> tags = new ArrayList<>();
|
||||
private final List<TagFileXml> tagFiles = new ArrayList<>();
|
||||
private final List<String> listeners = new ArrayList<>();
|
||||
private final List<FunctionInfo> functions = new ArrayList<>();
|
||||
|
||||
public String getTlibVersion() {
|
||||
return tlibVersion;
|
||||
}
|
||||
|
||||
public void setTlibVersion(String tlibVersion) {
|
||||
this.tlibVersion = tlibVersion;
|
||||
}
|
||||
|
||||
public String getJspVersion() {
|
||||
return jspVersion;
|
||||
}
|
||||
|
||||
public void setJspVersion(String jspVersion) {
|
||||
this.jspVersion = jspVersion;
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
public void setShortName(String shortName) {
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public ValidatorXml getValidator() {
|
||||
return validator;
|
||||
}
|
||||
|
||||
public void setValidator(ValidatorXml validator) {
|
||||
this.validator = validator;
|
||||
}
|
||||
|
||||
public void addTag(TagXml tag) {
|
||||
tags.add(tag);
|
||||
}
|
||||
|
||||
public List<TagXml> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void addTagFile(TagFileXml tag) {
|
||||
tagFiles.add(tag);
|
||||
}
|
||||
|
||||
public List<TagFileXml> getTagFiles() {
|
||||
return tagFiles;
|
||||
}
|
||||
|
||||
public void addListener(String listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public List<String> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
|
||||
public void addFunction(String name, String klass, String signature) {
|
||||
functions.add(new FunctionInfo(name, klass, signature));
|
||||
}
|
||||
|
||||
public List<FunctionInfo> getFunctions() {
|
||||
return functions;
|
||||
}
|
||||
}
|
||||
99
java/org/apache/tomcat/util/descriptor/tld/TldParser.java
Normal file
99
java/org/apache/tomcat/util/descriptor/tld/TldParser.java
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.tld;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.AccessController;
|
||||
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.descriptor.Constants;
|
||||
import org.apache.tomcat.util.descriptor.DigesterFactory;
|
||||
import org.apache.tomcat.util.descriptor.XmlErrorHandler;
|
||||
import org.apache.tomcat.util.digester.Digester;
|
||||
import org.apache.tomcat.util.digester.RuleSet;
|
||||
import org.apache.tomcat.util.security.PrivilegedGetTccl;
|
||||
import org.apache.tomcat.util.security.PrivilegedSetTccl;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Parses a Tag Library Descriptor.
|
||||
*/
|
||||
public class TldParser {
|
||||
private final Log log = LogFactory.getLog(TldParser.class); // must not be static
|
||||
private final Digester digester;
|
||||
|
||||
public TldParser(boolean namespaceAware, boolean validation,
|
||||
boolean blockExternal) {
|
||||
this(namespaceAware, validation, new TldRuleSet(), blockExternal);
|
||||
}
|
||||
|
||||
public TldParser(boolean namespaceAware, boolean validation, RuleSet ruleSet,
|
||||
boolean blockExternal) {
|
||||
digester = DigesterFactory.newDigester(
|
||||
validation, namespaceAware, ruleSet, blockExternal);
|
||||
}
|
||||
|
||||
public TaglibXml parse(TldResourcePath path) throws IOException, SAXException {
|
||||
ClassLoader original;
|
||||
if (Constants.IS_SECURITY_ENABLED) {
|
||||
PrivilegedGetTccl pa = new PrivilegedGetTccl();
|
||||
original = AccessController.doPrivileged(pa);
|
||||
} else {
|
||||
original = Thread.currentThread().getContextClassLoader();
|
||||
}
|
||||
try (InputStream is = path.openStream()) {
|
||||
if (Constants.IS_SECURITY_ENABLED) {
|
||||
PrivilegedSetTccl pa = new PrivilegedSetTccl(TldParser.class.getClassLoader());
|
||||
AccessController.doPrivileged(pa);
|
||||
} else {
|
||||
Thread.currentThread().setContextClassLoader(TldParser.class.getClassLoader());
|
||||
}
|
||||
XmlErrorHandler handler = new XmlErrorHandler();
|
||||
digester.setErrorHandler(handler);
|
||||
|
||||
TaglibXml taglibXml = new TaglibXml();
|
||||
digester.push(taglibXml);
|
||||
|
||||
InputSource source = new InputSource(path.toExternalForm());
|
||||
source.setByteStream(is);
|
||||
digester.parse(source);
|
||||
if (!handler.getWarnings().isEmpty() || !handler.getErrors().isEmpty()) {
|
||||
handler.logFindings(log, source.getSystemId());
|
||||
if (!handler.getErrors().isEmpty()) {
|
||||
// throw the first to indicate there was an error during processing
|
||||
throw handler.getErrors().iterator().next();
|
||||
}
|
||||
}
|
||||
return taglibXml;
|
||||
} finally {
|
||||
digester.reset();
|
||||
if (Constants.IS_SECURITY_ENABLED) {
|
||||
PrivilegedSetTccl pa = new PrivilegedSetTccl(original);
|
||||
AccessController.doPrivileged(pa);
|
||||
} else {
|
||||
Thread.currentThread().setContextClassLoader(original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setClassLoader(ClassLoader classLoader) {
|
||||
digester.setClassLoader(classLoader);
|
||||
}
|
||||
}
|
||||
171
java/org/apache/tomcat/util/descriptor/tld/TldResourcePath.java
Normal file
171
java/org/apache/tomcat/util/descriptor/tld/TldResourcePath.java
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.tld;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.tomcat.Jar;
|
||||
import org.apache.tomcat.util.scan.JarFactory;
|
||||
import org.apache.tomcat.util.scan.ReferenceCountedJar;
|
||||
|
||||
/**
|
||||
* A TLD Resource Path as defined in JSP 7.3.2.
|
||||
* <p>
|
||||
* This encapsulates references to Tag Library Descriptors that can be located
|
||||
* in different places:
|
||||
* <ul>
|
||||
* <li>As resources within an application</li>
|
||||
* <li>As entries in JAR files included in the application</li>
|
||||
* <li>As resources provided by the container</li>
|
||||
* </ul>
|
||||
* When configuring a mapping from a well-known URI to a TLD, a user is allowed
|
||||
* to specify just the name of a JAR file that implicitly contains a TLD in
|
||||
* <code>META-INF/taglib.tld</code>. Such a mapping must be explicitly converted
|
||||
* to a URL and entryName when using this implementation.
|
||||
*/
|
||||
public class TldResourcePath {
|
||||
private final URL url;
|
||||
private final String webappPath;
|
||||
private final String entryName;
|
||||
|
||||
/**
|
||||
* Constructor identifying a TLD resource directly.
|
||||
*
|
||||
* @param url the location of the TLD
|
||||
* @param webappPath the web application path, if any, of the TLD
|
||||
*/
|
||||
public TldResourcePath(URL url, String webappPath) {
|
||||
this(url, webappPath, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor identifying a TLD packaged within a JAR file.
|
||||
*
|
||||
* @param url the location of the JAR
|
||||
* @param webappPath the web application path, if any, of the JAR
|
||||
* @param entryName the name of the entry in the JAR
|
||||
*/
|
||||
public TldResourcePath(URL url, String webappPath, String entryName) {
|
||||
this.url = url;
|
||||
this.webappPath = webappPath;
|
||||
this.entryName = entryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL of the TLD or of the JAR containing the TLD.
|
||||
*
|
||||
* @return the URL of the TLD
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path within the web application, if any, that the resource
|
||||
* returned by {@link #getUrl()} was obtained from.
|
||||
*
|
||||
* @return the web application path or @null if the the resource is not
|
||||
* located within a web application
|
||||
*/
|
||||
public String getWebappPath() {
|
||||
return webappPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the JAR entry that contains the TLD.
|
||||
* May be null to indicate the URL refers directly to the TLD itself.
|
||||
*
|
||||
* @return the name of the JAR entry that contains the TLD
|
||||
*/
|
||||
public String getEntryName() {
|
||||
return entryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the external form of the URL representing this TLD.
|
||||
* This can be used as a canonical location for the TLD itself, for example,
|
||||
* as the systemId to use when parsing its XML.
|
||||
*
|
||||
* @return the external form of the URL representing this TLD
|
||||
*/
|
||||
public String toExternalForm() {
|
||||
if (entryName == null) {
|
||||
return url.toExternalForm();
|
||||
} else {
|
||||
return "jar:" + url.toExternalForm() + "!/" + entryName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a stream to access the TLD.
|
||||
*
|
||||
* @return a stream containing the TLD content
|
||||
* @throws IOException if there was a problem opening the stream
|
||||
*/
|
||||
public InputStream openStream() throws IOException {
|
||||
if (entryName == null) {
|
||||
return url.openStream();
|
||||
} else {
|
||||
URL entryUrl = JarFactory.getJarEntryURL(url, entryName);
|
||||
return entryUrl.openStream();
|
||||
}
|
||||
}
|
||||
|
||||
public Jar openJar() throws IOException {
|
||||
if (entryName == null) {
|
||||
return null;
|
||||
} else {
|
||||
// Bug 62976
|
||||
// Jar files containing tags are typically opened during initial
|
||||
// compilation and then closed when compilation is complete. The
|
||||
// reference counting wrapper is used because, when background
|
||||
// compilation is enabled, the Jar will need to be accessed (to
|
||||
// check for modifications) after it has been closed at the end
|
||||
// of the compilation stage.
|
||||
// Using a reference counted Jar enables the Jar to be re-opened,
|
||||
// used and then closed again rather than triggering an ISE.
|
||||
return new ReferenceCountedJar(url);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TldResourcePath other = (TldResourcePath) o;
|
||||
|
||||
return url.equals(other.url) &&
|
||||
Objects.equals(webappPath, other.webappPath) &&
|
||||
Objects.equals(entryName, other.entryName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = url.hashCode();
|
||||
result = result * 31 + Objects.hashCode(webappPath);
|
||||
result = result * 31 + Objects.hashCode(entryName);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
362
java/org/apache/tomcat/util/descriptor/tld/TldRuleSet.java
Normal file
362
java/org/apache/tomcat/util/descriptor/tld/TldRuleSet.java
Normal file
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.tld;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.servlet.jsp.tagext.TagAttributeInfo;
|
||||
import javax.servlet.jsp.tagext.TagVariableInfo;
|
||||
import javax.servlet.jsp.tagext.VariableInfo;
|
||||
|
||||
import org.apache.tomcat.util.digester.Digester;
|
||||
import org.apache.tomcat.util.digester.Rule;
|
||||
import org.apache.tomcat.util.digester.RuleSetBase;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
* RulesSet for digesting TLD files.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class TldRuleSet extends RuleSetBase {
|
||||
private static final String PREFIX = "taglib";
|
||||
private static final String VALIDATOR_PREFIX = PREFIX + "/validator";
|
||||
private static final String TAG_PREFIX = PREFIX + "/tag";
|
||||
private static final String TAGFILE_PREFIX = PREFIX + "/tag-file";
|
||||
private static final String FUNCTION_PREFIX = PREFIX + "/function";
|
||||
|
||||
@Override
|
||||
public void addRuleInstances(Digester digester) {
|
||||
|
||||
digester.addCallMethod(PREFIX + "/tlibversion", "setTlibVersion", 0);
|
||||
digester.addCallMethod(PREFIX + "/tlib-version", "setTlibVersion", 0);
|
||||
digester.addCallMethod(PREFIX + "/jspversion", "setJspVersion", 0);
|
||||
digester.addCallMethod(PREFIX + "/jsp-version", "setJspVersion", 0);
|
||||
digester.addRule(PREFIX, new Rule() {
|
||||
// for TLD 2.0 and later, jsp-version is set by version attribute
|
||||
@Override
|
||||
public void begin(String namespace, String name, Attributes attributes) {
|
||||
TaglibXml taglibXml = (TaglibXml) digester.peek();
|
||||
taglibXml.setJspVersion(attributes.getValue("version"));
|
||||
}
|
||||
});
|
||||
digester.addCallMethod(PREFIX + "/shortname", "setShortName", 0);
|
||||
digester.addCallMethod(PREFIX + "/short-name", "setShortName", 0);
|
||||
|
||||
// common rules
|
||||
digester.addCallMethod(PREFIX + "/uri", "setUri", 0);
|
||||
digester.addCallMethod(PREFIX + "/info", "setInfo", 0);
|
||||
digester.addCallMethod(PREFIX + "/description", "setInfo", 0);
|
||||
digester.addCallMethod(PREFIX + "/listener/listener-class", "addListener", 0);
|
||||
|
||||
// validator
|
||||
digester.addObjectCreate(VALIDATOR_PREFIX, ValidatorXml.class.getName());
|
||||
digester.addCallMethod(VALIDATOR_PREFIX + "/validator-class", "setValidatorClass", 0);
|
||||
digester.addCallMethod(VALIDATOR_PREFIX + "/init-param", "addInitParam", 2);
|
||||
digester.addCallParam(VALIDATOR_PREFIX + "/init-param/param-name", 0);
|
||||
digester.addCallParam(VALIDATOR_PREFIX + "/init-param/param-value", 1);
|
||||
digester.addSetNext(VALIDATOR_PREFIX, "setValidator", ValidatorXml.class.getName());
|
||||
|
||||
|
||||
// tag
|
||||
digester.addObjectCreate(TAG_PREFIX, TagXml.class.getName());
|
||||
addDescriptionGroup(digester, TAG_PREFIX);
|
||||
digester.addCallMethod(TAG_PREFIX + "/name", "setName", 0);
|
||||
digester.addCallMethod(TAG_PREFIX + "/tagclass", "setTagClass", 0);
|
||||
digester.addCallMethod(TAG_PREFIX + "/tag-class", "setTagClass", 0);
|
||||
digester.addCallMethod(TAG_PREFIX + "/teiclass", "setTeiClass", 0);
|
||||
digester.addCallMethod(TAG_PREFIX + "/tei-class", "setTeiClass", 0);
|
||||
digester.addCallMethod(TAG_PREFIX + "/bodycontent", "setBodyContent", 0);
|
||||
digester.addCallMethod(TAG_PREFIX + "/body-content", "setBodyContent", 0);
|
||||
|
||||
digester.addRule(TAG_PREFIX + "/variable", new ScriptVariableRule());
|
||||
digester.addCallMethod(TAG_PREFIX + "/variable/name-given", "setNameGiven", 0);
|
||||
digester.addCallMethod(TAG_PREFIX + "/variable/name-from-attribute",
|
||||
"setNameFromAttribute", 0);
|
||||
digester.addCallMethod(TAG_PREFIX + "/variable/variable-class", "setClassName", 0);
|
||||
digester.addRule(TAG_PREFIX + "/variable/declare",
|
||||
new GenericBooleanRule(Variable.class, "setDeclare"));
|
||||
digester.addCallMethod(TAG_PREFIX + "/variable/scope", "setScope", 0);
|
||||
|
||||
digester.addRule(TAG_PREFIX + "/attribute", new TagAttributeRule());
|
||||
digester.addCallMethod(TAG_PREFIX + "/attribute/description", "setDescription", 0);
|
||||
digester.addCallMethod(TAG_PREFIX + "/attribute/name", "setName", 0);
|
||||
digester.addRule(TAG_PREFIX + "/attribute/required",
|
||||
new GenericBooleanRule(Attribute.class, "setRequired"));
|
||||
digester.addRule(TAG_PREFIX + "/attribute/rtexprvalue",
|
||||
new GenericBooleanRule(Attribute.class, "setRequestTime"));
|
||||
digester.addCallMethod(TAG_PREFIX + "/attribute/type", "setType", 0);
|
||||
digester.addCallMethod(TAG_PREFIX + "/attribute/deferred-value", "setDeferredValue");
|
||||
digester.addCallMethod(TAG_PREFIX + "/attribute/deferred-value/type",
|
||||
"setExpectedTypeName", 0);
|
||||
digester.addCallMethod(TAG_PREFIX + "/attribute/deferred-method", "setDeferredMethod");
|
||||
digester.addCallMethod(TAG_PREFIX + "/attribute/deferred-method/method-signature",
|
||||
"setMethodSignature", 0);
|
||||
digester.addRule(TAG_PREFIX + "/attribute/fragment",
|
||||
new GenericBooleanRule(Attribute.class, "setFragment"));
|
||||
|
||||
digester.addRule(TAG_PREFIX + "/dynamic-attributes",
|
||||
new GenericBooleanRule(TagXml.class, "setDynamicAttributes"));
|
||||
digester.addSetNext(TAG_PREFIX, "addTag", TagXml.class.getName());
|
||||
|
||||
// tag-file
|
||||
digester.addObjectCreate(TAGFILE_PREFIX, TagFileXml.class.getName());
|
||||
addDescriptionGroup(digester, TAGFILE_PREFIX);
|
||||
digester.addCallMethod(TAGFILE_PREFIX + "/name", "setName", 0);
|
||||
digester.addCallMethod(TAGFILE_PREFIX + "/path", "setPath", 0);
|
||||
digester.addSetNext(TAGFILE_PREFIX, "addTagFile", TagFileXml.class.getName());
|
||||
|
||||
// function
|
||||
digester.addCallMethod(FUNCTION_PREFIX, "addFunction", 3);
|
||||
digester.addCallParam(FUNCTION_PREFIX + "/name", 0);
|
||||
digester.addCallParam(FUNCTION_PREFIX + "/function-class", 1);
|
||||
digester.addCallParam(FUNCTION_PREFIX + "/function-signature", 2);
|
||||
}
|
||||
|
||||
private void addDescriptionGroup(Digester digester, String prefix) {
|
||||
digester.addCallMethod(prefix + "/info", "setInfo", 0);
|
||||
digester.addCallMethod(prefix + "small-icon", "setSmallIcon", 0);
|
||||
digester.addCallMethod(prefix + "large-icon", "setLargeIcon", 0);
|
||||
|
||||
digester.addCallMethod(prefix + "/description", "setInfo", 0);
|
||||
digester.addCallMethod(prefix + "/display-name", "setDisplayName", 0);
|
||||
digester.addCallMethod(prefix + "/icon/small-icon", "setSmallIcon", 0);
|
||||
digester.addCallMethod(prefix + "/icon/large-icon", "setLargeIcon", 0);
|
||||
}
|
||||
|
||||
private static class TagAttributeRule extends Rule {
|
||||
@Override
|
||||
public void begin(String namespace, String name, Attributes attributes) throws Exception {
|
||||
TaglibXml taglibXml = (TaglibXml) digester.peek(digester.getCount() - 1);
|
||||
digester.push(new Attribute("1.2".equals(taglibXml.getJspVersion())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(String namespace, String name) throws Exception {
|
||||
Attribute attribute = (Attribute) digester.pop();
|
||||
TagXml tag = (TagXml) digester.peek();
|
||||
tag.getAttributes().add(attribute.toTagAttributeInfo());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Attribute {
|
||||
private final boolean allowShortNames;
|
||||
private String name;
|
||||
private boolean required;
|
||||
private String type;
|
||||
private boolean requestTime;
|
||||
private boolean fragment;
|
||||
private String description;
|
||||
private boolean deferredValue;
|
||||
private boolean deferredMethod;
|
||||
private String expectedTypeName;
|
||||
private String methodSignature;
|
||||
|
||||
private Attribute(boolean allowShortNames) {
|
||||
this.allowShortNames = allowShortNames;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setRequired(boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
if (allowShortNames) {
|
||||
switch (type) {
|
||||
case "Boolean":
|
||||
this.type = "java.lang.Boolean";
|
||||
break;
|
||||
case "Character":
|
||||
this.type = "java.lang.Character";
|
||||
break;
|
||||
case "Byte":
|
||||
this.type = "java.lang.Byte";
|
||||
break;
|
||||
case "Short":
|
||||
this.type = "java.lang.Short";
|
||||
break;
|
||||
case "Integer":
|
||||
this.type = "java.lang.Integer";
|
||||
break;
|
||||
case "Long":
|
||||
this.type = "java.lang.Long";
|
||||
break;
|
||||
case "Float":
|
||||
this.type = "java.lang.Float";
|
||||
break;
|
||||
case "Double":
|
||||
this.type = "java.lang.Double";
|
||||
break;
|
||||
case "String":
|
||||
this.type = "java.lang.String";
|
||||
break;
|
||||
case "Object":
|
||||
this.type = "java.lang.Object";
|
||||
break;
|
||||
default:
|
||||
this.type = type;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public void setRequestTime(boolean requestTime) {
|
||||
this.requestTime = requestTime;
|
||||
}
|
||||
|
||||
public void setFragment(boolean fragment) {
|
||||
this.fragment = fragment;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setDeferredValue() {
|
||||
this.deferredValue = true;
|
||||
}
|
||||
|
||||
public void setDeferredMethod() {
|
||||
this.deferredMethod = true;
|
||||
}
|
||||
|
||||
public void setExpectedTypeName(String expectedTypeName) {
|
||||
this.expectedTypeName = expectedTypeName;
|
||||
}
|
||||
|
||||
public void setMethodSignature(String methodSignature) {
|
||||
this.methodSignature = methodSignature;
|
||||
}
|
||||
|
||||
public TagAttributeInfo toTagAttributeInfo() {
|
||||
if (fragment) {
|
||||
// JSP8.5.2: for a fragment type is fixed and rexprvalue is true
|
||||
type = "javax.servlet.jsp.tagext.JspFragment";
|
||||
requestTime = true;
|
||||
} else if (deferredValue) {
|
||||
type = "javax.el.ValueExpression";
|
||||
if (expectedTypeName == null) {
|
||||
expectedTypeName = "java.lang.Object";
|
||||
}
|
||||
} else if (deferredMethod) {
|
||||
type = "javax.el.MethodExpression";
|
||||
if (methodSignature == null) {
|
||||
methodSignature = "java.lang.Object method()";
|
||||
}
|
||||
}
|
||||
|
||||
// According to JSP spec, for static values (those determined at
|
||||
// translation time) the type is fixed at java.lang.String.
|
||||
if (!requestTime && type == null) {
|
||||
type = "java.lang.String";
|
||||
}
|
||||
|
||||
return new TagAttributeInfo(
|
||||
name,
|
||||
required,
|
||||
type,
|
||||
requestTime,
|
||||
fragment,
|
||||
description,
|
||||
deferredValue,
|
||||
deferredMethod,
|
||||
expectedTypeName,
|
||||
methodSignature);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ScriptVariableRule extends Rule {
|
||||
@Override
|
||||
public void begin(String namespace, String name, Attributes attributes) throws Exception {
|
||||
digester.push(new Variable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(String namespace, String name) throws Exception {
|
||||
Variable variable = (Variable) digester.pop();
|
||||
TagXml tag = (TagXml) digester.peek();
|
||||
tag.getVariables().add(variable.toTagVariableInfo());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Variable {
|
||||
private String nameGiven;
|
||||
private String nameFromAttribute;
|
||||
private String className = "java.lang.String";
|
||||
private boolean declare = true;
|
||||
private int scope = VariableInfo.NESTED;
|
||||
|
||||
public void setNameGiven(String nameGiven) {
|
||||
this.nameGiven = nameGiven;
|
||||
}
|
||||
|
||||
public void setNameFromAttribute(String nameFromAttribute) {
|
||||
this.nameFromAttribute = nameFromAttribute;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public void setDeclare(boolean declare) {
|
||||
this.declare = declare;
|
||||
}
|
||||
|
||||
public void setScope(String scopeName) {
|
||||
switch (scopeName) {
|
||||
case "NESTED":
|
||||
scope = VariableInfo.NESTED;
|
||||
break;
|
||||
case "AT_BEGIN":
|
||||
scope = VariableInfo.AT_BEGIN;
|
||||
break;
|
||||
case "AT_END":
|
||||
scope = VariableInfo.AT_END;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public TagVariableInfo toTagVariableInfo() {
|
||||
return new TagVariableInfo(nameGiven, nameFromAttribute, className, declare, scope);
|
||||
}
|
||||
}
|
||||
|
||||
private static class GenericBooleanRule extends Rule {
|
||||
private final Method setter;
|
||||
|
||||
private GenericBooleanRule(Class<?> type, String setterName) {
|
||||
try {
|
||||
this.setter = type.getMethod(setterName, Boolean.TYPE);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void body(String namespace, String name, String text) throws Exception {
|
||||
if(null != text)
|
||||
text = text.trim();
|
||||
boolean value = "true".equalsIgnoreCase(text) || "yes".equalsIgnoreCase(text);
|
||||
setter.invoke(digester.peek(), Boolean.valueOf(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
44
java/org/apache/tomcat/util/descriptor/tld/ValidatorXml.java
Normal file
44
java/org/apache/tomcat/util/descriptor/tld/ValidatorXml.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.tld;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Model of a Tag Library Validator from the XML descriptor.
|
||||
*/
|
||||
public class ValidatorXml {
|
||||
private String validatorClass;
|
||||
private final Map<String, String> initParams = new HashMap<>();
|
||||
|
||||
public String getValidatorClass() {
|
||||
return validatorClass;
|
||||
}
|
||||
|
||||
public void setValidatorClass(String validatorClass) {
|
||||
this.validatorClass = validatorClass;
|
||||
}
|
||||
|
||||
public void addInitParam(String name, String value) {
|
||||
initParams.put(name, value);
|
||||
}
|
||||
|
||||
public Map<String, String> getInitParams() {
|
||||
return initParams;
|
||||
}
|
||||
}
|
||||
21
java/org/apache/tomcat/util/descriptor/tld/package-info.java
Normal file
21
java/org/apache/tomcat/util/descriptor/tld/package-info.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package containing a Java model of the XML for a Tag Library Descriptor.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.tld;
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* Representation of a context initialization parameter that is configured
|
||||
* in the server configuration file, rather than the application deployment
|
||||
* descriptor. This is convenient for establishing default values (which
|
||||
* may be configured to allow application overrides or not) without having
|
||||
* to modify the application deployment descriptor itself.
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
*/
|
||||
public class ApplicationParameter implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* The description of this environment entry.
|
||||
*/
|
||||
private String description = null;
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The name of this application parameter.
|
||||
*/
|
||||
private String name = null;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does this application parameter allow overrides by the application
|
||||
* deployment descriptor?
|
||||
*/
|
||||
private boolean override = true;
|
||||
|
||||
public boolean getOverride() {
|
||||
return this.override;
|
||||
}
|
||||
|
||||
public void setOverride(boolean override) {
|
||||
this.override = override;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The value of this application parameter.
|
||||
*/
|
||||
private String value = null;
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder("ApplicationParameter[");
|
||||
sb.append("name=");
|
||||
sb.append(name);
|
||||
if (description != null) {
|
||||
sb.append(", description=");
|
||||
sb.append(description);
|
||||
}
|
||||
sb.append(", value=");
|
||||
sb.append(value);
|
||||
sb.append(", override=");
|
||||
sb.append(override);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
26
java/org/apache/tomcat/util/descriptor/web/Constants.java
Normal file
26
java/org/apache/tomcat/util/descriptor/web/Constants.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String PACKAGE_NAME =
|
||||
Constants.class.getPackage().getName();
|
||||
|
||||
public static final String WEB_XML_LOCATION = "/WEB-INF/web.xml";
|
||||
|
||||
}
|
||||
162
java/org/apache/tomcat/util/descriptor/web/ContextEjb.java
Normal file
162
java/org/apache/tomcat/util/descriptor/web/ContextEjb.java
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @author Peter Rossbach (pero@apache.org)
|
||||
*/
|
||||
public class ContextEjb extends ResourceBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The name of the EJB home implementation class.
|
||||
*/
|
||||
private String home = null;
|
||||
|
||||
public String getHome() {
|
||||
return this.home;
|
||||
}
|
||||
|
||||
public void setHome(String home) {
|
||||
this.home = home;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The link to a J2EE EJB definition.
|
||||
*/
|
||||
private String link = null;
|
||||
|
||||
public String getLink() {
|
||||
return this.link;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the EJB remote implementation class.
|
||||
*/
|
||||
private String remote = null;
|
||||
|
||||
public String getRemote() {
|
||||
return this.remote;
|
||||
}
|
||||
|
||||
public void setRemote(String remote) {
|
||||
this.remote = remote;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder("ContextEjb[");
|
||||
sb.append("name=");
|
||||
sb.append(getName());
|
||||
if (getDescription() != null) {
|
||||
sb.append(", description=");
|
||||
sb.append(getDescription());
|
||||
}
|
||||
if (getType() != null) {
|
||||
sb.append(", type=");
|
||||
sb.append(getType());
|
||||
}
|
||||
if (home != null) {
|
||||
sb.append(", home=");
|
||||
sb.append(home);
|
||||
}
|
||||
if (remote != null) {
|
||||
sb.append(", remote=");
|
||||
sb.append(remote);
|
||||
}
|
||||
if (link != null) {
|
||||
sb.append(", link=");
|
||||
sb.append(link);
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((home == null) ? 0 : home.hashCode());
|
||||
result = prime * result + ((link == null) ? 0 : link.hashCode());
|
||||
result = prime * result + ((remote == null) ? 0 : remote.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ContextEjb other = (ContextEjb) obj;
|
||||
if (home == null) {
|
||||
if (other.home != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!home.equals(other.home)) {
|
||||
return false;
|
||||
}
|
||||
if (link == null) {
|
||||
if (other.link != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!link.equals(other.link)) {
|
||||
return false;
|
||||
}
|
||||
if (remote == null) {
|
||||
if (other.remote != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!remote.equals(other.remote)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Representation of an application environment entry, as represented in
|
||||
* an <code><env-entry></code> element in the deployment descriptor.
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
*/
|
||||
public class ContextEnvironment extends ResourceBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* Does this environment entry allow overrides by the application
|
||||
* deployment descriptor?
|
||||
*/
|
||||
private boolean override = true;
|
||||
|
||||
public boolean getOverride() {
|
||||
return this.override;
|
||||
}
|
||||
|
||||
public void setOverride(boolean override) {
|
||||
this.override = override;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The value of this environment entry.
|
||||
*/
|
||||
private String value = null;
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder("ContextEnvironment[");
|
||||
sb.append("name=");
|
||||
sb.append(getName());
|
||||
if (getDescription() != null) {
|
||||
sb.append(", description=");
|
||||
sb.append(getDescription());
|
||||
}
|
||||
if (getType() != null) {
|
||||
sb.append(", type=");
|
||||
sb.append(getType());
|
||||
}
|
||||
if (value != null) {
|
||||
sb.append(", value=");
|
||||
sb.append(value);
|
||||
}
|
||||
sb.append(", override=");
|
||||
sb.append(override);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + (override ? 1231 : 1237);
|
||||
result = prime * result + ((value == null) ? 0 : value.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ContextEnvironment other = (ContextEnvironment) obj;
|
||||
if (override != other.override) {
|
||||
return false;
|
||||
}
|
||||
if (value == null) {
|
||||
if (other.value != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!value.equals(other.value)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
212
java/org/apache/tomcat/util/descriptor/web/ContextHandler.java
Normal file
212
java/org/apache/tomcat/util/descriptor/web/ContextHandler.java
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
/**
|
||||
* Representation of a handler reference for a web service, as
|
||||
* represented in a <code><handler></code> element in the
|
||||
* deployment descriptor.
|
||||
*
|
||||
* @author Fabien Carrion
|
||||
*/
|
||||
public class ContextHandler extends ResourceBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* The Handler reference class.
|
||||
*/
|
||||
private String handlerclass = null;
|
||||
|
||||
public String getHandlerclass() {
|
||||
return this.handlerclass;
|
||||
}
|
||||
|
||||
public void setHandlerclass(String handlerclass) {
|
||||
this.handlerclass = handlerclass;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of QName specifying the SOAP Headers the handler will work on.
|
||||
* -namespace and localpart values must be found inside the WSDL.
|
||||
*
|
||||
* A service-qname is composed by a namespaceURI and a localpart.
|
||||
*
|
||||
* soapHeader[0] : namespaceURI
|
||||
* soapHeader[1] : localpart
|
||||
*/
|
||||
private final HashMap<String, String> soapHeaders = new HashMap<>();
|
||||
|
||||
public Iterator<String> getLocalparts() {
|
||||
return soapHeaders.keySet().iterator();
|
||||
}
|
||||
|
||||
public String getNamespaceuri(String localpart) {
|
||||
return soapHeaders.get(localpart);
|
||||
}
|
||||
|
||||
public void addSoapHeaders(String localpart, String namespaceuri) {
|
||||
soapHeaders.put(localpart, namespaceuri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a configured property.
|
||||
* @param name The property name
|
||||
* @param value The property value
|
||||
*/
|
||||
public void setProperty(String name, String value) {
|
||||
this.setProperty(name, (Object) value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The soapRole.
|
||||
*/
|
||||
private final ArrayList<String> soapRoles = new ArrayList<>();
|
||||
|
||||
public String getSoapRole(int i) {
|
||||
return this.soapRoles.get(i);
|
||||
}
|
||||
|
||||
public int getSoapRolesSize() {
|
||||
return this.soapRoles.size();
|
||||
}
|
||||
|
||||
public void addSoapRole(String soapRole) {
|
||||
this.soapRoles.add(soapRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* The portName.
|
||||
*/
|
||||
private final ArrayList<String> portNames = new ArrayList<>();
|
||||
|
||||
public String getPortName(int i) {
|
||||
return this.portNames.get(i);
|
||||
}
|
||||
|
||||
public int getPortNamesSize() {
|
||||
return this.portNames.size();
|
||||
}
|
||||
|
||||
public void addPortName(String portName) {
|
||||
this.portNames.add(portName);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder("ContextHandler[");
|
||||
sb.append("name=");
|
||||
sb.append(getName());
|
||||
if (handlerclass != null) {
|
||||
sb.append(", class=");
|
||||
sb.append(handlerclass);
|
||||
}
|
||||
if (this.soapHeaders != null) {
|
||||
sb.append(", soap-headers=");
|
||||
sb.append(this.soapHeaders);
|
||||
}
|
||||
if (this.getSoapRolesSize() > 0) {
|
||||
sb.append(", soap-roles=");
|
||||
sb.append(soapRoles);
|
||||
}
|
||||
if (this.getPortNamesSize() > 0) {
|
||||
sb.append(", port-name=");
|
||||
sb.append(portNames);
|
||||
}
|
||||
if (this.listProperties() != null) {
|
||||
sb.append(", init-param=");
|
||||
sb.append(this.listProperties());
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result +
|
||||
((handlerclass == null) ? 0 : handlerclass.hashCode());
|
||||
result = prime * result +
|
||||
((portNames == null) ? 0 : portNames.hashCode());
|
||||
result = prime * result +
|
||||
((soapHeaders == null) ? 0 : soapHeaders.hashCode());
|
||||
result = prime * result +
|
||||
((soapRoles == null) ? 0 : soapRoles.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ContextHandler other = (ContextHandler) obj;
|
||||
if (handlerclass == null) {
|
||||
if (other.handlerclass != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!handlerclass.equals(other.handlerclass)) {
|
||||
return false;
|
||||
}
|
||||
if (portNames == null) {
|
||||
if (other.portNames != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!portNames.equals(other.portNames)) {
|
||||
return false;
|
||||
}
|
||||
if (soapHeaders == null) {
|
||||
if (other.soapHeaders != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!soapHeaders.equals(other.soapHeaders)) {
|
||||
return false;
|
||||
}
|
||||
if (soapRoles == null) {
|
||||
if (other.soapRoles != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!soapRoles.equals(other.soapRoles)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
160
java/org/apache/tomcat/util/descriptor/web/ContextLocalEjb.java
Normal file
160
java/org/apache/tomcat/util/descriptor/web/ContextLocalEjb.java
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Representation of a local EJB resource reference for a web application, as
|
||||
* represented in a <code><ejb-local-ref></code> element in the
|
||||
* deployment descriptor.
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
* @author Peter Rossbach (pero@apache.org)
|
||||
*/
|
||||
public class ContextLocalEjb extends ResourceBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
/**
|
||||
* The name of the EJB home implementation class.
|
||||
*/
|
||||
private String home = null;
|
||||
|
||||
public String getHome() {
|
||||
return this.home;
|
||||
}
|
||||
|
||||
public void setHome(String home) {
|
||||
this.home = home;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The link to a J2EE EJB definition.
|
||||
*/
|
||||
private String link = null;
|
||||
|
||||
public String getLink() {
|
||||
return this.link;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The name of the EJB local implementation class.
|
||||
*/
|
||||
private String local = null;
|
||||
|
||||
public String getLocal() {
|
||||
return this.local;
|
||||
}
|
||||
|
||||
public void setLocal(String local) {
|
||||
this.local = local;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder("ContextLocalEjb[");
|
||||
sb.append("name=");
|
||||
sb.append(getName());
|
||||
if (getDescription() != null) {
|
||||
sb.append(", description=");
|
||||
sb.append(getDescription());
|
||||
}
|
||||
if (getType() != null) {
|
||||
sb.append(", type=");
|
||||
sb.append(getType());
|
||||
}
|
||||
if (home != null) {
|
||||
sb.append(", home=");
|
||||
sb.append(home);
|
||||
}
|
||||
if (link != null) {
|
||||
sb.append(", link=");
|
||||
sb.append(link);
|
||||
}
|
||||
if (local != null) {
|
||||
sb.append(", local=");
|
||||
sb.append(local);
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((home == null) ? 0 : home.hashCode());
|
||||
result = prime * result + ((link == null) ? 0 : link.hashCode());
|
||||
result = prime * result + ((local == null) ? 0 : local.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ContextLocalEjb other = (ContextLocalEjb) obj;
|
||||
if (home == null) {
|
||||
if (other.home != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!home.equals(other.home)) {
|
||||
return false;
|
||||
}
|
||||
if (link == null) {
|
||||
if (other.link != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!link.equals(other.link)) {
|
||||
return false;
|
||||
}
|
||||
if (local == null) {
|
||||
if (other.local != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!local.equals(other.local)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
188
java/org/apache/tomcat/util/descriptor/web/ContextResource.java
Normal file
188
java/org/apache/tomcat/util/descriptor/web/ContextResource.java
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @author Peter Rossbach (pero@apache.org)
|
||||
*/
|
||||
public class ContextResource extends ResourceBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* The authorization requirement for this resource
|
||||
* (<code>Application</code> or <code>Container</code>).
|
||||
*/
|
||||
private String auth = null;
|
||||
|
||||
public String getAuth() {
|
||||
return this.auth;
|
||||
}
|
||||
|
||||
public void setAuth(String auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* The sharing scope of this resource factory (<code>Shareable</code>
|
||||
* or <code>Unshareable</code>).
|
||||
*/
|
||||
private String scope = "Shareable";
|
||||
|
||||
public String getScope() {
|
||||
return this.scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is this resource known to be a singleton resource. The default value is
|
||||
* true since this is what users expect although the JavaEE spec implies
|
||||
* that the default should be false.
|
||||
*/
|
||||
private boolean singleton = true;
|
||||
|
||||
public boolean getSingleton() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
public void setSingleton(boolean singleton) {
|
||||
this.singleton = singleton;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The name of the zero argument method to be called when the resource is
|
||||
* no longer required to clean-up resources. This method must only speed up
|
||||
* the clean-up of resources that would otherwise happen via garbage
|
||||
* collection.
|
||||
*/
|
||||
private String closeMethod = null;
|
||||
private boolean closeMethodConfigured = false;
|
||||
|
||||
public String getCloseMethod() {
|
||||
return closeMethod;
|
||||
}
|
||||
|
||||
public void setCloseMethod(String closeMethod) {
|
||||
closeMethodConfigured = true;
|
||||
this.closeMethod = closeMethod;
|
||||
}
|
||||
|
||||
public boolean getCloseMethodConfigured() {
|
||||
return closeMethodConfigured;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder("ContextResource[");
|
||||
sb.append("name=");
|
||||
sb.append(getName());
|
||||
if (getDescription() != null) {
|
||||
sb.append(", description=");
|
||||
sb.append(getDescription());
|
||||
}
|
||||
if (getType() != null) {
|
||||
sb.append(", type=");
|
||||
sb.append(getType());
|
||||
}
|
||||
if (auth != null) {
|
||||
sb.append(", auth=");
|
||||
sb.append(auth);
|
||||
}
|
||||
if (scope != null) {
|
||||
sb.append(", scope=");
|
||||
sb.append(scope);
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((auth == null) ? 0 : auth.hashCode());
|
||||
result = prime * result +
|
||||
((closeMethod == null) ? 0 : closeMethod.hashCode());
|
||||
result = prime * result + ((scope == null) ? 0 : scope.hashCode());
|
||||
result = prime * result + (singleton ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ContextResource other = (ContextResource) obj;
|
||||
if (auth == null) {
|
||||
if (other.auth != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!auth.equals(other.auth)) {
|
||||
return false;
|
||||
}
|
||||
if (closeMethod == null) {
|
||||
if (other.closeMethod != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!closeMethod.equals(other.closeMethod)) {
|
||||
return false;
|
||||
}
|
||||
if (scope == null) {
|
||||
if (other.scope != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!scope.equals(other.scope)) {
|
||||
return false;
|
||||
}
|
||||
if (singleton != other.singleton) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Representation of an application resource reference, as represented in
|
||||
* an <code><res-env-refy></code> element in the deployment descriptor.
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
* @author Peter Rossbach (pero@apache.org)
|
||||
*/
|
||||
public class ContextResourceEnvRef extends ResourceBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
/**
|
||||
* Does this environment entry allow overrides by the application
|
||||
* deployment descriptor?
|
||||
*/
|
||||
private boolean override = true;
|
||||
|
||||
public boolean getOverride() {
|
||||
return this.override;
|
||||
}
|
||||
|
||||
public void setOverride(boolean override) {
|
||||
this.override = override;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder("ContextResourceEnvRef[");
|
||||
sb.append("name=");
|
||||
sb.append(getName());
|
||||
if (getType() != null) {
|
||||
sb.append(", type=");
|
||||
sb.append(getType());
|
||||
}
|
||||
sb.append(", override=");
|
||||
sb.append(override);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + (override ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ContextResourceEnvRef other = (ContextResourceEnvRef) obj;
|
||||
if (override != other.override) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Representation of a resource link for a web application, as
|
||||
* represented in a <code><ResourceLink></code> element in the
|
||||
* server configuration file.
|
||||
*
|
||||
* @author Remy Maucherat
|
||||
* @author Peter Rossbach (Peter Rossbach (pero@apache.org))
|
||||
*/
|
||||
public class ContextResourceLink extends ResourceBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
/**
|
||||
* The global name of this resource.
|
||||
*/
|
||||
private String global = null;
|
||||
/**
|
||||
* The factory to be used for creating the object
|
||||
*/
|
||||
private String factory = null;
|
||||
|
||||
public String getGlobal() {
|
||||
return this.global;
|
||||
}
|
||||
|
||||
public void setGlobal(String global) {
|
||||
this.global = global;
|
||||
}
|
||||
|
||||
public String getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
public void setFactory(String factory) {
|
||||
this.factory = factory;
|
||||
}
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder("ContextResourceLink[");
|
||||
sb.append("name=");
|
||||
sb.append(getName());
|
||||
if (getType() != null) {
|
||||
sb.append(", type=");
|
||||
sb.append(getType());
|
||||
}
|
||||
if (getGlobal() != null) {
|
||||
sb.append(", global=");
|
||||
sb.append(getGlobal());
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((factory == null) ? 0 : factory.hashCode());
|
||||
result = prime * result + ((global == null) ? 0 : global.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ContextResourceLink other = (ContextResourceLink) obj;
|
||||
if (factory == null) {
|
||||
if (other.factory != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!factory.equals(other.factory)) {
|
||||
return false;
|
||||
}
|
||||
if (global == null) {
|
||||
if (other.global != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!global.equals(other.global)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
355
java/org/apache/tomcat/util/descriptor/web/ContextService.java
Normal file
355
java/org/apache/tomcat/util/descriptor/web/ContextService.java
Normal file
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
/**
|
||||
* Representation of a web service reference for a web application, as
|
||||
* represented in a <code><service-ref></code> element in the
|
||||
* deployment descriptor.
|
||||
*
|
||||
* @author Fabien Carrion
|
||||
*/
|
||||
public class ContextService extends ResourceBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* The WebService reference name.
|
||||
*/
|
||||
private String displayname = null;
|
||||
|
||||
public String getDisplayname() {
|
||||
return this.displayname;
|
||||
}
|
||||
|
||||
public void setDisplayname(String displayname) {
|
||||
this.displayname = displayname;
|
||||
}
|
||||
|
||||
/**
|
||||
* A large icon for this WebService.
|
||||
*/
|
||||
private String largeIcon = null;
|
||||
|
||||
public String getLargeIcon() {
|
||||
return this.largeIcon;
|
||||
}
|
||||
|
||||
public void setLargeIcon(String largeIcon) {
|
||||
this.largeIcon = largeIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* A small icon for this WebService.
|
||||
*/
|
||||
private String smallIcon = null;
|
||||
|
||||
public String getSmallIcon() {
|
||||
return this.smallIcon;
|
||||
}
|
||||
|
||||
public void setSmallIcon(String smallIcon) {
|
||||
this.smallIcon = smallIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* The fully qualified class name of the JAX-WS Service interface that the
|
||||
* client depends on.
|
||||
*/
|
||||
private String serviceInterface = null;
|
||||
|
||||
public String getInterface() {
|
||||
return serviceInterface;
|
||||
}
|
||||
|
||||
public void setInterface(String serviceInterface) {
|
||||
this.serviceInterface = serviceInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the location (relative to the root of
|
||||
* the module) of the web service WSDL description.
|
||||
*/
|
||||
private String wsdlfile = null;
|
||||
|
||||
public String getWsdlfile() {
|
||||
return this.wsdlfile;
|
||||
}
|
||||
|
||||
public void setWsdlfile(String wsdlfile) {
|
||||
this.wsdlfile = wsdlfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* A file specifying the correlation of the WSDL definition
|
||||
* to the interfaces (Service Endpoint Interface, Service Interface).
|
||||
*/
|
||||
private String jaxrpcmappingfile = null;
|
||||
|
||||
public String getJaxrpcmappingfile() {
|
||||
return this.jaxrpcmappingfile;
|
||||
}
|
||||
|
||||
public void setJaxrpcmappingfile(String jaxrpcmappingfile) {
|
||||
this.jaxrpcmappingfile = jaxrpcmappingfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares the specific WSDL service element that is being referred to.
|
||||
* It is not specified if no wsdl-file is declared or if WSDL contains only
|
||||
* 1 service element.
|
||||
*
|
||||
* A service-qname is composed by a namespaceURI and a localpart.
|
||||
* It must be defined if more than 1 service is declared in the WSDL.
|
||||
*
|
||||
* serviceqname[0] : namespaceURI
|
||||
* serviceqname[1] : localpart
|
||||
*/
|
||||
private String[] serviceqname = new String[2];
|
||||
|
||||
public String[] getServiceqname() {
|
||||
return this.serviceqname;
|
||||
}
|
||||
|
||||
public String getServiceqname(int i) {
|
||||
return this.serviceqname[i];
|
||||
}
|
||||
|
||||
public String getServiceqnameNamespaceURI() {
|
||||
return this.serviceqname[0];
|
||||
}
|
||||
|
||||
public String getServiceqnameLocalpart() {
|
||||
return this.serviceqname[1];
|
||||
}
|
||||
|
||||
public void setServiceqname(String[] serviceqname) {
|
||||
this.serviceqname = serviceqname;
|
||||
}
|
||||
|
||||
public void setServiceqname(String serviceqname, int i) {
|
||||
this.serviceqname[i] = serviceqname;
|
||||
}
|
||||
|
||||
public void setServiceqnameNamespaceURI(String namespaceuri) {
|
||||
this.serviceqname[0] = namespaceuri;
|
||||
}
|
||||
|
||||
public void setServiceqnameLocalpart(String localpart) {
|
||||
this.serviceqname[1] = localpart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares a client dependency on the container to resolving a Service Endpoint Interface
|
||||
* to a WSDL port. It optionally associates the Service Endpoint Interface with a
|
||||
* particular port-component.
|
||||
* @return the endpoint names
|
||||
*/
|
||||
public Iterator<String> getServiceendpoints() {
|
||||
return this.listProperties();
|
||||
}
|
||||
|
||||
public String getPortlink(String serviceendpoint) {
|
||||
return (String) this.getProperty(serviceendpoint);
|
||||
}
|
||||
|
||||
public void addPortcomponent(String serviceendpoint, String portlink) {
|
||||
if (portlink == null)
|
||||
portlink = "";
|
||||
this.setProperty(serviceendpoint, portlink);
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of Handlers to use for this service-ref.
|
||||
*
|
||||
* The instantiation of the handler have to be done.
|
||||
*/
|
||||
private final HashMap<String, ContextHandler> handlers = new HashMap<>();
|
||||
|
||||
public Iterator<String> getHandlers() {
|
||||
return handlers.keySet().iterator();
|
||||
}
|
||||
|
||||
public ContextHandler getHandler(String handlername) {
|
||||
return handlers.get(handlername);
|
||||
}
|
||||
|
||||
public void addHandler(ContextHandler handler) {
|
||||
handlers.put(handler.getName(), handler);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder("ContextService[");
|
||||
sb.append("name=");
|
||||
sb.append(getName());
|
||||
if (getDescription() != null) {
|
||||
sb.append(", description=");
|
||||
sb.append(getDescription());
|
||||
}
|
||||
if (getType() != null) {
|
||||
sb.append(", type=");
|
||||
sb.append(getType());
|
||||
}
|
||||
if (displayname != null) {
|
||||
sb.append(", displayname=");
|
||||
sb.append(displayname);
|
||||
}
|
||||
if (largeIcon != null) {
|
||||
sb.append(", largeIcon=");
|
||||
sb.append(largeIcon);
|
||||
}
|
||||
if (smallIcon != null) {
|
||||
sb.append(", smallIcon=");
|
||||
sb.append(smallIcon);
|
||||
}
|
||||
if (wsdlfile != null) {
|
||||
sb.append(", wsdl-file=");
|
||||
sb.append(wsdlfile);
|
||||
}
|
||||
if (jaxrpcmappingfile != null) {
|
||||
sb.append(", jaxrpc-mapping-file=");
|
||||
sb.append(jaxrpcmappingfile);
|
||||
}
|
||||
if (serviceqname[0] != null) {
|
||||
sb.append(", service-qname/namespaceURI=");
|
||||
sb.append(serviceqname[0]);
|
||||
}
|
||||
if (serviceqname[1] != null) {
|
||||
sb.append(", service-qname/localpart=");
|
||||
sb.append(serviceqname[1]);
|
||||
}
|
||||
if (this.getServiceendpoints() != null) {
|
||||
sb.append(", port-component/service-endpoint-interface=");
|
||||
sb.append(this.getServiceendpoints());
|
||||
}
|
||||
if (handlers != null) {
|
||||
sb.append(", handler=");
|
||||
sb.append(handlers);
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result +
|
||||
((displayname == null) ? 0 : displayname.hashCode());
|
||||
result = prime * result +
|
||||
((handlers == null) ? 0 : handlers.hashCode());
|
||||
result = prime *
|
||||
result +
|
||||
((jaxrpcmappingfile == null) ? 0 : jaxrpcmappingfile.hashCode());
|
||||
result = prime * result +
|
||||
((largeIcon == null) ? 0 : largeIcon.hashCode());
|
||||
result = prime * result +
|
||||
((serviceInterface == null) ? 0 : serviceInterface.hashCode());
|
||||
result = prime * result + Arrays.hashCode(serviceqname);
|
||||
result = prime * result +
|
||||
((smallIcon == null) ? 0 : smallIcon.hashCode());
|
||||
result = prime * result +
|
||||
((wsdlfile == null) ? 0 : wsdlfile.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ContextService other = (ContextService) obj;
|
||||
if (displayname == null) {
|
||||
if (other.displayname != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!displayname.equals(other.displayname)) {
|
||||
return false;
|
||||
}
|
||||
if (handlers == null) {
|
||||
if (other.handlers != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!handlers.equals(other.handlers)) {
|
||||
return false;
|
||||
}
|
||||
if (jaxrpcmappingfile == null) {
|
||||
if (other.jaxrpcmappingfile != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!jaxrpcmappingfile.equals(other.jaxrpcmappingfile)) {
|
||||
return false;
|
||||
}
|
||||
if (largeIcon == null) {
|
||||
if (other.largeIcon != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!largeIcon.equals(other.largeIcon)) {
|
||||
return false;
|
||||
}
|
||||
if (serviceInterface == null) {
|
||||
if (other.serviceInterface != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!serviceInterface.equals(other.serviceInterface)) {
|
||||
return false;
|
||||
}
|
||||
if (!Arrays.equals(serviceqname, other.serviceqname)) {
|
||||
return false;
|
||||
}
|
||||
if (smallIcon == null) {
|
||||
if (other.smallIcon != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!smallIcon.equals(other.smallIcon)) {
|
||||
return false;
|
||||
}
|
||||
if (wsdlfile == null) {
|
||||
if (other.wsdlfile != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!wsdlfile.equals(other.wsdlfile)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
/**
|
||||
* Representation of an application resource reference, as represented in
|
||||
* an <code><res-env-refy></code> element in the deployment descriptor.
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
*/
|
||||
public class ContextTransaction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* Holder for our configured properties.
|
||||
*/
|
||||
private final HashMap<String, Object> properties = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @param name The property name
|
||||
* @return a configured property.
|
||||
*/
|
||||
public Object getProperty(String name) {
|
||||
return properties.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a configured property.
|
||||
* @param name The property name
|
||||
* @param value The property value
|
||||
*/
|
||||
public void setProperty(String name, Object value) {
|
||||
properties.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a configured property.
|
||||
* @param name The property name
|
||||
*/
|
||||
public void removeProperty(String name) {
|
||||
properties.remove(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* List properties.
|
||||
* @return the property names iterator
|
||||
*/
|
||||
public Iterator<String> listProperties() {
|
||||
return properties.keySet().iterator();
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("Transaction[");
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
163
java/org/apache/tomcat/util/descriptor/web/ErrorPage.java
Normal file
163
java/org/apache/tomcat/util/descriptor/web/ErrorPage.java
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.tomcat.util.buf.UDecoder;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public class ErrorPage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ----------------------------------------------------- Instance Variables
|
||||
|
||||
|
||||
/**
|
||||
* The error (status) code for which this error page is active. Note that
|
||||
* status code 0 is used for the default error page.
|
||||
*/
|
||||
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 (NumberFormatException nfe) {
|
||||
throw new IllegalArgumentException(nfe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
|
||||
// if ((location == null) || !location.startsWith("/"))
|
||||
// throw new IllegalArgumentException
|
||||
// ("Error Page Location must start with a '/'");
|
||||
this.location = UDecoder.URLDecode(location);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Render a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("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();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (exceptionType == null) {
|
||||
return Integer.toString(errorCode);
|
||||
} else {
|
||||
return exceptionType;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
205
java/org/apache/tomcat/util/descriptor/web/FilterDef.java
Normal file
205
java/org/apache/tomcat/util/descriptor/web/FilterDef.java
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
|
||||
|
||||
/**
|
||||
* Representation of a filter definition for a web application, as represented
|
||||
* in a <code><filter></code> element in the deployment descriptor.
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
*/
|
||||
public class FilterDef implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final StringManager sm =
|
||||
StringManager.getManager(Constants.PACKAGE_NAME);
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* The description of this filter.
|
||||
*/
|
||||
private String description = null;
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The display name of this filter.
|
||||
*/
|
||||
private String displayName = null;
|
||||
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The filter instance associated with this definition
|
||||
*/
|
||||
private transient Filter filter = null;
|
||||
|
||||
public Filter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public void setFilter(Filter filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The fully qualified name of the Java class that implements this filter.
|
||||
*/
|
||||
private String filterClass = null;
|
||||
|
||||
public String getFilterClass() {
|
||||
return this.filterClass;
|
||||
}
|
||||
|
||||
public void setFilterClass(String filterClass) {
|
||||
this.filterClass = filterClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The name of this filter, which must be unique among the filters
|
||||
* defined for a particular web application.
|
||||
*/
|
||||
private String filterName = null;
|
||||
|
||||
public String getFilterName() {
|
||||
return this.filterName;
|
||||
}
|
||||
|
||||
public void setFilterName(String filterName) {
|
||||
if (filterName == null || filterName.equals("")) {
|
||||
throw new IllegalArgumentException(
|
||||
sm.getString("filterDef.invalidFilterName", filterName));
|
||||
}
|
||||
this.filterName = filterName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The large icon associated with this filter.
|
||||
*/
|
||||
private String largeIcon = null;
|
||||
|
||||
public String getLargeIcon() {
|
||||
return this.largeIcon;
|
||||
}
|
||||
|
||||
public void setLargeIcon(String largeIcon) {
|
||||
this.largeIcon = largeIcon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The set of initialization parameters for this filter, keyed by
|
||||
* parameter name.
|
||||
*/
|
||||
private final Map<String, String> parameters = new HashMap<>();
|
||||
|
||||
public Map<String, String> getParameterMap() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The small icon associated with this filter.
|
||||
*/
|
||||
private String smallIcon = null;
|
||||
|
||||
public String getSmallIcon() {
|
||||
return this.smallIcon;
|
||||
}
|
||||
|
||||
public void setSmallIcon(String smallIcon) {
|
||||
this.smallIcon = smallIcon;
|
||||
}
|
||||
|
||||
private String asyncSupported = null;
|
||||
|
||||
public String getAsyncSupported() {
|
||||
return asyncSupported;
|
||||
}
|
||||
|
||||
public void setAsyncSupported(String asyncSupported) {
|
||||
this.asyncSupported = asyncSupported;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Add an initialization parameter to the set of parameters associated
|
||||
* with this filter.
|
||||
*
|
||||
* @param name The initialization parameter name
|
||||
* @param value The initialization parameter value
|
||||
*/
|
||||
public void addInitParameter(String name, String value) {
|
||||
|
||||
if (parameters.containsKey(name)) {
|
||||
// The spec does not define this but the TCK expects the first
|
||||
// definition to take precedence
|
||||
return;
|
||||
}
|
||||
parameters.put(name, value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("FilterDef[");
|
||||
sb.append("filterName=");
|
||||
sb.append(this.filterName);
|
||||
sb.append(", filterClass=");
|
||||
sb.append(this.filterClass);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
222
java/org/apache/tomcat/util/descriptor/web/FilterMap.java
Normal file
222
java/org/apache/tomcat/util/descriptor/web/FilterMap.java
Normal file
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
|
||||
import org.apache.tomcat.util.buf.UDecoder;
|
||||
|
||||
/**
|
||||
* Representation of a filter mapping for a web application, as represented
|
||||
* in a <code><filter-mapping></code> element in the deployment
|
||||
* descriptor. Each filter mapping must contain a filter name plus either
|
||||
* a URL pattern or a servlet name.
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
*/
|
||||
public class FilterMap extends XmlEncodingBase implements Serializable {
|
||||
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The name of this filter to be executed when this mapping matches
|
||||
* a particular request.
|
||||
*/
|
||||
|
||||
public static final int ERROR = 1;
|
||||
public static final int FORWARD = 2;
|
||||
public static final int INCLUDE = 4;
|
||||
public static final int REQUEST = 8;
|
||||
public static final int ASYNC = 16;
|
||||
|
||||
// represents nothing having been set. This will be seen
|
||||
// as equal to a REQUEST
|
||||
private static final int NOT_SET = 0;
|
||||
|
||||
private int dispatcherMapping = NOT_SET;
|
||||
|
||||
private String filterName = null;
|
||||
|
||||
public String getFilterName() {
|
||||
return this.filterName;
|
||||
}
|
||||
|
||||
public void setFilterName(String filterName) {
|
||||
this.filterName = filterName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The servlet name this mapping matches.
|
||||
*/
|
||||
private String[] servletNames = new String[0];
|
||||
|
||||
public String[] getServletNames() {
|
||||
if (matchAllServletNames) {
|
||||
return new String[] {};
|
||||
} else {
|
||||
return this.servletNames;
|
||||
}
|
||||
}
|
||||
|
||||
public void addServletName(String servletName) {
|
||||
if ("*".equals(servletName)) {
|
||||
this.matchAllServletNames = true;
|
||||
} else {
|
||||
String[] results = new String[servletNames.length + 1];
|
||||
System.arraycopy(servletNames, 0, results, 0, servletNames.length);
|
||||
results[servletNames.length] = servletName;
|
||||
servletNames = results;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The flag that indicates this mapping will match all url-patterns
|
||||
*/
|
||||
private boolean matchAllUrlPatterns = false;
|
||||
|
||||
public boolean getMatchAllUrlPatterns() {
|
||||
return matchAllUrlPatterns;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The flag that indicates this mapping will match all servlet-names
|
||||
*/
|
||||
private boolean matchAllServletNames = false;
|
||||
|
||||
public boolean getMatchAllServletNames() {
|
||||
return matchAllServletNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The URL pattern this mapping matches.
|
||||
*/
|
||||
private String[] urlPatterns = new String[0];
|
||||
|
||||
public String[] getURLPatterns() {
|
||||
if (matchAllUrlPatterns) {
|
||||
return new String[] {};
|
||||
} else {
|
||||
return this.urlPatterns;
|
||||
}
|
||||
}
|
||||
|
||||
public void addURLPattern(String urlPattern) {
|
||||
addURLPatternDecoded(UDecoder.URLDecode(urlPattern, getCharset()));
|
||||
}
|
||||
public void addURLPatternDecoded(String urlPattern) {
|
||||
if ("*".equals(urlPattern)) {
|
||||
this.matchAllUrlPatterns = true;
|
||||
} else {
|
||||
String[] results = new String[urlPatterns.length + 1];
|
||||
System.arraycopy(urlPatterns, 0, results, 0, urlPatterns.length);
|
||||
results[urlPatterns.length] = UDecoder.URLDecode(urlPattern);
|
||||
urlPatterns = results;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to set the current state of the FilterMap
|
||||
* representing the state of when filters should be applied.
|
||||
* @param dispatcherString the dispatcher type which should
|
||||
* match this filter
|
||||
*/
|
||||
public void setDispatcher(String dispatcherString) {
|
||||
String dispatcher = dispatcherString.toUpperCase(Locale.ENGLISH);
|
||||
|
||||
if (dispatcher.equals(DispatcherType.FORWARD.name())) {
|
||||
// apply FORWARD to the global dispatcherMapping.
|
||||
dispatcherMapping |= FORWARD;
|
||||
} else if (dispatcher.equals(DispatcherType.INCLUDE.name())) {
|
||||
// apply INCLUDE to the global dispatcherMapping.
|
||||
dispatcherMapping |= INCLUDE;
|
||||
} else if (dispatcher.equals(DispatcherType.REQUEST.name())) {
|
||||
// apply REQUEST to the global dispatcherMapping.
|
||||
dispatcherMapping |= REQUEST;
|
||||
} else if (dispatcher.equals(DispatcherType.ERROR.name())) {
|
||||
// apply ERROR to the global dispatcherMapping.
|
||||
dispatcherMapping |= ERROR;
|
||||
} else if (dispatcher.equals(DispatcherType.ASYNC.name())) {
|
||||
// apply ERROR to the global dispatcherMapping.
|
||||
dispatcherMapping |= ASYNC;
|
||||
}
|
||||
}
|
||||
|
||||
public int getDispatcherMapping() {
|
||||
// per the SRV.6.2.5 absence of any dispatcher elements is
|
||||
// equivalent to a REQUEST value
|
||||
if (dispatcherMapping == NOT_SET) return REQUEST;
|
||||
|
||||
return dispatcherMapping;
|
||||
}
|
||||
|
||||
public String[] getDispatcherNames() {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if ((dispatcherMapping & FORWARD) != 0) {
|
||||
result.add(DispatcherType.FORWARD.name());
|
||||
}
|
||||
if ((dispatcherMapping & INCLUDE) != 0) {
|
||||
result.add(DispatcherType.INCLUDE.name());
|
||||
}
|
||||
if ((dispatcherMapping & REQUEST) != 0) {
|
||||
result.add(DispatcherType.REQUEST.name());
|
||||
}
|
||||
if ((dispatcherMapping & ERROR) != 0) {
|
||||
result.add(DispatcherType.ERROR.name());
|
||||
}
|
||||
if ((dispatcherMapping & ASYNC) != 0) {
|
||||
result.add(DispatcherType.ASYNC.name());
|
||||
}
|
||||
return result.toArray(new String[result.size()]);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Render a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("FilterMap[");
|
||||
sb.append("filterName=");
|
||||
sb.append(this.filterName);
|
||||
for (int i = 0; i < servletNames.length; i++) {
|
||||
sb.append(", servletName=");
|
||||
sb.append(servletNames[i]);
|
||||
}
|
||||
for (int i = 0; i < urlPatterns.length; i++) {
|
||||
sb.append(", urlPattern=");
|
||||
sb.append(urlPatterns[i]);
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.tomcat.Jar;
|
||||
import org.apache.tomcat.JarScannerCallback;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
/**
|
||||
* Callback handling a web-fragment.xml descriptor.
|
||||
*/
|
||||
public class FragmentJarScannerCallback implements JarScannerCallback {
|
||||
|
||||
private static final String FRAGMENT_LOCATION =
|
||||
"META-INF/web-fragment.xml";
|
||||
private final WebXmlParser webXmlParser;
|
||||
private final boolean delegate;
|
||||
private final boolean parseRequired;
|
||||
private final Map<String,WebXml> fragments = new HashMap<>();
|
||||
private boolean ok = true;
|
||||
|
||||
public FragmentJarScannerCallback(WebXmlParser webXmlParser, boolean delegate,
|
||||
boolean parseRequired) {
|
||||
this.webXmlParser = webXmlParser;
|
||||
this.delegate = delegate;
|
||||
this.parseRequired = parseRequired;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void scan(Jar jar, String webappPath, boolean isWebapp) throws IOException {
|
||||
|
||||
InputStream is = null;
|
||||
WebXml fragment = new WebXml();
|
||||
fragment.setWebappJar(isWebapp);
|
||||
fragment.setDelegate(delegate);
|
||||
|
||||
try {
|
||||
// Only web application JARs are checked for web-fragment.xml
|
||||
// files.
|
||||
// web-fragment.xml files don't need to be parsed if they are never
|
||||
// going to be used.
|
||||
if (isWebapp && parseRequired) {
|
||||
is = jar.getInputStream(FRAGMENT_LOCATION);
|
||||
}
|
||||
|
||||
if (is == null) {
|
||||
// If there is no web.xml, normal JAR no impact on
|
||||
// distributable
|
||||
fragment.setDistributable(true);
|
||||
} else {
|
||||
String fragmentUrl = jar.getURL(FRAGMENT_LOCATION);
|
||||
InputSource source = new InputSource(fragmentUrl);
|
||||
source.setByteStream(is);
|
||||
if (!webXmlParser.parseWebXml(source, fragment, true)) {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
addFragment(fragment, jar.getJarFileURL());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String extractJarFileName(URL input) {
|
||||
String url = input.toString();
|
||||
if (url.endsWith("!/")) {
|
||||
// Remove it
|
||||
url = url.substring(0, url.length() - 2);
|
||||
}
|
||||
|
||||
// File name will now be whatever is after the final /
|
||||
return url.substring(url.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void scan(File file, String webappPath, boolean isWebapp) throws IOException {
|
||||
|
||||
WebXml fragment = new WebXml();
|
||||
fragment.setWebappJar(isWebapp);
|
||||
fragment.setDelegate(delegate);
|
||||
|
||||
File fragmentFile = new File(file, FRAGMENT_LOCATION);
|
||||
try {
|
||||
if (fragmentFile.isFile()) {
|
||||
try (InputStream stream = new FileInputStream(fragmentFile)) {
|
||||
InputSource source =
|
||||
new InputSource(fragmentFile.toURI().toURL().toString());
|
||||
source.setByteStream(stream);
|
||||
if (!webXmlParser.parseWebXml(source, fragment, true)) {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If there is no web.xml, normal folder no impact on
|
||||
// distributable
|
||||
fragment.setDistributable(true);
|
||||
}
|
||||
} finally {
|
||||
addFragment(fragment, file.toURI().toURL());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addFragment(WebXml fragment, URL url) {
|
||||
fragment.setURL(url);
|
||||
if (fragment.getName() == null) {
|
||||
fragment.setName(url.toString());
|
||||
}
|
||||
fragment.setJarName(extractJarFileName(url));
|
||||
if (fragments.containsKey(fragment.getName())) {
|
||||
// Duplicate. Mark the fragment that has already been found with
|
||||
// this name as having a duplicate so Tomcat can handle it
|
||||
// correctly when the fragments are being ordered.
|
||||
String duplicateName = fragment.getName();
|
||||
fragments.get(duplicateName).setDuplicated(true);
|
||||
// Rename the current fragment so it doesn't clash
|
||||
fragment.setName(url.toString());
|
||||
}
|
||||
fragments.put(fragment.getName(), fragment);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void scanWebInfClasses() {
|
||||
// NO-OP. Fragments unpacked in WEB-INF classes are not handled,
|
||||
// mainly because if there are multiple fragments there is no way to
|
||||
// handle multiple web-fragment.xml files.
|
||||
}
|
||||
|
||||
public boolean isOk() {
|
||||
return ok;
|
||||
}
|
||||
|
||||
public Map<String,WebXml> getFragments() {
|
||||
return fragments;
|
||||
}
|
||||
}
|
||||
25
java/org/apache/tomcat/util/descriptor/web/Injectable.java
Normal file
25
java/org/apache/tomcat/util/descriptor/web/Injectable.java
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Injectable {
|
||||
public String getName();
|
||||
public void addInjectionTarget(String injectionTargetName, String jndiName);
|
||||
public List<InjectionTarget> getInjectionTargets();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class InjectionTarget implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String targetClass;
|
||||
private String targetName;
|
||||
|
||||
|
||||
public InjectionTarget() {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public InjectionTarget(String targetClass, String targetName) {
|
||||
this.targetClass = targetClass;
|
||||
this.targetName = targetName;
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return targetClass;
|
||||
}
|
||||
|
||||
public void setTargetClass(String targetClass) {
|
||||
this.targetClass = targetClass;
|
||||
}
|
||||
|
||||
public String getTargetName() {
|
||||
return targetName;
|
||||
}
|
||||
|
||||
public void setTargetName(String targetName) {
|
||||
this.targetName = targetName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.servlet.descriptor.JspConfigDescriptor;
|
||||
import javax.servlet.descriptor.JspPropertyGroupDescriptor;
|
||||
import javax.servlet.descriptor.TaglibDescriptor;
|
||||
|
||||
public class JspConfigDescriptorImpl implements JspConfigDescriptor {
|
||||
|
||||
private final Collection<JspPropertyGroupDescriptor> jspPropertyGroups;
|
||||
private final Collection<TaglibDescriptor> taglibs;
|
||||
|
||||
public JspConfigDescriptorImpl(Collection<JspPropertyGroupDescriptor> jspPropertyGroups,
|
||||
Collection<TaglibDescriptor> taglibs) {
|
||||
this.jspPropertyGroups = jspPropertyGroups;
|
||||
this.taglibs = taglibs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<JspPropertyGroupDescriptor> getJspPropertyGroups() {
|
||||
return new ArrayList<>(jspPropertyGroups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TaglibDescriptor> getTaglibs() {
|
||||
return new ArrayList<>(taglibs);
|
||||
}
|
||||
}
|
||||
109
java/org/apache/tomcat/util/descriptor/web/JspPropertyGroup.java
Normal file
109
java/org/apache/tomcat/util/descriptor/web/JspPropertyGroup.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.tomcat.util.buf.UDecoder;
|
||||
|
||||
/**
|
||||
* Representation of a jsp-property-group element in web.xml.
|
||||
*/
|
||||
public class JspPropertyGroup extends XmlEncodingBase {
|
||||
|
||||
private Boolean deferredSyntax = null;
|
||||
public void setDeferredSyntax(String deferredSyntax) {
|
||||
this.deferredSyntax = Boolean.valueOf(deferredSyntax);
|
||||
}
|
||||
public Boolean getDeferredSyntax() { return deferredSyntax; }
|
||||
|
||||
private Boolean elIgnored = null;
|
||||
public void setElIgnored(String elIgnored) {
|
||||
this.elIgnored = Boolean.valueOf(elIgnored);
|
||||
}
|
||||
public Boolean getElIgnored() { return elIgnored; }
|
||||
|
||||
private final Collection<String> includeCodas = new ArrayList<>();
|
||||
public void addIncludeCoda(String includeCoda) {
|
||||
includeCodas.add(includeCoda);
|
||||
}
|
||||
public Collection<String> getIncludeCodas() { return includeCodas; }
|
||||
|
||||
private final Collection<String> includePreludes = new ArrayList<>();
|
||||
public void addIncludePrelude(String includePrelude) {
|
||||
includePreludes.add(includePrelude);
|
||||
}
|
||||
public Collection<String> getIncludePreludes() { return includePreludes; }
|
||||
|
||||
private Boolean isXml = null;
|
||||
public void setIsXml(String isXml) {
|
||||
this.isXml = Boolean.valueOf(isXml);
|
||||
}
|
||||
public Boolean getIsXml() { return isXml; }
|
||||
|
||||
private String pageEncoding = null;
|
||||
public void setPageEncoding(String pageEncoding) {
|
||||
this.pageEncoding = pageEncoding;
|
||||
}
|
||||
public String getPageEncoding() { return this.pageEncoding; }
|
||||
|
||||
private Boolean scriptingInvalid = null;
|
||||
public void setScriptingInvalid(String scriptingInvalid) {
|
||||
this.scriptingInvalid = Boolean.valueOf(scriptingInvalid);
|
||||
}
|
||||
public Boolean getScriptingInvalid() { return scriptingInvalid; }
|
||||
|
||||
private Boolean trimWhitespace = null;
|
||||
public void setTrimWhitespace(String trimWhitespace) {
|
||||
this.trimWhitespace = Boolean.valueOf(trimWhitespace);
|
||||
}
|
||||
public Boolean getTrimWhitespace() { return trimWhitespace; }
|
||||
|
||||
private LinkedHashSet<String> urlPattern = new LinkedHashSet<>();
|
||||
public void addUrlPattern(String urlPattern) {
|
||||
addUrlPatternDecoded(UDecoder.URLDecode(urlPattern, getCharset()));
|
||||
}
|
||||
public void addUrlPatternDecoded(String urlPattern) {
|
||||
this.urlPattern.add(urlPattern);
|
||||
}
|
||||
public Set<String> getUrlPatterns() { return this.urlPattern; }
|
||||
|
||||
private String defaultContentType = null;
|
||||
public void setDefaultContentType(String defaultContentType) {
|
||||
this.defaultContentType = defaultContentType;
|
||||
}
|
||||
public String getDefaultContentType() { return this.defaultContentType; }
|
||||
|
||||
private String buffer = null;
|
||||
public void setBuffer(String buffer) {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
public String getBuffer() { return this.buffer; }
|
||||
|
||||
private Boolean errorOnUndeclaredNamespace = null;
|
||||
public void setErrorOnUndeclaredNamespace(
|
||||
String errorOnUndeclaredNamespace) {
|
||||
this.errorOnUndeclaredNamespace =
|
||||
Boolean.valueOf(errorOnUndeclaredNamespace);
|
||||
}
|
||||
public Boolean getErrorOnUndeclaredNamespace() {
|
||||
return this.errorOnUndeclaredNamespace;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.servlet.descriptor.JspPropertyGroupDescriptor;
|
||||
|
||||
|
||||
|
||||
public class JspPropertyGroupDescriptorImpl
|
||||
implements JspPropertyGroupDescriptor{
|
||||
|
||||
private final JspPropertyGroup jspPropertyGroup;
|
||||
|
||||
|
||||
public JspPropertyGroupDescriptorImpl(
|
||||
JspPropertyGroup jspPropertyGroup) {
|
||||
this.jspPropertyGroup = jspPropertyGroup;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getBuffer() {
|
||||
return jspPropertyGroup.getBuffer();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDefaultContentType() {
|
||||
return jspPropertyGroup.getDefaultContentType();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDeferredSyntaxAllowedAsLiteral() {
|
||||
String result = null;
|
||||
|
||||
if (jspPropertyGroup.getDeferredSyntax() != null) {
|
||||
result = jspPropertyGroup.getDeferredSyntax().toString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getElIgnored() {
|
||||
String result = null;
|
||||
|
||||
if (jspPropertyGroup.getElIgnored() != null) {
|
||||
result = jspPropertyGroup.getElIgnored().toString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getErrorOnUndeclaredNamespace() {
|
||||
String result = null;
|
||||
|
||||
if (jspPropertyGroup.getErrorOnUndeclaredNamespace() != null) {
|
||||
result =
|
||||
jspPropertyGroup.getErrorOnUndeclaredNamespace().toString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<String> getIncludeCodas() {
|
||||
return new ArrayList<>(jspPropertyGroup.getIncludeCodas());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<String> getIncludePreludes() {
|
||||
return new ArrayList<>(jspPropertyGroup.getIncludePreludes());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getIsXml() {
|
||||
String result = null;
|
||||
|
||||
if (jspPropertyGroup.getIsXml() != null) {
|
||||
result = jspPropertyGroup.getIsXml().toString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getPageEncoding() {
|
||||
return jspPropertyGroup.getPageEncoding();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getScriptingInvalid() {
|
||||
String result = null;
|
||||
|
||||
if (jspPropertyGroup.getScriptingInvalid() != null) {
|
||||
result = jspPropertyGroup.getScriptingInvalid().toString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTrimDirectiveWhitespaces() {
|
||||
String result = null;
|
||||
|
||||
if (jspPropertyGroup.getTrimWhitespace() != null) {
|
||||
result = jspPropertyGroup.getTrimWhitespace().toString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<String> getUrlPatterns() {
|
||||
return new ArrayList<>(jspPropertyGroup.getUrlPatterns());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
filterDef.invalidFilterName=Invalid <filter-name> [{0}] in filter definition.
|
||||
|
||||
securityConstraint.uncoveredHttpMethod=For security constraints with URL pattern [{0}] only the HTTP methods [{1}] are covered. All other methods are uncovered.
|
||||
securityConstraint.uncoveredHttpMethodFix=Adding security constraints with URL pattern [{0}] to deny access with the uncovered HTTP methods that are not one of the following [{1}]
|
||||
securityConstraint.uncoveredHttpOmittedMethod=For security constraints with URL pattern [{0}] the HTTP methods [{1}] are uncovered.
|
||||
securityConstraint.uncoveredHttpOmittedMethodFix=Adding security constraints with URL pattern [{0}] to deny access with the uncovered HTTP methods [{1}]
|
||||
|
||||
servletDef.invalidServletName=Invalid <servlet-name> [{0}] in servlet definition.
|
||||
|
||||
webRuleSet.absoluteOrdering=<absolute-ordering> element not valid in web-fragment.xml and will be ignored
|
||||
webRuleSet.absoluteOrderingCount=<absolute-ordering> element is limited to 1 occurrence
|
||||
webRuleSet.nameCount=<name> element is limited to 1 occurrence
|
||||
webRuleSet.postconstruct.duplicate=Duplicate post construct method definition for class [{0}]
|
||||
webRuleSet.predestroy.duplicate=Duplicate @PreDestroy method definition for class [{0}]
|
||||
webRuleSet.relativeOrdering=<ordering> element not valid in web.xml and will be ignored
|
||||
webRuleSet.relativeOrderingCount=<ordering> element is limited to 1 occurrence
|
||||
|
||||
webXml.duplicateEnvEntry=Duplicate env-entry name [{0}]
|
||||
webXml.duplicateFilter=Duplicate filter name [{0}]
|
||||
webXml.duplicateFragment=More than one fragment with the name [{0}] was found. This is not legal with relative ordering. See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering.
|
||||
webXml.duplicateMessageDestination=Duplicate message-destination name [{0}]
|
||||
webXml.duplicateMessageDestinationRef=Duplicate message-destination-ref name [{0}]
|
||||
webXml.duplicateResourceEnvRef=Duplicate resource-env-ref name [{0}]
|
||||
webXml.duplicateResourceRef=Duplicate resource-ref name [{0}]
|
||||
webXml.duplicateServletMapping=The servlets named [{0}] and [{1}] are both mapped to the url-pattern [{2}] which is not permitted
|
||||
webXml.duplicateTaglibUri=Duplicate tag library URI [{0}]
|
||||
webXml.mergeConflictDisplayName=The display name was defined in multiple fragments with different values including fragment with name [{0}] located at [{1}]
|
||||
webXml.mergeConflictFilter=The Filter [{0}] was defined inconsistently in multiple fragments including fragment with name [{1}] located at [{2}]
|
||||
webXml.mergeConflictLoginConfig=A LoginConfig was defined inconsistently in multiple fragments including fragment with name [{0}] located at [{1}]
|
||||
webXml.mergeConflictOrder=Fragment relative ordering contains circular references. This can be resolved by using absolute ordering in web.xml.
|
||||
webXml.mergeConflictResource=The Resource [{0}] was defined inconsistently in multiple fragments including fragment with name [{1}] located at [{2}]
|
||||
webXml.mergeConflictServlet=The Servlet [{0}] was defined inconsistently in multiple fragments including fragment with name [{1}] located at [{2}]
|
||||
webXml.mergeConflictSessionCookieComment=The session cookie comment was defined inconsistently in multiple fragments with different values including fragment with name [{0}] located at [{1}]
|
||||
webXml.mergeConflictSessionCookieDomain=The session cookie domain was defined inconsistently in multiple fragments with different values including fragment with name [{0}] located at [{1}]
|
||||
webXml.mergeConflictSessionCookieHttpOnly=The session cookie http-only flag was defined inconsistently in multiple fragments with different values including fragment with name [{0}] located at [{1}]
|
||||
webXml.mergeConflictSessionCookieMaxAge=The session cookie max-age was defined inconsistently in multiple fragments with different values including fragment with name [{0}] located at [{1}]
|
||||
webXml.mergeConflictSessionCookieName=The session cookie name was defined inconsistently in multiple fragments with different values including fragment with name [{0}] located at [{1}]
|
||||
webXml.mergeConflictSessionCookiePath=The session cookie path was defined inconsistently in multiple fragments with different values including fragment with name [{0}] located at [{1}]
|
||||
webXml.mergeConflictSessionCookieSecure=The session cookie secure flag was defined inconsistently in multiple fragments with different values including fragment with name [{0}] located at [{1}]
|
||||
webXml.mergeConflictSessionTimeout=The session timeout was defined inconsistently in multiple fragments with different values including fragment with name [{0}] located at [{1}]
|
||||
webXml.mergeConflictSessionTrackingMode=The session tracking modes were defined inconsistently in multiple fragments including fragment with name [{0}] located at [{1}]
|
||||
webXml.mergeConflictString=The [{0}] with name [{1}] was defined inconsistently in multiple fragments including fragment with name [{2}] located at [{3}]
|
||||
webXml.multipleOther=Multiple <others> entries nested in <ordering> element
|
||||
webXml.reservedName=A web.xml file was detected using a reserved name [{0}]. The name element will be ignored for this fragment.
|
||||
webXml.unrecognisedPublicId=The public ID [{0}] did not match any of the known public ID''s for web.xml files so the version could not be identified
|
||||
webXml.version.unknown=Unknown version string [{0}]. Default version will be used.
|
||||
webXml.wrongFragmentName=Used a wrong fragment name [{0}] at web.xml absolute-ordering tag!
|
||||
|
||||
webXmlParser.applicationParse=Parse error in application web.xml file at [{0}]
|
||||
webXmlParser.applicationPosition=Occurred at line [{0}] column [{1}]
|
||||
webXmlParser.applicationStart=Parsing application web.xml file at [{0}]
|
||||
|
||||
xmlEncodingBase.encodingInvalid=The encoding [{0}] is not recognised by this JRE. The existing value of [{1}] will be used
|
||||
@@ -0,0 +1,20 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
filterDef.invalidFilterName=Ungültiger <filter-name> [{0}] in der Filter Definition.
|
||||
|
||||
webRuleSet.postconstruct.duplicate=Doppelte Post-Konstruktor-Methoden-Definition für Klasse [{0}]
|
||||
|
||||
webXml.duplicateFilter=Doppelter Filter-Name [{0}]
|
||||
@@ -0,0 +1,31 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
filterDef.invalidFilterName=<filter-name> [{0}] inválido en la definición de filtros.\n
|
||||
|
||||
securityConstraint.uncoveredHttpOmittedMethod=Debido a restricciones de seguridad con el patrón de URL [{0}] los métodos HTTP [{1}] no estan cubiertos.
|
||||
|
||||
webRuleSet.absoluteOrdering=Elemento <absolute-ordering> no válido en web-fragment.xml y será ignorado
|
||||
webRuleSet.postconstruct.duplicate=La definición del metodo the post construcción para la clase [{0}] esta duplicada\n
|
||||
webRuleSet.relativeOrdering=elemento <ordering> no válido en web.xml y será ignorado
|
||||
|
||||
webXml.duplicateFilter=Filtro de nombre duplicado [{0}]\n
|
||||
webXml.duplicateServletMapping=Los servlets llamados [{0}] y [{1}] estan ambos mapeados al patrón de URL [{2}] el cual no esta permitido
|
||||
webXml.mergeConflictSessionTrackingMode=Los modos de seguimiento fueron definidos inconsistentemente en multiples fragmentos, incluyendo fragmentos con el nombre [{0}] localizado en [{1}]\n
|
||||
webXml.reservedName=Un archivo web.xml fue detectado usando un nombre reservado [{0}]. El nombre será ignorado para este fragmento.
|
||||
|
||||
webXmlParser.applicationParse=Error de evaluación (parse) en el archivo web.xml de la aplicación a [{0}]
|
||||
webXmlParser.applicationPosition=Se ha producido en la línea [{0}] columna [{1}]
|
||||
webXmlParser.applicationStart=Analizando fichero de aplicación web.xml en [{0}]
|
||||
@@ -0,0 +1,66 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
filterDef.invalidFilterName=Valeur Invalide de <filter-name> [{0}] dans la définition du filtre.
|
||||
|
||||
securityConstraint.uncoveredHttpMethod=Les méthodes HTTP [{1}] des contraintes de sécurité du modèle d''URL [{0}] sont protégées, toutes les autres ne le sont pas
|
||||
securityConstraint.uncoveredHttpMethodFix=Ajout de contraintes de sécurité avec le masque d''URL [{0}] pour empêcher l''accès aux méthodes HTTP non couvertes qui ne sont pas une de celles ci [{1}]
|
||||
securityConstraint.uncoveredHttpOmittedMethod=Les méthodes HTTP [{1}] des contraintes de sécurité du modèle d''URL [{0}] ne sont pas protégées
|
||||
securityConstraint.uncoveredHttpOmittedMethodFix=Ajout de contraintes de sécurité avec le masque d''URL [{0}] pour empêcher l''accès aux méthodes HTTP [{1}] non couvertes
|
||||
|
||||
servletDef.invalidServletName=<servlet-name> [{0}] invalide dans la définition du Servlet
|
||||
|
||||
webRuleSet.absoluteOrdering=L’élément <absolute-ordering> est invalide dans web-fragment.xml et sera ignoré
|
||||
webRuleSet.absoluteOrderingCount=L'élément <absolute-ordering> est limité à 1 ocurrence
|
||||
webRuleSet.nameCount=L'élément <name> est limité à 1 ocurrence
|
||||
webRuleSet.postconstruct.duplicate=La méthode post construct est dupliquée dans la classe [{0}]
|
||||
webRuleSet.predestroy.duplicate=Double définition de l''annotation de méthode @PreDestroy pour la classe [{0}]
|
||||
webRuleSet.relativeOrdering=L’élément <ordering> est invalide dans web.xml et sera ignoré
|
||||
webRuleSet.relativeOrderingCount=L'élément <ordering> est limité à 1 ocurrence
|
||||
|
||||
webXml.duplicateEnvEntry=Le nom de l''env-entry [{0}] a été déclaré en double
|
||||
webXml.duplicateFilter=Nom du filtre dupliqué [{0}]
|
||||
webXml.duplicateFragment=Il y a plus d''un fragment nommé [{0}], ce qui n''est pas légal avec l''ordre relatif; voir la section 8.2.2 2c de la spécification Servlet, l''ordre absolu peut éventuellement être utilisé
|
||||
webXml.duplicateMessageDestination=Le nom de la message-destination [{0}] a été déclaré en double
|
||||
webXml.duplicateMessageDestinationRef=Le nom de la message-destination-ref [{0}] a été déclaré en double
|
||||
webXml.duplicateResourceEnvRef=Le nom de la resource-env-ref [{0}] a été déclaré en double
|
||||
webXml.duplicateResourceRef=Le nom de la resource-ref [{0}] a été déclaré en double
|
||||
webXml.duplicateServletMapping=Les servlets nommés [{0}] et [{1}] sont tous deux associés au même modèle d''URL [{2}], ce qui n''est pas permis
|
||||
webXml.duplicateTaglibUri=Librairies de tags déclarée en double avec l''URI [{0}]
|
||||
webXml.mergeConflictDisplayName=Le nom d''affichage a été défini de manière inconsistante entre différents fragments dont le fragment [{0}] situé à [{1}]
|
||||
webXml.mergeConflictFilter=Le Filter [{0}] a été défini de manière inconsistante entre différents fragments dont le fragment [{1}] situé à [{2}]
|
||||
webXml.mergeConflictLoginConfig=Le LoginConfig a été défini de manière inconsistante entre différents fragments dont le fragment [{0}] situé à [{1}]
|
||||
webXml.mergeConflictOrder=L'ordre relatif des fragments contient des références circulaires, cela peut être résolu en utilisant un ordre absolu dans web.xml
|
||||
webXml.mergeConflictResource=La Resource [{0}] a été définie de manière inconsistante entre différents fragments dont le fragment [{1}] situé à [{2}]
|
||||
webXml.mergeConflictServlet=Le Servlet [{0}] a été défini de manière inconsistante entre différents fragments dont le fragment [{1}] situé à [{2}]
|
||||
webXml.mergeConflictSessionCookieComment=Le commentaire de cookie de session a été défini de manière inconsistante avec des valeurs différentes entre différents fragments dont le fragment [{0}] situé à [{1}]
|
||||
webXml.mergeConflictSessionCookieDomain=Le domaine de cookie de session a été défini de manière inconsistante avec des valeurs différentes entre différents fragments dont le fragment [{0}] situé à [{1}]
|
||||
webXml.mergeConflictSessionCookieHttpOnly=L''indicateur http-only du cookie de session a été défini de manière inconsistante avec des valeurs différentes entre différents fragments dont le fragment [{0}] situé à [{1}]
|
||||
webXml.mergeConflictSessionCookieMaxAge=Le max-age du cookie de session a été défini de manière inconsistante avec des valeurs différentes entre différents fragments dont le fragment [{0}] situé à [{1}]
|
||||
webXml.mergeConflictSessionCookieName=Le nom de cookie de session a été défini de manière inconsistante avec des valeurs différentes entre différents fragments dont le fragment [{0}] situé à [{1}]
|
||||
webXml.mergeConflictSessionCookiePath=Le chemin du cookie de session a été défini de manière inconsistante avec des valeurs différentes entre différents fragments dont le fragment [{0}] situé à [{1}]
|
||||
webXml.mergeConflictSessionCookieSecure=L''indicateur secure du cookie de session a été défini de manière inconsistante avec des valeurs différentes entre différents fragments dont le fragment [{0}] situé à [{1}]
|
||||
webXml.mergeConflictSessionTimeout=Le timeout de la session a été défini de manière inconsistante avec des valeurs différentes entre différents fragments dont le fragment [{0}] situé à [{1}]
|
||||
webXml.mergeConflictSessionTrackingMode=Les modes de gestion de la session ont été déclarés de manière inconsistante entre plusieurs fragments nommés [{0}] et localisés à [{1}]
|
||||
webXml.mergeConflictString=Le [{0}] avec comme nom [{1}] a été défini de manière inconsistante entre différents fragments dont le fragment [{2}] situé à [{3}]
|
||||
webXml.multipleOther=Plusieurs entrées <others> sont incluses dans l'élément <ordering>
|
||||
webXml.reservedName=Un fichier web.xml a été détecté avec un nom réservé [{0}], l''élément name sera ignoré pour ce fragment
|
||||
webXml.unrecognisedPublicId=L''identifiant public [{0}] ne correspond à aucun des identifiants connus pour les fichiers web.xml, donc la version n''a pu être indentifiée
|
||||
webXml.version.unknown=Version [{0}] inconnue, utilisation de la version par défaut
|
||||
webXml.wrongFragmentName=Utilisation d''un mauvais nom de fragment [{0}] dans le tag absolute-ordering de web.xml
|
||||
|
||||
webXmlParser.applicationParse=Erreur de traitement du web.xml de l''application à [{0}]
|
||||
webXmlParser.applicationPosition=S''est produit à la ligne [{0}] colonne [{1}]
|
||||
webXmlParser.applicationStart=Traitement du web.xml de l''application à [{0}]
|
||||
@@ -0,0 +1,66 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
filterDef.invalidFilterName=フィルター定義に無効な <フィルター名> [{0}] があります。
|
||||
|
||||
securityConstraint.uncoveredHttpMethod=URLパターン[{0}]のセキュリティ制約の場合、HTTPメソッド[{1}]のみが対象となります。 その他の方法はすべて対象外です。
|
||||
securityConstraint.uncoveredHttpMethodFix=次の[{1}]ではない特定のHTTPメソッドのアクセスを拒否するURLパターン[{0}]を持つセキュリティ制約を追加します。
|
||||
securityConstraint.uncoveredHttpOmittedMethod=URLパターン[{0}]を持つセキュリティ制約の場合、HTTPメソッド[{1}]は検出されません。
|
||||
securityConstraint.uncoveredHttpOmittedMethodFix=保護されていないHTTPメソッド[{1}]でのアクセスを拒否するURLパターン[{0}]のセキュリティ制約を追加
|
||||
|
||||
servletDef.invalidServletName=サーブレット定義の<servlet-name> [{0}]が無効です。
|
||||
|
||||
webRuleSet.absoluteOrdering=<absolute-ordering>要素はweb-fragment.xmlで無効であり無視されます。
|
||||
webRuleSet.absoluteOrderingCount=<absolute-ordering>要素は1回の発生に制限されます。
|
||||
webRuleSet.nameCount=<name>要素は1回に制限されます。
|
||||
webRuleSet.postconstruct.duplicate=クラス [{0}]にPostConstructメソッド定義が重複しています
|
||||
webRuleSet.predestroy.duplicate=クラス[{0}]の重複する@PreDestroyメソッド定義
|
||||
webRuleSet.relativeOrdering=<ordering>要素はweb.xmlで無効であり無視されます。
|
||||
webRuleSet.relativeOrderingCount=<ordering>要素は1回の出現に制限されます。
|
||||
|
||||
webXml.duplicateEnvEntry=重複したenvエントリ名[{0}]
|
||||
webXml.duplicateFilter=同じ名前のファイル [{0}] が存在します。
|
||||
webXml.duplicateFragment=同名のフラグメント [{0}] が複数見つかりました。相対的な順序付けは正式な機能ではありません。詳細は Servlet Speification の 8.2.2 節 2c 項を参照してください。絶対的な順序付けの利用を検討してください。
|
||||
webXml.duplicateMessageDestination=重複するmessage-destination-name[{0}]
|
||||
webXml.duplicateMessageDestinationRef=重複したmessage-destination-ref 名 [{0}]
|
||||
webXml.duplicateResourceEnvRef=重複した resource-env-ref [{0}]
|
||||
webXml.duplicateResourceRef=重複したresource-ref [{0}]
|
||||
webXml.duplicateServletMapping=サーブレット [{0}] と [{1}] を同じ url-pattern [{2}] にマッピングすることはできません。
|
||||
webXml.duplicateTaglibUri=URI [{0}] のタグライブラリは重複しています。
|
||||
webXml.mergeConflictDisplayName=[{1}] に配置されたフラグメント [{0}] の表示名は、他のフラグメントと異なります。
|
||||
webXml.mergeConflictFilter=[{2}]に配置された名前[{1}]を持つフラグメントを含む複数のフラグメントでフィルタ[{0}]が一貫して定義されていません
|
||||
webXml.mergeConflictLoginConfig=[{1}] に配置されたフラグメント [{0}] の LoginConfig は、他のフラグメントと異なります。
|
||||
webXml.mergeConflictOrder=フラグメントの相対順序には循環参照が含まれます。 これは、web.xmlで絶対順序を使用することで解決できます。
|
||||
webXml.mergeConflictResource=[{2}]にある名前[{1}]のフラグメントを含む、複数のフラグメントでリソース[{0}]が一貫して定義されていません。
|
||||
webXml.mergeConflictServlet=Servlet [{0}]は、[{2}]にある名前[{1}]のフラグメントを含む複数のフラグメントで一貫して定義されていません
|
||||
webXml.mergeConflictSessionCookieComment=セッションCookieのコメントは、[{1}]にある名前[{0}]のフラグメントを含む異なる値を持つ複数のフラグメントで一貫して定義されていません。
|
||||
webXml.mergeConflictSessionCookieDomain=セッションCookieドメインは、[{1}]にある名前[{0}]のフラグメントを含む、異なる値を持つ複数のフラグメントで一貫して定義されていません。
|
||||
webXml.mergeConflictSessionCookieHttpOnly=[{1}] に配置されたフラグメント [{0}] のセッションクッキー http-only フラグの値は、他のフラグメントと異なります。
|
||||
webXml.mergeConflictSessionCookieMaxAge=[{1}] に配置されたフラグメント [{0}] のセッションクッキー max-age の値は、他のフラグメントと異なります。
|
||||
webXml.mergeConflictSessionCookieName=セッションCookie名は、[{1}]にある名前[{0}]のフラグメントを含む異なる値を持つ複数のフラグメントで矛盾して定義されました。
|
||||
webXml.mergeConflictSessionCookiePath=[{1}] に配置されたフラグメント [{0}] のセッションクッキー path は、他のフラグメントと異なります。
|
||||
webXml.mergeConflictSessionCookieSecure=[{1}] に配置されたフラグメント [{0}] のセッションクッキー secure フラグの値は、他のフラグメントと異なります。
|
||||
webXml.mergeConflictSessionTimeout=[{1}] に配置されたフラグメント [{0}] のセッションタイムアウト時間は、他のフラグメントと異なります。
|
||||
webXml.mergeConflictSessionTrackingMode=[{1}] に配置されたフラグメント名 [{0}] を含む複数のフラグメントについて、セッション追跡モードの設定が一貫しません。
|
||||
webXml.mergeConflictString=[{0}] の [{1}] は [{3}] に配置された複数フラグメント [{2}] で別の値が定義されています。
|
||||
webXml.multipleOther=<ordering> 要素に複数の <others> 要素が指定されました。
|
||||
webXml.reservedName=予約名[{0}]を使用してweb.xmlファイルが検出されました。 name要素はこのフラグメントでは無視されます。
|
||||
webXml.unrecognisedPublicId=public ID [{0}]は、既知のweb.xmlファイルのpublic IDと一致しないため、バージョンを特定できませんでした。
|
||||
webXml.version.unknown=[{0}] は未知のバージョン文字列です。初期値を使用します。
|
||||
webXml.wrongFragmentName=web.xmlのabsolute-orderingタグで間違ったフラグメント名[{0}]を使用しました!
|
||||
|
||||
webXmlParser.applicationParse=[{0}]のアプリケーションweb.xmlファイルの解析エラー
|
||||
webXmlParser.applicationPosition=行[{0}]列[{1}]で発生しました。
|
||||
webXmlParser.applicationStart=[{0}]のアプリケーションweb.xmlファイルの解析
|
||||
@@ -0,0 +1,66 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
filterDef.invalidFilterName=유효하지 않은 <filter-name>. [{0}]이(가) 필터 정의에 포함되어 있습니다.
|
||||
|
||||
securityConstraint.uncoveredHttpMethod=URL 패턴 [{0}]와(과) 함께 설정되는 security constraint들에 대해, HTTP 메소드들 [{1}]만이 커버됩니다. 다른 모든 메소드들은 커버되지 않습니다.
|
||||
securityConstraint.uncoveredHttpMethodFix=[{1}] 중의 하나가 아닌, 커버될 수 없는 HTTP 메소드들을 사용한 접근을 거부하기 위하여, URL 패턴이 [{0}]인 security constraint들을 추가합니다.
|
||||
securityConstraint.uncoveredHttpOmittedMethod=URL 패턴 [{0}]와(과) 함께 설정된 security constraint들에 대하여, HTTP 메소드들 [{1}]은(는) 커버되지 않습니다.
|
||||
securityConstraint.uncoveredHttpOmittedMethodFix=커버될 수 없는 HTTP 메소드들 [{1}]에 대한 접근을 거부하기 위하여, URL 패턴 [{0}]와(과) 함께 security constraint를 추가합니다.
|
||||
|
||||
servletDef.invalidServletName=서블릿 정의에서 유효하지 않은 <servlet-name> [{0}]
|
||||
|
||||
webRuleSet.absoluteOrdering=<absolute-ordering> 엘리먼트는 web-fragment.xml 내에서 유효하지 않으므로, 무시될 것입니다.
|
||||
webRuleSet.absoluteOrderingCount=<absolute-ordering> 엘리먼트는 1회만 나타나도록 제한됩니다.
|
||||
webRuleSet.nameCount=<name> 엘리먼트는 단 한번만 나타나도록 제한됩니다.
|
||||
webRuleSet.postconstruct.duplicate=클래스 [{0}]에 PostConstruct 메소드가 중복 정의되어 있습니다.
|
||||
webRuleSet.predestroy.duplicate=클래스 [{0}]에 중복된 @PreDestroy 메소드 정의
|
||||
webRuleSet.relativeOrdering=web.xml 내에서 유효하지 않아서, 해당 <ordering> 엘리먼트는 무시될 것입니다.
|
||||
webRuleSet.relativeOrderingCount=<ordering> 엘리먼트는 오직 한번만 나타나도록 제한됩니다.
|
||||
|
||||
webXml.duplicateEnvEntry=중복된 env-entry 이름 [{0}]
|
||||
webXml.duplicateFilter=중복된 필터 이름: [{0}]
|
||||
webXml.duplicateFragment=이름이 [{0}]인, 둘 이상의 fragment들이 발견되었습니다. 이는 상대적 순서배열에서 불허됩니다. 상세 정보는 서블릿 스펙 8.2.2 2c 장을 참조하십시오. 절대적 순서배열을 사용하는 것을 고려해 보십시오.
|
||||
webXml.duplicateMessageDestination=중복된 message-destination 이름 [{0}]
|
||||
webXml.duplicateMessageDestinationRef=중복된 message-destination-ref 이름 [{0}]
|
||||
webXml.duplicateResourceEnvRef=중복된 resource-env-ref 이름 [{0}]입니다.
|
||||
webXml.duplicateResourceRef=중복된 resource-ref 이름: [{0}]
|
||||
webXml.duplicateServletMapping=이름이 [{0}]과 [{1}]인 두 서블릿들 모두 url-pattern [{2}]에 매핑되어 있는데, 이는 허용되지 않습니다.
|
||||
webXml.duplicateTaglibUri=중복된 태그 라이브러리 URI [{0}]
|
||||
webXml.mergeConflictDisplayName=표시 이름이, 위치가 [{1}]이고 이름이 [{0}]인 fragment를 포함하여, 여러 개의 fragment들에 다른 값들로 정의되었습니다.
|
||||
webXml.mergeConflictFilter=필터 [{0}]이(가), [{2}]에 위치한 [{1}](이)라는 이름을 가진 fragment를 포함하여, 여러 개의 fragment들에서 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictLoginConfig=LoginConfig가, [{1}]에 위치하고 이름이 [{0}]인 fragment를 포함하여, 여러 개의 fragment들에 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictOrder=Fragment의 상대적 순서들이 순환 참조를 포함하고 있습니다. 이 문제는 web.xml에서 절대 순서를 사용함으로써 해결될 수 있습니다.
|
||||
webXml.mergeConflictResource=리소스 [{0}]은(는), 이름이 [{1}](이)고 [{2}]에 위치한 fragment를 포함하여, 여러 개의 fragment들에서 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictServlet=서블릿 [{0}]이(가), [{2}]에 위치하고 [{1}](이)라는 이름을 가진 fragment를 포함하여, 여러 개의 fragment들에서 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictSessionCookieComment=세션 쿠키 주석이, [{1}]에 위치하고 [{0}](이)라는 이름의 fragment를 포함하여, 여러 개의 fragment들에서 다른 값들로 비일관되게 정의되었습니다.
|
||||
webXml.mergeConflictSessionCookieDomain=세션 쿠키 도메인이, [{1}]에 위치하고 이름이 [{0}]인 fragment를 포함하여, 여러 개의 fragment들에서 다른 값들로 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictSessionCookieHttpOnly=세션 쿠키의 http-only 플래그가, [{1}]에 위치하고 이름이 [{0}]인 fragment를 포함하여, 여러 개의 fragment들에 다른 값들로 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictSessionCookieMaxAge=세션 쿠키의 max-age가, [{1}]에 위치하고 이름이 [{0}]인 fragment를 포함하여, 여러 개의 fragment들에서 다른 값들로 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictSessionCookieName=세션 쿠키 이름이, [{1}]에 위치하고 [{0}](이)라는 이름을 가진 fragment를 포함하여, 여러 개의 fragment들에서 다른 값들로 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictSessionCookiePath=세션 쿠기 경로가, [{1}]에 위치하고 이름이 [{0}]인 fragment를 포함하여, 여러 개의 fragment들에서 다른 값들로 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictSessionCookieSecure=세션 쿠키의 secure 플래그가, [{1}]에 위치하고 이름이 [{0}]인 fragment를 포함하여, 여러 개의 fragment들에서 다른 값들로 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictSessionTimeout=세션 제한 시간 초과 값이, [{1}]에 위치하고 이름이 [{0}]인 fragment를 포함하여, 여러 개의 fragment들에 다른 값들로 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictSessionTrackingMode=세션 트랙킹 모드 설정들이, [{1}]에 위치하고 [{0}](이)라는 이름의 fragment를 포함하여, 여러 fragment들에 일관되지 않게 정의되었습니다.
|
||||
webXml.mergeConflictString=이름이 [{1}]인 [{0}]이(가), [{3}]에 위치하고 이름이 [{2}]인 fragment를 포함하여, 여러 개의 fragment들에서 일관되지 않게 정의되었습니다.
|
||||
webXml.multipleOther=<ordering> 엘리먼트 안에 내재된, 여러 개의 <others> 엔트리들
|
||||
webXml.reservedName=예약된 이름 [{0}]을(를) 사용한 web.xml이 탐지되었습니다. name 엘리먼트는 이 fragment를 위해 무시될 것입니다.
|
||||
webXml.unrecognisedPublicId=public ID [{0}]이(가), web.xml 파일들을 위해 알려진 public ID들 중 어떤 것과도 부합되지 않아, 해당 버전을 알아낼 수 없습니다.
|
||||
webXml.version.unknown=알 수 없는 버전 문자열 [{0}]. 기본 버전이 사용될 것입니다.
|
||||
webXml.wrongFragmentName=web.xml의 absolute-ordering 태그에서 잘못된 fragment 이름, [{0}]이(가) 사용되었습니다!
|
||||
|
||||
webXmlParser.applicationParse=[{0}]에 위치한 애플리케이션 web.xml 내에서 파싱 오류 발생
|
||||
webXmlParser.applicationPosition=행 [{0}], 열 [{1}]에서 발생했음
|
||||
webXmlParser.applicationStart=[{0}]에 위치한 애플리케이션 web.xml을 파싱합니다.
|
||||
@@ -0,0 +1,40 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
filterDef.invalidFilterName=过滤器定义中的<filter-name> [{0}] 无效。
|
||||
|
||||
securityConstraint.uncoveredHttpOmittedMethod=对于URL模式[{0}]的安全性约束,将发现HTTP方法[{1}]。
|
||||
securityConstraint.uncoveredHttpOmittedMethodFix=添加url模式为[{0}]的安全约束以拒绝使用未覆盖的http方法[{1}]的访问
|
||||
|
||||
webRuleSet.absoluteOrdering=<绝对值排序>元素在web片段xml中无效,将被忽略。
|
||||
webRuleSet.nameCount=<name>元素只能出现1次
|
||||
webRuleSet.postconstruct.duplicate=class [{0}] 有重复的 post 构造方法声明
|
||||
|
||||
webXml.duplicateEnvEntry=重复的env-entry 名 [{0}]
|
||||
webXml.duplicateFilter=重复的过滤器名称 [{0}]
|
||||
webXml.duplicateServletMapping=名为 [{0}]和 [{1}] 的servlet不能映射为一个url模式(url-pattern) [{2}]
|
||||
webXml.mergeConflictDisplayName=显示名称在多个片段中被定义,这些片段包含不同的值,包括位于[{1}]的[{0}]的片段。
|
||||
webXml.mergeConflictFilter=筛选器[{0}]在多个片段中定义不一致,包括位于[{2}]的名为[{1}]的片段
|
||||
webXml.mergeConflictOrder=片段相对顺序包含循环引用。这可以通过在web.xml中使用绝对排序来解决。
|
||||
webXml.mergeConflictServlet=Servlet[{0}]在多个片段中的定义不一致,包括位于[{2}]的名为[{1}]的片段
|
||||
webXml.mergeConflictSessionCookieName=会话cookie名称在多个具有不同值的片段中定义不一致,包括位于 [{1}] 的片段 [{0}]
|
||||
webXml.mergeConflictSessionTimeout=会话超时以不同值的多个片段不一致地定义,这些片段包括位于[{1}]的具有名称[{0}]的片段。
|
||||
webXml.mergeConflictSessionTrackingMode=会话跟踪模式在多个片段中定义不一致,包括位于[{1}]的名称为[{0}]的片段
|
||||
webXml.reservedName=使用保留名称[{0}]检测到web.xml文件。 此片段将忽略name元素。
|
||||
webXml.unrecognisedPublicId=对于web.xml文件,公共ID[{0}]不匹配任何已知的公共ID‘,因此无法识别版本。
|
||||
webXml.version.unknown=未知版本字符串 [{0}]。将使用默认版本。
|
||||
webXml.wrongFragmentName=在web.xml绝对排序标签上使用了错误的片段名[{0}]!
|
||||
|
||||
webXmlParser.applicationPosition=出现在第 [{0}] 行 第 [{1}] 列
|
||||
217
java/org/apache/tomcat/util/descriptor/web/LoginConfig.java
Normal file
217
java/org/apache/tomcat/util/descriptor/web/LoginConfig.java
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.tomcat.util.buf.UDecoder;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public class LoginConfig implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
// ----------------------------------------------------------- Constructors
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new LoginConfig with default properties.
|
||||
*/
|
||||
public LoginConfig() {
|
||||
|
||||
super();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new LoginConfig with the specified properties.
|
||||
*
|
||||
* @param authMethod The authentication method
|
||||
* @param realmName The realm name
|
||||
* @param loginPage The login page URI
|
||||
* @param errorPage The error page URI
|
||||
*/
|
||||
public LoginConfig(String authMethod, String realmName,
|
||||
String loginPage, String errorPage) {
|
||||
|
||||
super();
|
||||
setAuthMethod(authMethod);
|
||||
setRealmName(realmName);
|
||||
setLoginPage(loginPage);
|
||||
setErrorPage(errorPage);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* The authentication method to use for application login. Must be
|
||||
* BASIC, DIGEST, FORM, or CLIENT-CERT.
|
||||
*/
|
||||
private String authMethod = null;
|
||||
|
||||
public String getAuthMethod() {
|
||||
return this.authMethod;
|
||||
}
|
||||
|
||||
public void setAuthMethod(String authMethod) {
|
||||
this.authMethod = authMethod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The context-relative URI of the error page for form login.
|
||||
*/
|
||||
private String errorPage = null;
|
||||
|
||||
public String getErrorPage() {
|
||||
return this.errorPage;
|
||||
}
|
||||
|
||||
public void setErrorPage(String errorPage) {
|
||||
// if ((errorPage == null) || !errorPage.startsWith("/"))
|
||||
// throw new IllegalArgumentException
|
||||
// ("Error Page resource path must start with a '/'");
|
||||
this.errorPage = UDecoder.URLDecode(errorPage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The context-relative URI of the login page for form login.
|
||||
*/
|
||||
private String loginPage = null;
|
||||
|
||||
public String getLoginPage() {
|
||||
return this.loginPage;
|
||||
}
|
||||
|
||||
public void setLoginPage(String loginPage) {
|
||||
// if ((loginPage == null) || !loginPage.startsWith("/"))
|
||||
// throw new IllegalArgumentException
|
||||
// ("Login Page resource path must start with a '/'");
|
||||
this.loginPage = UDecoder.URLDecode(loginPage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The realm name used when challenging the user for authentication
|
||||
* credentials.
|
||||
*/
|
||||
private String realmName = null;
|
||||
|
||||
public String getRealmName() {
|
||||
return this.realmName;
|
||||
}
|
||||
|
||||
public void setRealmName(String realmName) {
|
||||
this.realmName = realmName;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("LoginConfig[");
|
||||
sb.append("authMethod=");
|
||||
sb.append(authMethod);
|
||||
if (realmName != null) {
|
||||
sb.append(", realmName=");
|
||||
sb.append(realmName);
|
||||
}
|
||||
if (loginPage != null) {
|
||||
sb.append(", loginPage=");
|
||||
sb.append(loginPage);
|
||||
}
|
||||
if (errorPage != null) {
|
||||
sb.append(", errorPage=");
|
||||
sb.append(errorPage);
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
+ ((authMethod == null) ? 0 : authMethod.hashCode());
|
||||
result = prime * result
|
||||
+ ((errorPage == null) ? 0 : errorPage.hashCode());
|
||||
result = prime * result
|
||||
+ ((loginPage == null) ? 0 : loginPage.hashCode());
|
||||
result = prime * result
|
||||
+ ((realmName == null) ? 0 : realmName.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(obj instanceof LoginConfig))
|
||||
return false;
|
||||
LoginConfig other = (LoginConfig) obj;
|
||||
if (authMethod == null) {
|
||||
if (other.authMethod != null)
|
||||
return false;
|
||||
} else if (!authMethod.equals(other.authMethod))
|
||||
return false;
|
||||
if (errorPage == null) {
|
||||
if (other.errorPage != null)
|
||||
return false;
|
||||
} else if (!errorPage.equals(other.errorPage))
|
||||
return false;
|
||||
if (loginPage == null) {
|
||||
if (other.loginPage != null)
|
||||
return false;
|
||||
} else if (!loginPage.equals(other.loginPage))
|
||||
return false;
|
||||
if (realmName == null) {
|
||||
if (other.realmName != null)
|
||||
return false;
|
||||
} else if (!realmName.equals(other.realmName))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Representation of a message destination for a web application, as
|
||||
* represented in a <code><message-destination></code> element
|
||||
* in the deployment descriptor.</p>
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
* @since Tomcat 5.0
|
||||
*/
|
||||
public class MessageDestination extends ResourceBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* The display name of this destination.
|
||||
*/
|
||||
private String displayName = null;
|
||||
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The large icon of this destination.
|
||||
*/
|
||||
private String largeIcon = null;
|
||||
|
||||
public String getLargeIcon() {
|
||||
return this.largeIcon;
|
||||
}
|
||||
|
||||
public void setLargeIcon(String largeIcon) {
|
||||
this.largeIcon = largeIcon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The small icon of this destination.
|
||||
*/
|
||||
private String smallIcon = null;
|
||||
|
||||
public String getSmallIcon() {
|
||||
return this.smallIcon;
|
||||
}
|
||||
|
||||
public void setSmallIcon(String smallIcon) {
|
||||
this.smallIcon = smallIcon;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("MessageDestination[");
|
||||
sb.append("name=");
|
||||
sb.append(getName());
|
||||
if (displayName != null) {
|
||||
sb.append(", displayName=");
|
||||
sb.append(displayName);
|
||||
}
|
||||
if (largeIcon != null) {
|
||||
sb.append(", largeIcon=");
|
||||
sb.append(largeIcon);
|
||||
}
|
||||
if (smallIcon != null) {
|
||||
sb.append(", smallIcon=");
|
||||
sb.append(smallIcon);
|
||||
}
|
||||
if (getDescription() != null) {
|
||||
sb.append(", description=");
|
||||
sb.append(getDescription());
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result +
|
||||
((displayName == null) ? 0 : displayName.hashCode());
|
||||
result = prime * result +
|
||||
((largeIcon == null) ? 0 : largeIcon.hashCode());
|
||||
result = prime * result +
|
||||
((smallIcon == null) ? 0 : smallIcon.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
MessageDestination other = (MessageDestination) obj;
|
||||
if (displayName == null) {
|
||||
if (other.displayName != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!displayName.equals(other.displayName)) {
|
||||
return false;
|
||||
}
|
||||
if (largeIcon == null) {
|
||||
if (other.largeIcon != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!largeIcon.equals(other.largeIcon)) {
|
||||
return false;
|
||||
}
|
||||
if (smallIcon == null) {
|
||||
if (other.smallIcon != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!smallIcon.equals(other.smallIcon)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Representation of a message destination reference for a web application,
|
||||
* as represented in a <code><message-destination-ref></code> element
|
||||
* in the deployment descriptor.</p>
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
* @since Tomcat 5.0
|
||||
*/
|
||||
public class MessageDestinationRef extends ResourceBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* The link of this destination ref.
|
||||
*/
|
||||
private String link = null;
|
||||
|
||||
public String getLink() {
|
||||
return this.link;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The usage of this destination ref.
|
||||
*/
|
||||
private String usage = null;
|
||||
|
||||
public String getUsage() {
|
||||
return this.usage;
|
||||
}
|
||||
|
||||
public void setUsage(String usage) {
|
||||
this.usage = usage;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("MessageDestination[");
|
||||
sb.append("name=");
|
||||
sb.append(getName());
|
||||
if (link != null) {
|
||||
sb.append(", link=");
|
||||
sb.append(link);
|
||||
}
|
||||
if (getType() != null) {
|
||||
sb.append(", type=");
|
||||
sb.append(getType());
|
||||
}
|
||||
if (usage != null) {
|
||||
sb.append(", usage=");
|
||||
sb.append(usage);
|
||||
}
|
||||
if (getDescription() != null) {
|
||||
sb.append(", description=");
|
||||
sb.append(getDescription());
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((link == null) ? 0 : link.hashCode());
|
||||
result = prime * result + ((usage == null) ? 0 : usage.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
MessageDestinationRef other = (MessageDestinationRef) obj;
|
||||
if (link == null) {
|
||||
if (other.link != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!link.equals(other.link)) {
|
||||
return false;
|
||||
}
|
||||
if (usage == null) {
|
||||
if (other.usage != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!usage.equals(other.usage)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
138
java/org/apache/tomcat/util/descriptor/web/MultipartDef.java
Normal file
138
java/org/apache/tomcat/util/descriptor/web/MultipartDef.java
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* Representation of a the multipart configuration for a servlet.
|
||||
*/
|
||||
public class MultipartDef implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
private String location;
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
|
||||
private String maxFileSize;
|
||||
|
||||
public String getMaxFileSize() {
|
||||
return maxFileSize;
|
||||
}
|
||||
|
||||
public void setMaxFileSize(String maxFileSize) {
|
||||
this.maxFileSize = maxFileSize;
|
||||
}
|
||||
|
||||
|
||||
private String maxRequestSize;
|
||||
|
||||
public String getMaxRequestSize() {
|
||||
return maxRequestSize;
|
||||
}
|
||||
|
||||
public void setMaxRequestSize(String maxRequestSize) {
|
||||
this.maxRequestSize = maxRequestSize;
|
||||
}
|
||||
|
||||
|
||||
private String fileSizeThreshold;
|
||||
|
||||
public String getFileSizeThreshold() {
|
||||
return fileSizeThreshold;
|
||||
}
|
||||
|
||||
public void setFileSizeThreshold(String fileSizeThreshold) {
|
||||
this.fileSizeThreshold = fileSizeThreshold;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------- Object methods
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime
|
||||
* result
|
||||
+ ((fileSizeThreshold == null) ? 0 : fileSizeThreshold
|
||||
.hashCode());
|
||||
result = prime * result
|
||||
+ ((location == null) ? 0 : location.hashCode());
|
||||
result = prime * result
|
||||
+ ((maxFileSize == null) ? 0 : maxFileSize.hashCode());
|
||||
result = prime * result
|
||||
+ ((maxRequestSize == null) ? 0 : maxRequestSize.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof MultipartDef)) {
|
||||
return false;
|
||||
}
|
||||
MultipartDef other = (MultipartDef) obj;
|
||||
if (fileSizeThreshold == null) {
|
||||
if (other.fileSizeThreshold != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!fileSizeThreshold.equals(other.fileSizeThreshold)) {
|
||||
return false;
|
||||
}
|
||||
if (location == null) {
|
||||
if (other.location != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!location.equals(other.location)) {
|
||||
return false;
|
||||
}
|
||||
if (maxFileSize == null) {
|
||||
if (other.maxFileSize != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!maxFileSize.equals(other.maxFileSize)) {
|
||||
return false;
|
||||
}
|
||||
if (maxRequestSize == null) {
|
||||
if (other.maxRequestSize != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!maxRequestSize.equals(other.maxRequestSize)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Defines an interface for the object that is added to the representation of a
|
||||
* JNDI resource in web.xml to enable it to also be the implementation of that
|
||||
* JNDI resource. Only Catalina implements this interface but because the
|
||||
* web.xml representation is shared this interface has to be visible to Catalina
|
||||
* and Jasper.
|
||||
*/
|
||||
public interface NamingResources {
|
||||
|
||||
void addEnvironment(ContextEnvironment ce);
|
||||
void removeEnvironment(String name);
|
||||
|
||||
void addResource(ContextResource cr);
|
||||
void removeResource(String name);
|
||||
|
||||
void addResourceLink(ContextResourceLink crl);
|
||||
void removeResourceLink(String name);
|
||||
|
||||
Object getContainer();
|
||||
}
|
||||
233
java/org/apache/tomcat/util/descriptor/web/ResourceBase.java
Normal file
233
java/org/apache/tomcat/util/descriptor/web/ResourceBase.java
Normal file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Representation of an Context element
|
||||
*
|
||||
* @author Peter Rossbach (pero@apache.org)
|
||||
*/
|
||||
public class ResourceBase implements Serializable, Injectable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
/**
|
||||
* The description of this resource.
|
||||
*/
|
||||
private String description = null;
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The name of this resource.
|
||||
*/
|
||||
private String name = null;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The name of the resource implementation class.
|
||||
*/
|
||||
private String type = null;
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
private String lookupName = null;
|
||||
|
||||
public String getLookupName() {
|
||||
return lookupName;
|
||||
}
|
||||
|
||||
public void setLookupName(String lookupName) {
|
||||
if (lookupName == null || lookupName.length() == 0) {
|
||||
this.lookupName = null;
|
||||
return;
|
||||
}
|
||||
this.lookupName = lookupName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Holder for our configured properties.
|
||||
*/
|
||||
private final HashMap<String, Object> properties = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @param name The property name
|
||||
* @return a configured property.
|
||||
*/
|
||||
public Object getProperty(String name) {
|
||||
return properties.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a configured property.
|
||||
* @param name The property name
|
||||
* @param value The property value
|
||||
*/
|
||||
public void setProperty(String name, Object value) {
|
||||
properties.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a configured property.
|
||||
* @param name The property name
|
||||
*/
|
||||
public void removeProperty(String name) {
|
||||
properties.remove(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* List properties.
|
||||
* @return the property names iterator
|
||||
*/
|
||||
public Iterator<String> listProperties() {
|
||||
return properties.keySet().iterator();
|
||||
}
|
||||
|
||||
private final List<InjectionTarget> injectionTargets = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void addInjectionTarget(String injectionTargetName, String jndiName) {
|
||||
InjectionTarget target = new InjectionTarget(injectionTargetName, jndiName);
|
||||
injectionTargets.add(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InjectionTarget> getInjectionTargets() {
|
||||
return injectionTargets;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((injectionTargets == null) ? 0 : injectionTargets.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((properties == null) ? 0 : properties.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
result = prime * result + ((lookupName == null) ? 0 : lookupName.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ResourceBase other = (ResourceBase) obj;
|
||||
if (description == null) {
|
||||
if (other.description != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!description.equals(other.description)) {
|
||||
return false;
|
||||
}
|
||||
if (injectionTargets == null) {
|
||||
if (other.injectionTargets != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!injectionTargets.equals(other.injectionTargets)) {
|
||||
return false;
|
||||
}
|
||||
if (name == null) {
|
||||
if (other.name != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!name.equals(other.name)) {
|
||||
return false;
|
||||
}
|
||||
if (properties == null) {
|
||||
if (other.properties != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!properties.equals(other.properties)) {
|
||||
return false;
|
||||
}
|
||||
if (type == null) {
|
||||
if (other.type != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!type.equals(other.type)) {
|
||||
return false;
|
||||
}
|
||||
if (lookupName == null) {
|
||||
if (other.lookupName != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!lookupName.equals(other.lookupName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The NamingResources with which we are associated (if any).
|
||||
*/
|
||||
private NamingResources resources = null;
|
||||
|
||||
public NamingResources getNamingResources() {
|
||||
return this.resources;
|
||||
}
|
||||
|
||||
public void setNamingResources(NamingResources resources) {
|
||||
this.resources = resources;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.tomcat.util.buf.UDecoder;
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public class SecurityCollection extends XmlEncodingBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ----------------------------------------------------------- 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
|
||||
* @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 explicitly covered by this web resource collection.
|
||||
*/
|
||||
private String methods[] = new String[0];
|
||||
|
||||
|
||||
/**
|
||||
* The HTTP methods explicitly excluded from this web resource collection.
|
||||
*/
|
||||
private String omittedMethods[] = 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];
|
||||
|
||||
|
||||
/**
|
||||
* This security collection was established by a deployment descriptor.
|
||||
* Defaults to <code>true</code>.
|
||||
*/
|
||||
private boolean isFromDescriptor = true;
|
||||
|
||||
// ------------------------------------------------------------- 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return if this constraint was defined in a deployment descriptor.
|
||||
*/
|
||||
public boolean isFromDescriptor() {
|
||||
return isFromDescriptor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set if this constraint was defined in a deployment descriptor.
|
||||
* @param isFromDescriptor <code>true</code> was declared in a descriptor
|
||||
*/
|
||||
public void setFromDescriptor(boolean isFromDescriptor) {
|
||||
this.isFromDescriptor = isFromDescriptor;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Add an HTTP request method to be explicitly part of this web resource
|
||||
* collection.
|
||||
* @param method The method
|
||||
*/
|
||||
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 an HTTP request method to the methods explicitly excluded from this
|
||||
* web resource collection.
|
||||
* @param method The method
|
||||
*/
|
||||
public void addOmittedMethod(String method) {
|
||||
if (method == null)
|
||||
return;
|
||||
String results[] = new String[omittedMethods.length + 1];
|
||||
for (int i = 0; i < omittedMethods.length; i++)
|
||||
results[i] = omittedMethods[i];
|
||||
results[omittedMethods.length] = method;
|
||||
omittedMethods = results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a URL pattern to be part of this web resource collection.
|
||||
* @param pattern The pattern
|
||||
*/
|
||||
public void addPattern(String pattern) {
|
||||
addPatternDecoded(UDecoder.URLDecode(pattern, StandardCharsets.UTF_8));
|
||||
}
|
||||
public void addPatternDecoded(String pattern) {
|
||||
|
||||
if (pattern == null)
|
||||
return;
|
||||
|
||||
String decodedPattern = UDecoder.URLDecode(pattern);
|
||||
String results[] = new String[patterns.length + 1];
|
||||
for (int i = 0; i < patterns.length; i++) {
|
||||
results[i] = patterns[i];
|
||||
}
|
||||
results[patterns.length] = decodedPattern;
|
||||
patterns = results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the collection applies to the specified method.
|
||||
* @param method Request method to check
|
||||
* @return <code>true</code> if the specified HTTP request method is
|
||||
* part of this web resource collection.
|
||||
*/
|
||||
public boolean findMethod(String method) {
|
||||
|
||||
if (methods.length == 0 && omittedMethods.length == 0)
|
||||
return true;
|
||||
if (methods.length > 0) {
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
if (methods[i].equals(method))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (omittedMethods.length > 0) {
|
||||
for (int i = 0; i < omittedMethods.length; i++) {
|
||||
if (omittedMethods[i].equals(method))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the set of HTTP request methods that are part of this web
|
||||
* resource collection, or a zero-length array if no methods have been
|
||||
* explicitly included.
|
||||
*/
|
||||
public String[] findMethods() {
|
||||
return methods;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the set of HTTP request methods that are explicitly excluded from
|
||||
* this web resource collection, or a zero-length array if no request
|
||||
* methods are excluded.
|
||||
*/
|
||||
public String[] findOmittedMethods() {
|
||||
return omittedMethods;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is the specified pattern part of this web resource collection?
|
||||
*
|
||||
* @param pattern Pattern to be compared
|
||||
* @return <code>true</code> if the pattern is part of the collection
|
||||
*/
|
||||
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 HTTP request method from those that are explicitly
|
||||
* excluded from this web resource collection.
|
||||
*
|
||||
* @param method Request method to be removed
|
||||
*/
|
||||
public void removeOmittedMethod(String method) {
|
||||
|
||||
if (method == null)
|
||||
return;
|
||||
int n = -1;
|
||||
for (int i = 0; i < omittedMethods.length; i++) {
|
||||
if (omittedMethods[i].equals(method)) {
|
||||
n = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (n >= 0) {
|
||||
int j = 0;
|
||||
String results[] = new String[omittedMethods.length - 1];
|
||||
for (int i = 0; i < omittedMethods.length; i++) {
|
||||
if (i != n)
|
||||
results[j++] = omittedMethods[i];
|
||||
}
|
||||
omittedMethods = 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.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("SecurityCollection[");
|
||||
sb.append(name);
|
||||
if (description != null) {
|
||||
sb.append(", ");
|
||||
sb.append(description);
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,766 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.HttpConstraintElement;
|
||||
import javax.servlet.HttpMethodConstraintElement;
|
||||
import javax.servlet.ServletSecurityElement;
|
||||
import javax.servlet.annotation.ServletSecurity;
|
||||
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic;
|
||||
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public class SecurityConstraint extends XmlEncodingBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String ROLE_ALL_ROLES = "*";
|
||||
public static final String ROLE_ALL_AUTHENTICATED_USERS = "**";
|
||||
|
||||
private static final StringManager sm =
|
||||
StringManager.getManager(Constants.PACKAGE_NAME);
|
||||
|
||||
|
||||
// ----------------------------------------------------------- Constructors
|
||||
|
||||
/**
|
||||
* Construct a new security constraint instance with default values.
|
||||
*/
|
||||
public SecurityConstraint() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------- Instance Variables
|
||||
|
||||
|
||||
/**
|
||||
* Was the "all roles" wildcard - {@link #ROLE_ALL_ROLES} - included in the
|
||||
* authorization constraints for this security constraint?
|
||||
*/
|
||||
private boolean allRoles = false;
|
||||
|
||||
|
||||
/**
|
||||
* Was the "all authenticated users" wildcard -
|
||||
* {@link #ROLE_ALL_AUTHENTICATED_USERS} - included in the authorization
|
||||
* constraints for this security constraint?
|
||||
*/
|
||||
private boolean authenticatedUsers = false;
|
||||
|
||||
|
||||
/**
|
||||
* Was an authorization constraint included in this security constraint?
|
||||
* This is necessary to distinguish the case where an auth-constraint with
|
||||
* no roles (signifying no direct access at all) was requested, versus
|
||||
* a lack of auth-constraint which implies no access control checking.
|
||||
*/
|
||||
private boolean authConstraint = false;
|
||||
|
||||
|
||||
/**
|
||||
* 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 display name of this security constraint.
|
||||
*/
|
||||
private String displayName = null;
|
||||
|
||||
|
||||
/**
|
||||
* The user data constraint for this security constraint. Must be NONE,
|
||||
* INTEGRAL, or CONFIDENTIAL.
|
||||
*/
|
||||
private String userConstraint = "NONE";
|
||||
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* Was the "all roles" wildcard included in this authentication
|
||||
* constraint?
|
||||
* @return <code>true</code> if all roles
|
||||
*/
|
||||
public boolean getAllRoles() {
|
||||
|
||||
return this.allRoles;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Was the "all authenticated users" wildcard included in this
|
||||
* authentication constraint?
|
||||
* @return <code>true</code> if all authenticated users
|
||||
*/
|
||||
public boolean getAuthenticatedUsers() {
|
||||
return this.authenticatedUsers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the authorization constraint present flag for this security
|
||||
* constraint.
|
||||
* @return <code>true</code> if this needs authorization
|
||||
*/
|
||||
public boolean getAuthConstraint() {
|
||||
|
||||
return this.authConstraint;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the authorization constraint present flag for this security
|
||||
* constraint.
|
||||
* @param authConstraint The new value
|
||||
*/
|
||||
public void setAuthConstraint(boolean authConstraint) {
|
||||
|
||||
this.authConstraint = authConstraint;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the display name of this security constraint.
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
|
||||
return this.displayName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the display name of this security constraint.
|
||||
* @param displayName The new value
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
|
||||
this.displayName = displayName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the user data constraint for this security constraint.
|
||||
* @return the user 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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called in the unlikely event that an application defines a role named
|
||||
* "**".
|
||||
*/
|
||||
public void treatAllAuthenticatedUsersAsApplicationRole() {
|
||||
if (authenticatedUsers) {
|
||||
authenticatedUsers = false;
|
||||
|
||||
String results[] = new String[authRoles.length + 1];
|
||||
for (int i = 0; i < authRoles.length; i++)
|
||||
results[i] = authRoles[i];
|
||||
results[authRoles.length] = ROLE_ALL_AUTHENTICATED_USERS;
|
||||
authRoles = results;
|
||||
authConstraint = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------- 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;
|
||||
|
||||
if (ROLE_ALL_ROLES.equals(authRole)) {
|
||||
allRoles = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ROLE_ALL_AUTHENTICATED_USERS.equals(authRole)) {
|
||||
authenticatedUsers = true;
|
||||
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;
|
||||
authConstraint = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
collection.setCharset(getCharset());
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check a role.
|
||||
*
|
||||
* @param role Role name to be checked
|
||||
* @return <code>true</code> if the specified role is permitted access to
|
||||
* the resources protected by this security constraint.
|
||||
*/
|
||||
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).
|
||||
* @return the roles array
|
||||
*/
|
||||
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
|
||||
* @return the collection
|
||||
*/
|
||||
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.
|
||||
* @return the collections array
|
||||
*/
|
||||
public SecurityCollection[] findCollections() {
|
||||
return collections;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the constraint applies to a URI and method.
|
||||
* @param uri Context-relative URI to check
|
||||
* @param method Request method being used
|
||||
* @return <code>true</code> if the specified context-relative URI (and
|
||||
* associated HTTP method) are protected by this security constraint.
|
||||
*/
|
||||
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;
|
||||
|
||||
if (ROLE_ALL_ROLES.equals(authRole)) {
|
||||
allRoles = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ROLE_ALL_AUTHENTICATED_USERS.equals(authRole)) {
|
||||
authenticatedUsers = false;
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a {@link ServletSecurityElement} to an array of
|
||||
* {@link SecurityConstraint}(s).
|
||||
*
|
||||
* @param element The element to be converted
|
||||
* @param urlPattern The url pattern that the element should be applied
|
||||
* to
|
||||
* @return The (possibly zero length) array of constraints that
|
||||
* are the equivalent to the input
|
||||
*/
|
||||
public static SecurityConstraint[] createConstraints(
|
||||
ServletSecurityElement element, String urlPattern) {
|
||||
Set<SecurityConstraint> result = new HashSet<>();
|
||||
|
||||
// Add the per method constraints
|
||||
Collection<HttpMethodConstraintElement> methods =
|
||||
element.getHttpMethodConstraints();
|
||||
for (HttpMethodConstraintElement methodElement : methods) {
|
||||
SecurityConstraint constraint =
|
||||
createConstraint(methodElement, urlPattern, true);
|
||||
// There will always be a single collection
|
||||
SecurityCollection collection = constraint.findCollections()[0];
|
||||
collection.addMethod(methodElement.getMethodName());
|
||||
result.add(constraint);
|
||||
}
|
||||
|
||||
// Add the constraint for all the other methods
|
||||
SecurityConstraint constraint = createConstraint(element, urlPattern, false);
|
||||
if (constraint != null) {
|
||||
// There will always be a single collection
|
||||
SecurityCollection collection = constraint.findCollections()[0];
|
||||
for (String name : element.getMethodNames()) {
|
||||
collection.addOmittedMethod(name);
|
||||
}
|
||||
|
||||
result.add(constraint);
|
||||
|
||||
}
|
||||
|
||||
return result.toArray(new SecurityConstraint[result.size()]);
|
||||
}
|
||||
|
||||
private static SecurityConstraint createConstraint(
|
||||
HttpConstraintElement element, String urlPattern, boolean alwaysCreate) {
|
||||
|
||||
SecurityConstraint constraint = new SecurityConstraint();
|
||||
SecurityCollection collection = new SecurityCollection();
|
||||
boolean create = alwaysCreate;
|
||||
|
||||
if (element.getTransportGuarantee() !=
|
||||
ServletSecurity.TransportGuarantee.NONE) {
|
||||
constraint.setUserConstraint(element.getTransportGuarantee().name());
|
||||
create = true;
|
||||
}
|
||||
if (element.getRolesAllowed().length > 0) {
|
||||
String[] roles = element.getRolesAllowed();
|
||||
for (String role : roles) {
|
||||
constraint.addAuthRole(role);
|
||||
}
|
||||
create = true;
|
||||
}
|
||||
if (element.getEmptyRoleSemantic() != EmptyRoleSemantic.PERMIT) {
|
||||
constraint.setAuthConstraint(true);
|
||||
create = true;
|
||||
}
|
||||
|
||||
if (create) {
|
||||
collection.addPattern(urlPattern);
|
||||
constraint.addCollection(collection);
|
||||
return constraint;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static SecurityConstraint[] findUncoveredHttpMethods(
|
||||
SecurityConstraint[] constraints,
|
||||
boolean denyUncoveredHttpMethods, Log log) {
|
||||
|
||||
Set<String> coveredPatterns = new HashSet<>();
|
||||
Map<String,Set<String>> urlMethodMap = new HashMap<>();
|
||||
Map<String,Set<String>> urlOmittedMethodMap = new HashMap<>();
|
||||
|
||||
List<SecurityConstraint> newConstraints = new ArrayList<>();
|
||||
|
||||
// First build the lists of covered patterns and those patterns that
|
||||
// might be uncovered
|
||||
for (SecurityConstraint constraint : constraints) {
|
||||
SecurityCollection[] collections = constraint.findCollections();
|
||||
for (SecurityCollection collection : collections) {
|
||||
String[] patterns = collection.findPatterns();
|
||||
String[] methods = collection.findMethods();
|
||||
String[] omittedMethods = collection.findOmittedMethods();
|
||||
// Simple case: no methods
|
||||
if (methods.length == 0 && omittedMethods.length == 0) {
|
||||
for (String pattern : patterns) {
|
||||
coveredPatterns.add(pattern);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Pre-calculate so we don't do this for every iteration of the
|
||||
// following loop
|
||||
List<String> omNew = null;
|
||||
if (omittedMethods.length != 0) {
|
||||
omNew = Arrays.asList(omittedMethods);
|
||||
}
|
||||
|
||||
// Only need to process uncovered patterns
|
||||
for (String pattern : patterns) {
|
||||
if (!coveredPatterns.contains(pattern)) {
|
||||
if (methods.length == 0) {
|
||||
// Build the interset of omitted methods for this
|
||||
// pattern
|
||||
Set<String> om = urlOmittedMethodMap.get(pattern);
|
||||
if (om == null) {
|
||||
om = new HashSet<>();
|
||||
urlOmittedMethodMap.put(pattern, om);
|
||||
om.addAll(omNew);
|
||||
} else {
|
||||
om.retainAll(omNew);
|
||||
}
|
||||
} else {
|
||||
// Build the union of methods for this pattern
|
||||
Set<String> m = urlMethodMap.get(pattern);
|
||||
if (m == null) {
|
||||
m = new HashSet<>();
|
||||
urlMethodMap.put(pattern, m);
|
||||
}
|
||||
for (String method : methods) {
|
||||
m.add(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now check the potentially uncovered patterns
|
||||
for (Map.Entry<String, Set<String>> entry : urlMethodMap.entrySet()) {
|
||||
String pattern = entry.getKey();
|
||||
if (coveredPatterns.contains(pattern)) {
|
||||
// Fully covered. Ignore any partial coverage
|
||||
urlOmittedMethodMap.remove(pattern);
|
||||
continue;
|
||||
}
|
||||
|
||||
Set<String> omittedMethods = urlOmittedMethodMap.remove(pattern);
|
||||
Set<String> methods = entry.getValue();
|
||||
|
||||
if (omittedMethods == null) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (String method : methods) {
|
||||
msg.append(method);
|
||||
msg.append(' ');
|
||||
}
|
||||
if (denyUncoveredHttpMethods) {
|
||||
log.info(sm.getString(
|
||||
"securityConstraint.uncoveredHttpMethodFix",
|
||||
pattern, msg.toString().trim()));
|
||||
SecurityCollection collection = new SecurityCollection();
|
||||
for (String method : methods) {
|
||||
collection.addOmittedMethod(method);
|
||||
}
|
||||
collection.addPatternDecoded(pattern);
|
||||
collection.setName("deny-uncovered-http-methods");
|
||||
SecurityConstraint constraint = new SecurityConstraint();
|
||||
constraint.setAuthConstraint(true);
|
||||
constraint.addCollection(collection);
|
||||
newConstraints.add(constraint);
|
||||
} else {
|
||||
log.error(sm.getString(
|
||||
"securityConstraint.uncoveredHttpMethod",
|
||||
pattern, msg.toString().trim()));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// As long as every omitted method as a corresponding method the
|
||||
// pattern is fully covered.
|
||||
omittedMethods.removeAll(methods);
|
||||
|
||||
handleOmittedMethods(omittedMethods, pattern, denyUncoveredHttpMethods,
|
||||
newConstraints, log);
|
||||
}
|
||||
for (Map.Entry<String, Set<String>> entry :
|
||||
urlOmittedMethodMap.entrySet()) {
|
||||
String pattern = entry.getKey();
|
||||
if (coveredPatterns.contains(pattern)) {
|
||||
// Fully covered. Ignore any partial coverage
|
||||
continue;
|
||||
}
|
||||
|
||||
handleOmittedMethods(entry.getValue(), pattern, denyUncoveredHttpMethods,
|
||||
newConstraints, log);
|
||||
}
|
||||
|
||||
return newConstraints.toArray(new SecurityConstraint[newConstraints.size()]);
|
||||
}
|
||||
|
||||
|
||||
private static void handleOmittedMethods(Set<String> omittedMethods, String pattern,
|
||||
boolean denyUncoveredHttpMethods, List<SecurityConstraint> newConstraints, Log log) {
|
||||
if (omittedMethods.size() > 0) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (String method : omittedMethods) {
|
||||
msg.append(method);
|
||||
msg.append(' ');
|
||||
}
|
||||
if (denyUncoveredHttpMethods) {
|
||||
log.info(sm.getString(
|
||||
"securityConstraint.uncoveredHttpOmittedMethodFix",
|
||||
pattern, msg.toString().trim()));
|
||||
SecurityCollection collection = new SecurityCollection();
|
||||
for (String method : omittedMethods) {
|
||||
collection.addMethod(method);
|
||||
}
|
||||
collection.addPatternDecoded(pattern);
|
||||
collection.setName("deny-uncovered-http-methods");
|
||||
SecurityConstraint constraint = new SecurityConstraint();
|
||||
constraint.setAuthConstraint(true);
|
||||
constraint.addCollection(collection);
|
||||
newConstraints.add(constraint);
|
||||
} else {
|
||||
log.error(sm.getString(
|
||||
"securityConstraint.uncoveredHttpOmittedMethod",
|
||||
pattern, msg.toString().trim()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Representation of a security role reference for a web application, as
|
||||
* represented in a <code><security-role-ref></code> element
|
||||
* in the deployment descriptor.</p>
|
||||
*
|
||||
* @since Tomcat 5.5
|
||||
*/
|
||||
public class SecurityRoleRef implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
/**
|
||||
* The (required) role name.
|
||||
*/
|
||||
private String name = null;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The optional role link.
|
||||
*/
|
||||
private String link = null;
|
||||
|
||||
public String getLink() {
|
||||
return this.link;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("SecurityRoleRef[");
|
||||
sb.append("name=");
|
||||
sb.append(name);
|
||||
if (link != null) {
|
||||
sb.append(", link=");
|
||||
sb.append(link);
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
274
java/org/apache/tomcat/util/descriptor/web/ServletDef.java
Normal file
274
java/org/apache/tomcat/util/descriptor/web/ServletDef.java
Normal file
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
|
||||
|
||||
/**
|
||||
* Representation of a servlet definition for a web application, as represented
|
||||
* in a <code><servlet></code> element in the deployment descriptor.
|
||||
*/
|
||||
|
||||
public class ServletDef implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final StringManager sm =
|
||||
StringManager.getManager(Constants.PACKAGE_NAME);
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
/**
|
||||
* The description of this servlet.
|
||||
*/
|
||||
private String description = null;
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The display name of this servlet.
|
||||
*/
|
||||
private String displayName = null;
|
||||
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The small icon associated with this servlet.
|
||||
*/
|
||||
private String smallIcon = null;
|
||||
|
||||
public String getSmallIcon() {
|
||||
return this.smallIcon;
|
||||
}
|
||||
|
||||
public void setSmallIcon(String smallIcon) {
|
||||
this.smallIcon = smallIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* The large icon associated with this servlet.
|
||||
*/
|
||||
private String largeIcon = null;
|
||||
|
||||
public String getLargeIcon() {
|
||||
return this.largeIcon;
|
||||
}
|
||||
|
||||
public void setLargeIcon(String largeIcon) {
|
||||
this.largeIcon = largeIcon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The name of this servlet, which must be unique among the servlets
|
||||
* defined for a particular web application.
|
||||
*/
|
||||
private String servletName = null;
|
||||
|
||||
public String getServletName() {
|
||||
return this.servletName;
|
||||
}
|
||||
|
||||
public void setServletName(String servletName) {
|
||||
if (servletName == null || servletName.equals("")) {
|
||||
throw new IllegalArgumentException(
|
||||
sm.getString("servletDef.invalidServletName", servletName));
|
||||
}
|
||||
this.servletName = servletName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The fully qualified name of the Java class that implements this servlet.
|
||||
*/
|
||||
private String servletClass = null;
|
||||
|
||||
public String getServletClass() {
|
||||
return this.servletClass;
|
||||
}
|
||||
|
||||
public void setServletClass(String servletClass) {
|
||||
this.servletClass = servletClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The name of the JSP file to which this servlet definition applies
|
||||
*/
|
||||
private String jspFile = null;
|
||||
|
||||
public String getJspFile() {
|
||||
return this.jspFile;
|
||||
}
|
||||
|
||||
public void setJspFile(String jspFile) {
|
||||
this.jspFile = jspFile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The set of initialization parameters for this servlet, keyed by
|
||||
* parameter name.
|
||||
*/
|
||||
private final Map<String, String> parameters = new HashMap<>();
|
||||
|
||||
public Map<String, String> getParameterMap() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an initialization parameter to the set of parameters associated
|
||||
* with this servlet.
|
||||
*
|
||||
* @param name The initialisation parameter name
|
||||
* @param value The initialisation parameter value
|
||||
*/
|
||||
public void addInitParameter(String name, String value) {
|
||||
|
||||
if (parameters.containsKey(name)) {
|
||||
// The spec does not define this but the TCK expects the first
|
||||
// definition to take precedence
|
||||
return;
|
||||
}
|
||||
parameters.put(name, value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The load-on-startup order for this servlet
|
||||
*/
|
||||
private Integer loadOnStartup = null;
|
||||
|
||||
public Integer getLoadOnStartup() {
|
||||
return this.loadOnStartup;
|
||||
}
|
||||
|
||||
public void setLoadOnStartup(String loadOnStartup) {
|
||||
this.loadOnStartup = Integer.valueOf(loadOnStartup);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The run-as configuration for this servlet
|
||||
*/
|
||||
private String runAs = null;
|
||||
|
||||
public String getRunAs() {
|
||||
return this.runAs;
|
||||
}
|
||||
|
||||
public void setRunAs(String runAs) {
|
||||
this.runAs = runAs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The set of security role references for this servlet
|
||||
*/
|
||||
private final Set<SecurityRoleRef> securityRoleRefs = new HashSet<>();
|
||||
|
||||
public Set<SecurityRoleRef> getSecurityRoleRefs() {
|
||||
return this.securityRoleRefs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a security-role-ref to the set of security-role-refs associated
|
||||
* with this servlet.
|
||||
* @param securityRoleRef The security role
|
||||
*/
|
||||
public void addSecurityRoleRef(SecurityRoleRef securityRoleRef) {
|
||||
securityRoleRefs.add(securityRoleRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* The multipart configuration, if any, for this servlet
|
||||
*/
|
||||
private MultipartDef multipartDef = null;
|
||||
|
||||
public MultipartDef getMultipartDef() {
|
||||
return this.multipartDef;
|
||||
}
|
||||
|
||||
public void setMultipartDef(MultipartDef multipartDef) {
|
||||
this.multipartDef = multipartDef;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does this servlet support async.
|
||||
*/
|
||||
private Boolean asyncSupported = null;
|
||||
|
||||
public Boolean getAsyncSupported() {
|
||||
return this.asyncSupported;
|
||||
}
|
||||
|
||||
public void setAsyncSupported(String asyncSupported) {
|
||||
this.asyncSupported = Boolean.valueOf(asyncSupported);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is this servlet enabled.
|
||||
*/
|
||||
private Boolean enabled = null;
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(String enabled) {
|
||||
this.enabled = Boolean.valueOf(enabled);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can this ServletDef be overridden by an SCI?
|
||||
*/
|
||||
private boolean overridable = false;
|
||||
|
||||
public boolean isOverridable() {
|
||||
return overridable;
|
||||
}
|
||||
|
||||
public void setOverridable(boolean overridable) {
|
||||
this.overridable = overridable;
|
||||
}
|
||||
|
||||
}
|
||||
105
java/org/apache/tomcat/util/descriptor/web/SessionConfig.java
Normal file
105
java/org/apache/tomcat/util/descriptor/web/SessionConfig.java
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
|
||||
/**
|
||||
* Representation of a session configuration element for a web application,
|
||||
* as represented in a <code><session-config></code> element in the
|
||||
* deployment descriptor.
|
||||
*/
|
||||
public class SessionConfig {
|
||||
private Integer sessionTimeout;
|
||||
private String cookieName;
|
||||
private String cookieDomain;
|
||||
private String cookiePath;
|
||||
private String cookieComment;
|
||||
private Boolean cookieHttpOnly;
|
||||
private Boolean cookieSecure;
|
||||
private Integer cookieMaxAge;
|
||||
private final EnumSet<SessionTrackingMode> sessionTrackingModes =
|
||||
EnumSet.noneOf(SessionTrackingMode.class);
|
||||
|
||||
public Integer getSessionTimeout() {
|
||||
return sessionTimeout;
|
||||
}
|
||||
public void setSessionTimeout(String sessionTimeout) {
|
||||
this.sessionTimeout = Integer.valueOf(sessionTimeout);
|
||||
}
|
||||
|
||||
public String getCookieName() {
|
||||
return cookieName;
|
||||
}
|
||||
public void setCookieName(String cookieName) {
|
||||
this.cookieName = cookieName;
|
||||
}
|
||||
|
||||
public String getCookieDomain() {
|
||||
return cookieDomain;
|
||||
}
|
||||
public void setCookieDomain(String cookieDomain) {
|
||||
this.cookieDomain = cookieDomain;
|
||||
}
|
||||
|
||||
public String getCookiePath() {
|
||||
return cookiePath;
|
||||
}
|
||||
public void setCookiePath(String cookiePath) {
|
||||
this.cookiePath = cookiePath;
|
||||
}
|
||||
|
||||
public String getCookieComment() {
|
||||
return cookieComment;
|
||||
}
|
||||
public void setCookieComment(String cookieComment) {
|
||||
this.cookieComment = cookieComment;
|
||||
}
|
||||
|
||||
public Boolean getCookieHttpOnly() {
|
||||
return cookieHttpOnly;
|
||||
}
|
||||
public void setCookieHttpOnly(String cookieHttpOnly) {
|
||||
this.cookieHttpOnly = Boolean.valueOf(cookieHttpOnly);
|
||||
}
|
||||
|
||||
public Boolean getCookieSecure() {
|
||||
return cookieSecure;
|
||||
}
|
||||
public void setCookieSecure(String cookieSecure) {
|
||||
this.cookieSecure = Boolean.valueOf(cookieSecure);
|
||||
}
|
||||
|
||||
public Integer getCookieMaxAge() {
|
||||
return cookieMaxAge;
|
||||
}
|
||||
public void setCookieMaxAge(String cookieMaxAge) {
|
||||
this.cookieMaxAge = Integer.valueOf(cookieMaxAge);
|
||||
}
|
||||
|
||||
public EnumSet<SessionTrackingMode> getSessionTrackingModes() {
|
||||
return sessionTrackingModes;
|
||||
}
|
||||
public void addSessionTrackingMode(String sessionTrackingMode) {
|
||||
sessionTrackingModes.add(
|
||||
SessionTrackingMode.valueOf(sessionTrackingMode));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import javax.servlet.descriptor.TaglibDescriptor;
|
||||
|
||||
public class TaglibDescriptorImpl implements TaglibDescriptor {
|
||||
|
||||
private final String location;
|
||||
private final String uri;
|
||||
|
||||
public TaglibDescriptorImpl(String location, String uri) {
|
||||
this.location = location;
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaglibLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaglibURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
+ ((location == null) ? 0 : location.hashCode());
|
||||
result = prime * result + ((uri == null) ? 0 : uri.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof TaglibDescriptorImpl)) {
|
||||
return false;
|
||||
}
|
||||
TaglibDescriptorImpl other = (TaglibDescriptorImpl) obj;
|
||||
if (location == null) {
|
||||
if (other.location != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!location.equals(other.location)) {
|
||||
return false;
|
||||
}
|
||||
if (uri == null) {
|
||||
if (other.uri != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!uri.equals(other.uri)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
1379
java/org/apache/tomcat/util/descriptor/web/WebRuleSet.java
Normal file
1379
java/org/apache/tomcat/util/descriptor/web/WebRuleSet.java
Normal file
File diff suppressed because it is too large
Load Diff
2394
java/org/apache/tomcat/util/descriptor/web/WebXml.java
Normal file
2394
java/org/apache/tomcat/util/descriptor/web/WebXml.java
Normal file
File diff suppressed because it is too large
Load Diff
155
java/org/apache/tomcat/util/descriptor/web/WebXmlParser.java
Normal file
155
java/org/apache/tomcat/util/descriptor/web/WebXmlParser.java
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.descriptor.DigesterFactory;
|
||||
import org.apache.tomcat.util.descriptor.InputSourceUtil;
|
||||
import org.apache.tomcat.util.descriptor.XmlErrorHandler;
|
||||
import org.apache.tomcat.util.digester.Digester;
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
public class WebXmlParser {
|
||||
|
||||
private final Log log = LogFactory.getLog(WebXmlParser.class); // must not be static
|
||||
|
||||
/**
|
||||
* The string resources for this package.
|
||||
*/
|
||||
private static final StringManager sm =
|
||||
StringManager.getManager(Constants.PACKAGE_NAME);
|
||||
|
||||
/**
|
||||
* The <code>Digester</code> we will use to process web application
|
||||
* deployment descriptor files.
|
||||
*/
|
||||
private final Digester webDigester;
|
||||
private final WebRuleSet webRuleSet;
|
||||
|
||||
/**
|
||||
* The <code>Digester</code> we will use to process web fragment
|
||||
* deployment descriptor files.
|
||||
*/
|
||||
private final Digester webFragmentDigester;
|
||||
private final WebRuleSet webFragmentRuleSet;
|
||||
|
||||
|
||||
public WebXmlParser(boolean namespaceAware, boolean validation,
|
||||
boolean blockExternal) {
|
||||
webRuleSet = new WebRuleSet(false);
|
||||
webDigester = DigesterFactory.newDigester(validation,
|
||||
namespaceAware, webRuleSet, blockExternal);
|
||||
webDigester.getParser();
|
||||
|
||||
webFragmentRuleSet = new WebRuleSet(true);
|
||||
webFragmentDigester = DigesterFactory.newDigester(validation,
|
||||
namespaceAware, webFragmentRuleSet, blockExternal);
|
||||
webFragmentDigester.getParser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a web descriptor at a location.
|
||||
*
|
||||
* @param url the location; if null no load will be attempted
|
||||
* @param dest the instance to be populated by the parse operation
|
||||
* @param fragment indicate if the descriptor is a web-app or web-fragment
|
||||
* @return true if the descriptor was successfully parsed
|
||||
* @throws IOException if there was a problem reading from the URL
|
||||
*/
|
||||
public boolean parseWebXml(URL url, WebXml dest, boolean fragment) throws IOException {
|
||||
if (url == null) {
|
||||
return true;
|
||||
}
|
||||
InputSource source = new InputSource(url.toExternalForm());
|
||||
source.setByteStream(url.openStream());
|
||||
return parseWebXml(source, dest, fragment);
|
||||
}
|
||||
|
||||
|
||||
public boolean parseWebXml(InputSource source, WebXml dest,
|
||||
boolean fragment) {
|
||||
|
||||
boolean ok = true;
|
||||
|
||||
if (source == null) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
XmlErrorHandler handler = new XmlErrorHandler();
|
||||
|
||||
Digester digester;
|
||||
WebRuleSet ruleSet;
|
||||
if (fragment) {
|
||||
digester = webFragmentDigester;
|
||||
ruleSet = webFragmentRuleSet;
|
||||
} else {
|
||||
digester = webDigester;
|
||||
ruleSet = webRuleSet;
|
||||
}
|
||||
|
||||
digester.push(dest);
|
||||
digester.setErrorHandler(handler);
|
||||
|
||||
if(log.isDebugEnabled()) {
|
||||
log.debug(sm.getString("webXmlParser.applicationStart",
|
||||
source.getSystemId()));
|
||||
}
|
||||
|
||||
try {
|
||||
digester.parse(source);
|
||||
|
||||
if (handler.getWarnings().size() > 0 ||
|
||||
handler.getErrors().size() > 0) {
|
||||
ok = false;
|
||||
handler.logFindings(log, source.getSystemId());
|
||||
}
|
||||
} catch (SAXParseException e) {
|
||||
log.error(sm.getString("webXmlParser.applicationParse",
|
||||
source.getSystemId()), e);
|
||||
log.error(sm.getString("webXmlParser.applicationPosition",
|
||||
"" + e.getLineNumber(),
|
||||
"" + e.getColumnNumber()));
|
||||
ok = false;
|
||||
} catch (Exception e) {
|
||||
log.error(sm.getString("webXmlParser.applicationParse",
|
||||
source.getSystemId()), e);
|
||||
ok = false;
|
||||
} finally {
|
||||
InputSourceUtil.close(source);
|
||||
digester.reset();
|
||||
ruleSet.recycle();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the ClassLoader to be used for creating descriptor objects.
|
||||
* @param classLoader the ClassLoader to be used for creating descriptor objects
|
||||
*/
|
||||
public void setClassLoader(ClassLoader classLoader) {
|
||||
webDigester.setClassLoader(classLoader);
|
||||
webFragmentDigester.setClassLoader(classLoader);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.tomcat.util.descriptor.web;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.buf.B2CConverter;
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
|
||||
/**
|
||||
* Base class for those elements that need to track the encoding used in the
|
||||
* source XML.
|
||||
*/
|
||||
public abstract class XmlEncodingBase {
|
||||
|
||||
private static final StringManager sm = StringManager.getManager(XmlEncodingBase.class);
|
||||
private static Log log = LogFactory.getLog(XmlEncodingBase.class);
|
||||
private Charset charset = StandardCharsets.UTF_8;
|
||||
|
||||
|
||||
/**
|
||||
* @param encoding The encoding of the XML source that was used to
|
||||
* populated this object.
|
||||
* @deprecated This method will be removed in Tomcat 9
|
||||
*/
|
||||
@Deprecated
|
||||
public void setEncoding(String encoding) {
|
||||
try {
|
||||
charset = B2CConverter.getCharset(encoding);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.warn(sm.getString("xmlEncodingBase.encodingInvalid", encoding, charset.name()), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain the encoding of the XML source that was used to populated this
|
||||
* object.
|
||||
*
|
||||
* @return The encoding of the associated XML source or <code>UTF-8</code>
|
||||
* if the encoding could not be determined
|
||||
* @deprecated This method will be removed in Tomcat 9
|
||||
*/
|
||||
@Deprecated
|
||||
public String getEncoding() {
|
||||
return charset.name();
|
||||
}
|
||||
|
||||
|
||||
public void setCharset(Charset charset) {
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain the character encoding of the XML source that was used to
|
||||
* populated this object.
|
||||
*
|
||||
* @return The character encoding of the associated XML source or
|
||||
* <code>UTF-8</code> if the encoding could not be determined
|
||||
*/
|
||||
public Charset getCharset() {
|
||||
return charset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<mbeans-descriptors>
|
||||
|
||||
<mbean name="ContextEnvironment"
|
||||
className="org.apache.catalina.mbeans.ContextEnvironmentMBean"
|
||||
description="Representation of an application environment entry"
|
||||
domain="Catalina"
|
||||
group="Resources"
|
||||
type="org.apache.tomcat.util.descriptor.web.ContextEnvironment">
|
||||
|
||||
<attribute name="className"
|
||||
description="Fully qualified class name of the managed object"
|
||||
type="java.lang.String"
|
||||
writeable="false"/>
|
||||
|
||||
<attribute name="description"
|
||||
description="The description of this environment entry"
|
||||
type="java.lang.String"/>
|
||||
|
||||
<attribute name="name"
|
||||
description="The name of this environment entry"
|
||||
type="java.lang.String"/>
|
||||
|
||||
<attribute name="override"
|
||||
description="Does this environment entry allow overrides by the
|
||||
application deployment descriptor"
|
||||
type="boolean"/>
|
||||
|
||||
<attribute name="type"
|
||||
description="The type of this environment entry"
|
||||
type="java.lang.String"/>
|
||||
|
||||
<attribute name="value"
|
||||
description="The value of this environment entry"
|
||||
type="java.lang.String"/>
|
||||
</mbean>
|
||||
|
||||
|
||||
<mbean name="ContextResource"
|
||||
className="org.apache.catalina.mbeans.ContextResourceMBean"
|
||||
description="Representation of a resource reference for a web application"
|
||||
domain="Catalina"
|
||||
group="Resources"
|
||||
type="org.apache.tomcat.util.descriptor.web.ContextResource">
|
||||
|
||||
<attribute name="auth"
|
||||
description="The authorization requirement for this resource"
|
||||
type="java.lang.String"/>
|
||||
|
||||
<attribute name="description"
|
||||
description="The description of this resource"
|
||||
type="java.lang.String"/>
|
||||
|
||||
<attribute name="name"
|
||||
description="The name of this resource"
|
||||
type="java.lang.String"/>
|
||||
|
||||
<attribute name="scope"
|
||||
description="The sharing scope of this resource factory"
|
||||
type="java.lang.String"/>
|
||||
|
||||
<attribute name="type"
|
||||
description="The type of this environment entry"
|
||||
type="java.lang.String"/>
|
||||
</mbean>
|
||||
|
||||
|
||||
<mbean name="ContextResourceLink"
|
||||
className="org.apache.catalina.mbeans.ContextResourceLinkMBean"
|
||||
description="Representation of a resource link for a web application"
|
||||
domain="Catalina"
|
||||
group="Resources"
|
||||
type="org.apache.tomcat.util.descriptor.web.ContextResourceLink">
|
||||
|
||||
<attribute name="global"
|
||||
description="The global name of this resource"
|
||||
type="java.lang.String"/>
|
||||
|
||||
<attribute name="name"
|
||||
description="The name of this resource"
|
||||
type="java.lang.String"/>
|
||||
|
||||
<attribute name="description"
|
||||
description="The description of this resource"
|
||||
type="java.lang.String"/>
|
||||
|
||||
<attribute name="type"
|
||||
description="The type of this resource"
|
||||
type="java.lang.String"/>
|
||||
|
||||
</mbean>
|
||||
|
||||
|
||||
</mbeans-descriptors>
|
||||
26
java/org/apache/tomcat/util/descriptor/web/package.html
Normal file
26
java/org/apache/tomcat/util/descriptor/web/package.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<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>
|
||||
Reference in New Issue
Block a user