This commit is contained in:
2024-11-30 19:03:49 +08:00
commit 1e6763c160
3806 changed files with 737676 additions and 0 deletions

View 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);
}

View 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;
}
}

View 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);
}
}
}
}

View 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;
}
}

View 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.
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}].

View File

@@ -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}].

View 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.
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}]

View 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.
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}]を処理中

View 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.
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}]

View 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.
digesterFactory.missingSchema=XML模型[{0}]未找到如果XML校验功能开启了的话这很可能终止XML校验

View 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));
}
}
}

View 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() {
}
}

View File

@@ -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);
}
}
}

View File

@@ -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));
}
}
}

View 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=The element [{0}] is not permitted in an implicit.tld file

View 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

View 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=要素[{0}]は、implicit.tldファイルでは許可されていません。

View 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=implicit.tld 파일 내에서, 엘리먼트 [{0}]은(는) 허용되지 않습니다.

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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);
}
}

View 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;
}
}

View 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));
}
}
}

View 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;
}
}

View 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;

View File

@@ -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();
}
}

View 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";
}

View 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>&lt;ejb-ref&gt;</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;
}
}

View File

@@ -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>&lt;env-entry&gt;</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;
}
}

View 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>&lt;handler&gt;</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;
}
}

View 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>&lt;ejb-local-ref&gt;</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;
}
}

View 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>&lt;resource-ref&gt;</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;
}
}

View File

@@ -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>&lt;res-env-refy&gt;</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;
}
}

View File

@@ -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>&lt;ResourceLink&gt;</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;
}
}

View 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>&lt;service-ref&gt;</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;
}
}

View File

@@ -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>&lt;res-env-refy&gt;</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();
}
}

View 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>&lt;error-page&gt;</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;
}
}
}

View 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>&lt;filter&gt;</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();
}
}

View 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>&lt;filter-mapping&gt;</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();
}
}

View File

@@ -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;
}
}

View 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();
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View 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;
}
}

View File

@@ -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());
}
}

View File

@@ -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

View File

@@ -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}]

View File

@@ -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}]

View File

@@ -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}]

Some files were not shown because too many files have changed in this diff Show More