diff --git a/appserver/featuresets/debug/pom.xml b/appserver/featuresets/debug/pom.xml
index 03e577ac547..fd8c813ab4a 100644
--- a/appserver/featuresets/debug/pom.xml
+++ b/appserver/featuresets/debug/pom.xml
@@ -62,6 +62,27 @@
org.apache.felixorg.apache.felix.framework
+
+
+ org.glassfish.grizzly
+ grizzly-framework
+
+
+ org.glassfish.grizzly
+ grizzly-portunif
+
+
+ org.glassfish.grizzly
+ grizzly-http
+
+
+ org.glassfish.grizzly
+ grizzly-http2
+
+
+ org.glassfish.grizzly
+ grizzly-http-server
+ org.glassfish.main.featuresets
diff --git a/appserver/tests/tck/servlet/pom.xml b/appserver/tests/tck/servlet/pom.xml
new file mode 100644
index 00000000000..2f4fd6ed64d
--- /dev/null
+++ b/appserver/tests/tck/servlet/pom.xml
@@ -0,0 +1,320 @@
+
+
+
+
+ 4.0.0
+
+
+ org.glassfish.main.tests.tck
+ tck
+ 7.0.0-SNAPSHOT
+
+
+ glassfish-external-tck-servlet
+ pom
+
+ TCK: servlet
+
+
+ ${project.build.directory}/apache-ant-${ant.version}
+ https://archive.apache.org/dist/ant/binaries/apache-ant-${ant.version}-bin.zip
+
+ ${project.build.directory}/servlet-tck
+ ${tck.home}/src/com/sun/ts/tests
+
+ ${project.build.directory}/glassfish7
+ ${project.version}
+ ${glassfish.home}/glassfish/bin/asadmin
+
+ org/glassfish/**\:com/sun/enterprise/**
+
+ 14848
+ 11527
+ 18080
+ 18181
+ 17676
+ 18686
+ 13700
+ 13920
+ 13820
+ 12000
+
+
+
+
+ org.glassfish.main.distributions
+ glassfish
+ ${glassfish.version}
+ zip
+ test
+
+
+ org.glassfish.main.tests.tck
+ jakarta-servlet-tck
+ ${project.version}
+ zip
+
+
+
+
+
+
+ com.googlecode.maven-download-plugin
+ download-maven-plugin
+
+
+ download-ant
+ generate-resources
+
+ wget
+
+
+
+
+ ${skipITs}
+ ${ant.zip.url}
+ true
+ ${project.build.directory}
+
+
+
+
+ maven-dependency-plugin
+
+ ${skipITs}
+
+
+
+ unpack-glassfish
+ pre-integration-test
+
+ unpack-dependencies
+
+
+ glassfish
+ ${project.build.directory}
+
+
+
+ unpack-tck
+ pre-integration-test
+
+ unpack-dependencies
+
+
+ jakarta-servlet-tck
+ ${project.build.directory}
+
+
+
+
+
+
+ maven-antrun-plugin
+
+
+ org.apache.ant
+ ant
+ ${ant.version}
+
+
+ ant-contrib
+ ant-contrib
+ 1.0b3
+
+
+ ant
+ ant
+
+
+
+
+
+ ${skipITs}
+
+
+
+ prepare-tck-and-glassfish
+ pre-integration-test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ]]>
+
+ ]]>
+
+
+
+ ]]>
+
+ ]]>
+
+
+
+
+ run
+
+
+
+
+ configure-tck-tests
+ pre-integration-test
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Deploying from ${test.dir}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ run-tck-tests
+ integration-test
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/appserver/tests/tck/tck-download/jakarta-servlet-tck/pom.xml b/appserver/tests/tck/tck-download/jakarta-servlet-tck/pom.xml
new file mode 100644
index 00000000000..4afc4bc1282
--- /dev/null
+++ b/appserver/tests/tck/tck-download/jakarta-servlet-tck/pom.xml
@@ -0,0 +1,82 @@
+
+
+
+ 4.0.0
+
+ org.glassfish.main.tests.tck
+ tck-download
+ 7.0.0-SNAPSHOT
+
+
+ jakarta-servlet-tck
+ pom
+ TCK: Install Jakarta servlet TCK
+
+
+ jakarta-servlet-tck-6.0.0.zip
+ https://download.eclipse.org/ee4j/jakartaee-tck/jakartaee10/staged/eftl/${tck.test.servlet.file}
+
+
+
+
+
+ com.googlecode.maven-download-plugin
+ download-maven-plugin
+
+
+ download-servlet-tck
+ generate-resources
+
+ wget
+
+
+
+
+ ${tck.test.servlet.url}
+ false
+ ${project.build.directory}
+
+
+
+ maven-install-plugin
+
+
+ install-servlet-tck
+ process-resources
+
+ install-file
+
+
+ ${project.build.directory}/${tck.test.servlet.file}
+ ${project.groupId}
+ ${project.artifactId}
+ ${project.version}
+ zip
+ true
+
+
+
+
+
+
+
+
diff --git a/appserver/web/web-core/src/main/java/com/sun/enterprise/web/connector/grizzly/CoyoteConnectorLauncher.java b/appserver/web/web-core/src/main/java/com/sun/enterprise/web/connector/grizzly/CoyoteConnectorLauncher.java
index 4a0d797ba79..1d15f6a8bde 100644
--- a/appserver/web/web-core/src/main/java/com/sun/enterprise/web/connector/grizzly/CoyoteConnectorLauncher.java
+++ b/appserver/web/web-core/src/main/java/com/sun/enterprise/web/connector/grizzly/CoyoteConnectorLauncher.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
@@ -25,68 +26,49 @@
import org.glassfish.grizzly.http.server.HttpHandler;
/**
- * Abstract the protocol implementation, including threading, etc.
- * Processor is single threaded and specific to stream-based protocols,
- * will not fit Jk protocols like JNI.
+ * Abstract the protocol implementation, including threading, etc. Processor is single threaded and specific to
+ * stream-based protocols, will not fit Jk protocols like JNI.
*
* @author Remy Maucherat
* @author Costin Manolache
*/
-public class CoyoteConnectorLauncher implements ProtocolHandler
-{
- // START SJSAS 6439313
- protected boolean blocking = false;
- // END SJSAS 6439313
+public class CoyoteConnectorLauncher implements ProtocolHandler {
+ protected boolean blocking;
/**
- * The SelectorThread implementation class. Not used when
- * Coyote is used.
+ * The SelectorThread implementation class. Not used when Coyote is used.
*/
- protected String selectorThreadImpl = null;
-
+ protected String selectorThreadImpl;
public CoyoteConnectorLauncher() {
- // START SJSAS 6439313
- this(false,false,null);
+ this(false, false, null);
}
-
- public CoyoteConnectorLauncher(boolean secure, boolean blocking,
- String selectorThreadImpl) {
+ public CoyoteConnectorLauncher(boolean secure, boolean blocking, String selectorThreadImpl) {
this.secure = secure;
this.blocking = blocking;
this.selectorThreadImpl = selectorThreadImpl;
}
-
public int getMaxHttpHeaderSize() {
return maxHttpHeaderSize;
}
-
public void setMaxHttpHeaderSize(int valueI) {
maxHttpHeaderSize = valueI;
setAttribute("maxHttpHeaderSize", "" + valueI);
}
-
- /** Pass config info
+ /**
+ * Pass config info
*/
@Override
- public void setAttribute( String name, Object value ) {
-
+ public void setAttribute(String name, Object value) {
attributes.put(name, value);
-/*
- if ("maxKeepAliveRequests".equals(name)) {
- maxKeepAliveRequests = Integer.parseInt((String) value.toString());
- } else if ("port".equals(name)) {
- setPort(Integer.parseInt((String) value.toString()));
- }
-*/
}
@Override
- public Object getAttribute( String key ) {
+ public Object getAttribute(String key) {
return attributes.get(key);
}
@@ -101,14 +83,15 @@ public void setProperty(String name, String value) {
* Get a property
*/
public String getProperty(String name) {
- return (String)getAttribute(name);
+ return (String) getAttribute(name);
}
- /** The adapter, used to call the connector
+ /**
+ * The adapter, used to call the connector
*/
@Override
public void setHandler(HttpHandler adapter) {
- this.adapter=adapter;
+ this.adapter = adapter;
}
@Override
@@ -116,8 +99,8 @@ public HttpHandler getHandler() {
return adapter;
}
-
- /** Start the protocol
+ /**
+ * Start the protocol
*/
@Override
public void init() throws Exception {
@@ -138,24 +121,22 @@ public void destroy() throws Exception {
// socket factory attributes ( XXX replace with normal setters )
protected Map attributes = new HashMap<>();
- protected String socketFactoryName=null;
- protected String sslImplementationName=null;
+ protected String socketFactoryName = null;
+ protected String sslImplementationName = null;
- private int maxKeepAliveRequests=100; // as in Apache HTTPD server
- protected int timeout = 300000; // 5 minutes as in Apache HTTPD server
+ private int maxKeepAliveRequests = 100; // as in Apache HTTPD server
+ protected int timeout = 300000; // 5 minutes as in Apache HTTPD server
protected int maxPostSize = 2 * 1024 * 1024;
protected int maxHttpHeaderSize = 4 * 1024;
private String reportedname;
- protected int socketCloseDelay=-1;
+ protected int socketCloseDelay = -1;
protected boolean disableUploadTimeout = true;
protected HttpHandler adapter;
- // START OF SJSAS PE 8.1 6172948
/**
* The input request buffer size.
*/
protected int requestBufferSize = 4096;
- // END OF SJSAS PE 8.1 6172948
/**
* Compression value.
@@ -164,12 +145,11 @@ public void destroy() throws Exception {
// -------------------- Pool setup --------------------
-
public String getSocketFactory() {
return socketFactoryName;
}
- public void setSocketFactory( String valueS ) {
+ public void setSocketFactory(String valueS) {
socketFactoryName = valueS;
setAttribute("socketFactory", valueS);
}
@@ -178,8 +158,8 @@ public String getSSLImplementation() {
return sslImplementationName;
}
- public void setSSLImplementation( String valueS) {
- sslImplementationName=valueS;
+ public void setSSLImplementation(String valueS) {
+ sslImplementationName = valueS;
setAttribute("sslImplementation", valueS);
}
@@ -213,7 +193,7 @@ public String getKeystore() {
return getProperty("keystore");
}
- public void setKeystore( String k ) {
+ public void setKeystore(String k) {
setAttribute("keystore", k);
}
@@ -221,20 +201,18 @@ public String getKeypass() {
return getProperty("keypass");
}
- public void setKeypass( String k ) {
+ public void setKeypass(String k) {
attributes.put("keypass", k);
- //setAttribute("keypass", k);
}
public String getKeytype() {
return getProperty("keystoreType");
}
- public void setKeytype( String k ) {
+ public void setKeytype(String k) {
setAttribute("keystoreType", k);
}
- // START GlassFish Issue 657
public void setTruststore(String truststore) {
setAttribute("truststore", truststore);
}
@@ -242,13 +220,12 @@ public void setTruststore(String truststore) {
public void setTruststoreType(String truststoreType) {
setAttribute("truststoreType", truststoreType);
}
- // END GlassFish Issue 657
public String getClientauth() {
return getProperty("clientauth");
}
- public void setClientauth( String k ) {
+ public void setClientauth(String k) {
setAttribute("clientauth", k);
}
@@ -256,7 +233,7 @@ public String getProtocol() {
return getProperty("protocol");
}
- public void setProtocol( String k ) {
+ public void setProtocol(String k) {
setAttribute("protocol", k);
}
@@ -272,7 +249,7 @@ public String getAlgorithm() {
return getProperty("algorithm");
}
- public void setAlgorithm( String k ) {
+ public void setAlgorithm(String k) {
setAttribute("algorithm", k);
}
@@ -280,21 +257,19 @@ public boolean getSecure() {
return secure;
}
- public void setSecure( boolean b ) {
- secure=b;
+ public void setSecure(boolean b) {
+ secure = b;
setAttribute("secure", "" + b);
}
- // START SJSAS 6439313
public boolean getBlocking() {
return blocking;
}
- public void setBlocking( boolean b ) {
- blocking=b;
+ public void setBlocking(boolean b) {
+ blocking = b;
setAttribute("blocking", "" + b);
}
- // END SJSAS 6439313
public String getCiphers() {
return getProperty("ciphers");
@@ -316,7 +291,8 @@ public int getMaxKeepAliveRequests() {
return maxKeepAliveRequests;
}
- /** Set the maximum number of Keep-Alive requests that we will honor.
+ /**
+ * Set the maximum number of Keep-Alive requests that we will honor.
*/
public void setMaxKeepAliveRequests(int mkar) {
maxKeepAliveRequests = mkar;
@@ -327,15 +303,13 @@ public int getSocketCloseDelay() {
return socketCloseDelay;
}
- public void setSocketCloseDelay( int d ) {
- socketCloseDelay=d;
+ public void setSocketCloseDelay(int d) {
+ socketCloseDelay = d;
setAttribute("socketCloseDelay", "" + d);
}
- protected static ServerSocketFactory string2SocketFactory(String val)
- throws ClassNotFoundException, IllegalAccessException, InstantiationException {
- Class chC = Class.forName(val);
- return (ServerSocketFactory) chC.newInstance();
+ protected static ServerSocketFactory string2SocketFactory(String val) throws ReflectiveOperationException, IllegalArgumentException, SecurityException {
+ return (ServerSocketFactory) Class.forName(val).getDeclaredConstructor().newInstance();
}
public int getTimeout() {
@@ -355,7 +329,6 @@ public void setReportedname(String reportedName) {
reportedname = reportedName;
}
- // START OF SJSAS PE 8.1 6172948
/**
* Set the request input buffer size
*/
@@ -363,12 +336,10 @@ public void setBufferSize(int requestBufferSize) {
this.requestBufferSize = requestBufferSize;
}
-
/**
* Return the request input buffer size
*/
- public int getBufferSize(){
+ public int getBufferSize() {
return requestBufferSize;
}
- // END OF SJSAS PE 8.1 6172948
}
diff --git a/appserver/web/web-core/src/main/java/com/sun/enterprise/web/connector/grizzly/DummyConnectorLauncher.java b/appserver/web/web-core/src/main/java/com/sun/enterprise/web/connector/grizzly/DummyConnectorLauncher.java
index c13dd4f2b66..c18daa5724b 100644
--- a/appserver/web/web-core/src/main/java/com/sun/enterprise/web/connector/grizzly/DummyConnectorLauncher.java
+++ b/appserver/web/web-core/src/main/java/com/sun/enterprise/web/connector/grizzly/DummyConnectorLauncher.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
@@ -18,8 +19,7 @@
package com.sun.enterprise.web.connector.grizzly;
/**
- * Dummy Connector Launcher that doesn't start any listener like Grizzly
- * or Coyote.
+ * Dummy Connector Launcher that doesn't start any listener like Grizzly or Coyote.
*
* @author Jean-Francois Arcand
*/
@@ -27,9 +27,8 @@ public class DummyConnectorLauncher extends CoyoteConnectorLauncher {
// ------------------------------------------------------- Constructor --//
- public DummyConnectorLauncher(boolean secure, boolean blocking,
- String selectorThreadImpl) {
- super(secure,blocking,selectorThreadImpl);
+ public DummyConnectorLauncher(boolean secure, boolean blocking, String selectorThreadImpl) {
+ super(secure, blocking, selectorThreadImpl);
}
/**
@@ -39,17 +38,12 @@ public DummyConnectorLauncher(boolean secure, boolean blocking,
public void init() throws Exception {
}
-
@Override
public void start() throws Exception {
}
-
@Override
public void destroy() throws Exception {
}
-
-
}
-
diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/ClientAbortException.java b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/ClientAbortException.java
index 9bbedfbdd97..cd8a3a7a16d 100644
--- a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/ClientAbortException.java
+++ b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/ClientAbortException.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
@@ -20,18 +21,16 @@
import java.io.IOException;
/**
- * Wrap an IOException identifying it as being caused by an abort
- * of a request by a remote client.
+ * Wrap an IOException identifying it as being caused by an abort of a request by a remote client.
*
* @author Glenn L. Nielsen
* @version $Revision: 1.3 $ $Date: 2005/12/08 01:27:28 $
*/
-
public final class ClientAbortException extends IOException {
+ private static final long serialVersionUID = 1L;
- //------------------------------------------------------------ Constructors
-
+ // ------------------------------------------------------------ Constructors
/**
* Construct a new ClientAbortException with no other information.
@@ -40,7 +39,6 @@ public ClientAbortException() {
super();
}
-
/**
* Construct a new ClientAbortException for the specified message.
*
@@ -50,7 +48,6 @@ public ClientAbortException(String message) {
super(message);
}
-
/**
* Construct a new ClientAbortException for the specified throwable.
*
@@ -60,10 +57,8 @@ public ClientAbortException(Throwable throwable) {
super(throwable);
}
-
/**
- * Construct a new ClientAbortException for the specified message
- * and throwable.
+ * Construct a new ClientAbortException for the specified message and throwable.
*
* @param message Message describing this exception
* @param throwable Throwable that caused this exception
diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Connector.java b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Connector.java
index 2c9a6ade000..83dc83e22db 100644
--- a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Connector.java
+++ b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Connector.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
@@ -17,7 +18,15 @@
package org.apache.catalina.connector;
-import com.sun.appserv.ProxyHandler;
+import static java.util.logging.Level.FINE;
+import static java.util.logging.Level.INFO;
+import static java.util.logging.Level.WARNING;
+import static org.apache.catalina.Globals.CERTIFICATES_ATTR;
+import static org.apache.catalina.Globals.SSL_CERTIFICATE_ATTR;
+import static org.apache.catalina.LogFacade.CONNECTOR_BEEN_STARTED;
+import static org.apache.catalina.LogFacade.CONNECTOR_NOT_BEEN_STARTED;
+import static org.apache.catalina.LogFacade.PROTOCOL_HANDLER_DESTROY_FAILED_EXCEPTION;
+import static org.apache.catalina.LogFacade.PROTOCOL_HANDLER_START_FAILED_EXCEPTION;
import java.lang.reflect.Constructor;
import java.net.URLEncoder;
@@ -37,7 +46,6 @@
import org.apache.catalina.Container;
import org.apache.catalina.Context;
-import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
@@ -51,6 +59,8 @@
import org.glassfish.grizzly.http.server.util.Mapper;
import org.glassfish.web.util.IntrospectionUtils;
+import com.sun.appserv.ProxyHandler;
+
import jakarta.servlet.http.HttpServletRequest;
/**
@@ -60,9 +70,7 @@
* @author Remy Maucherat
* @version $Revision: 1.23 $ $Date: 2007/07/09 20:46:45 $
*/
-public class Connector
- implements org.apache.catalina.Connector, Lifecycle
-{
+public class Connector implements org.apache.catalina.Connector, Lifecycle {
private static final Logger log = LogFacade.getLogger();
private static final ResourceBundle rb = log.getResourceBundle();
@@ -70,14 +78,11 @@ public class Connector
// START SJSAS 6363251
/**
- * Coyote Adapter class name.
- * Defaults to the CoyoteAdapter.
+ * Coyote Adapter class name. Defaults to the CoyoteAdapter.
*/
- private String defaultClassName =
- "org.apache.catalina.connector.CoyoteAdapter";
+ private String defaultClassName = "org.apache.catalina.connector.CoyoteAdapter";
// END SJSAS 6363251
-
// ----------------------------------------------------- Instance Variables
/**
@@ -88,7 +93,7 @@ public class Connector
/**
* The Service we are associated with (if any).
*/
- private Service service = null;
+ private Service service;
/**
* The accept count for this Connector.
@@ -96,10 +101,9 @@ public class Connector
private int acceptCount = 10;
/**
- * The IP address on which to bind, if any. If null, all
- * addresses on the server will be bound.
+ * The IP address on which to bind, if any. If null, all addresses on the server will be bound.
*/
- private String address = null;
+ private String address;
/**
* Do we allow TRACE ?
@@ -114,7 +118,7 @@ public class Connector
/**
* The Container used for processing requests received by this Connector.
*/
- protected Container container = null;
+ protected Container container;
/**
* Compression value.
@@ -129,12 +133,12 @@ public class Connector
/**
* The "enable DNS lookups" flag for this Connector.
*/
- private boolean enableLookups = false;
+ private boolean enableLookups;
/**
* The server socket factory for this component.
*/
- private ServerSocketFactory factory = null;
+ private ServerSocketFactory factory;
/**
* Maximum size of a HTTP header. 4KB is the default.
@@ -149,8 +153,7 @@ public class Connector
/**
* Descriptive information about this Connector implementation.
*/
- private static final String info =
- "org.apache.catalina.connector.Connector/2.0";
+ private static final String info = "org.apache.catalina.connector.Connector/2.0";
/**
* The lifecycle event support for this component.
@@ -168,27 +171,22 @@ public class Connector
private int maxProcessors = 20;
/**
- * Linger value on the incoming connection.
- * Note : a value inferior to 0 means no linger.
+ * Linger value on the incoming connection. Note : a value inferior to 0 means no linger.
*/
private int connectionLinger = Constants.DEFAULT_CONNECTION_LINGER;
/**
- * Timeout value on the incoming connection.
- * Note : a value of 0 means no timeout.
+ * Timeout value on the incoming connection. Note : a value of 0 means no timeout.
*/
private int connectionTimeout = Constants.DEFAULT_CONNECTION_TIMEOUT;
/**
- * Timeout value on the incoming connection during request processing.
- * Note : a value of 0 means no timeout.
+ * Timeout value on the incoming connection during request processing. Note : a value of 0 means no timeout.
*/
- private int connectionUploadTimeout =
- Constants.DEFAULT_CONNECTION_UPLOAD_TIMEOUT;
+ private int connectionUploadTimeout = Constants.DEFAULT_CONNECTION_UPLOAD_TIMEOUT;
/**
- * Timeout value on the server socket.
- * Note : a value of 0 means no timeout.
+ * Timeout value on the server socket. Note : a value of 0 means no timeout.
*/
private int serverSocketTimeout = Constants.DEFAULT_SERVER_SOCKET_TIMEOUT;
@@ -198,18 +196,16 @@ public class Connector
private int port = 8080;
/**
- * The server name to which we should pretend requests to this Connector
- * were directed. This is useful when operating Tomcat behind a proxy
- * server, so that redirects get constructed accurately. If not specified,
- * the server name included in the Host header is used.
+ * The server name to which we should pretend requests to this Connector were directed. This is useful when operating
+ * Tomcat behind a proxy server, so that redirects get constructed accurately. If not specified, the server name
+ * included in the Host header is used.
*/
- private String proxyName = null;
+ private String proxyName;
/**
- * The server port to which we should pretend requests to this Connector
- * were directed. This is useful when operating Tomcat behind a proxy
- * server, so that redirects get constructed accurately. If not specified,
- * the port number specified by the port property is used.
+ * The server port to which we should pretend requests to this Connector were directed. This is useful when operating
+ * Tomcat behind a proxy server, so that redirects get constructed accurately. If not specified, the port number
+ * specified by the port property is used.
*/
private int proxyPort = 0;
@@ -218,44 +214,34 @@ public class Connector
*/
private int redirectPort = 443;
- // BEGIN S1AS 5000999
/**
* The default host.
*/
private String defaultHost;
- // END S1AS 5000999
/**
- * The request scheme that will be set on all requests received
- * through this connector.
+ * The request scheme that will be set on all requests received through this connector.
*/
private String scheme = "http";
/**
- * The secure connection flag that will be set on all requests received
- * through this connector.
+ * The secure connection flag that will be set on all requests received through this connector.
*/
private boolean secure = false;
- // START SJSAS 6439313
/**
- * The blocking connection flag that will be set on all requests received
- * through this connector.
+ * The blocking connection flag that will be set on all requests received through this connector.
*/
private boolean blocking = false;
- // END SJSAS 6439313
- /** For jk, do tomcat authentication if true, trust server if false
+ /**
+ * For jk, do tomcat authentication if true, trust server if false
*/
private boolean tomcatAuthentication = true;
-
-
/**
- * Flag to disable setting a seperate time-out for uploads.
- * If true, then the timeout parameter is
- * ignored. If false, then the timeout
- * parameter is used to control uploads.
+ * Flag to disable setting a seperate time-out for uploads. If true, then the timeout
+ * parameter is ignored. If false, then the timeout parameter is used to control uploads.
*/
private boolean disableUploadTimeout = true;
@@ -265,14 +251,12 @@ public class Connector
private int maxKeepAliveRequests = 100;
/**
- * Maximum size of a POST which will be automatically parsed by the
- * container. 2MB by default.
+ * Maximum size of a POST which will be automatically parsed by the container. 2MB by default.
*/
private int maxPostSize = 2 * 1024 * 1024;
/**
- * Maximum size of a POST which will be saved by the container
- * during authentication. 4kB by default
+ * Maximum size of a POST which will be saved by the container during authentication. 4kB by default
*/
protected int maxSavePostSize = 4 * 1024;
@@ -286,32 +270,20 @@ public class Connector
*/
private boolean started = false;
- /**
- * The shutdown signal to our background thread
- */
- private boolean stopped = false;
-
- /**
- * The background thread.
- */
- private Thread thread = null;
-
/**
* Use TCP no delay ?
*/
private boolean tcpNoDelay = true;
/**
- * Coyote Protocol handler class name.
- * Defaults to the Coyote HTTP/1.1 protocolHandler.
+ * Coyote Protocol handler class name. Defaults to the Coyote HTTP/1.1 protocolHandler.
*/
- private String protocolHandlerClassName =
- "com.sun.enterprise.web.connector.grizzly.CoyoteConnectorLauncher";
+ private String protocolHandlerClassName = "com.sun.enterprise.web.connector.grizzly.CoyoteConnectorLauncher";
/**
* Coyote protocol handler.
*/
- private ProtocolHandler protocolHandler = null;
+ private ProtocolHandler protocolHandler;
private String instanceName;
@@ -320,7 +292,7 @@ public class Connector
*/
private String name;
- private HttpHandler handler = null;
+ private HttpHandler handler;
/**
* Mapper.
@@ -330,31 +302,21 @@ public class Connector
/**
* URI encoding.
*/
- /* GlassFish Issue 2339
- private String uriEncoding = null;
- */
- // START GlassFish Issue 2339
private String uriEncoding = "UTF-8";
- // END GlassFish Issue 2339
- // START SJSAS 6331392
private boolean enabled = true;
- // END SJSAS 6331392
- // START S1AS 6188932
/**
- * Flag indicating whether this connector is receiving its requests from
- * a trusted intermediate server
+ * Flag indicating whether this connector is receiving its requests from a trusted intermediate server
*/
protected boolean authPassthroughEnabled = false;
- protected ProxyHandler proxyHandler = null;
- // END S1AS 6188932
+ protected ProxyHandler proxyHandler;
/**
* The SelectorThread implementation class.
*/
- private String selectorThreadImpl = null;
+ private String selectorThreadImpl;
private String jvmRoute;
@@ -409,8 +371,7 @@ public String getCompression() {
/**
* Set the value of compression.
*
- * @param compression The new compression value, which can be "on", "off"
- * or "force"
+ * @param compression The new compression value, which can be "on", "off" or "force"
*/
public void setCompression(String compression) {
this.compression = compression;
@@ -520,7 +481,7 @@ public void setAddress(String address) {
}
/**
- * True if the TRACE method is allowed. Default value is "false".
+ * True if the TRACE method is allowed. Default value is "false".
*/
public boolean getAllowTrace() {
return allowTrace;
@@ -561,8 +522,7 @@ public void setBufferSize(int bufferSize) {
}
/**
- * Return the Container used for processing requests received by this
- * Connector.
+ * Return the Container used for processing requests received by this Connector.
*/
@Override
public Container getContainer() {
@@ -570,8 +530,7 @@ public Container getContainer() {
}
/**
- * Set the Container used for processing requests received by this
- * Connector.
+ * Set the Container used for processing requests received by this Connector.
*
* @param container The new Container to use
*/
@@ -650,9 +609,10 @@ public Mapper getMapper() {
/**
* Set the {@link Mapper}.
+ *
* @param mapper
*/
- public void setMapper(Mapper mapper){
+ public void setMapper(Mapper mapper) {
this.mapper = mapper;
}
@@ -691,29 +651,27 @@ public void setMaxProcessors(int maxProcessors) {
}
/**
- * Return the maximum size of a POST which will be automatically
- * parsed by the container.
+ * Return the maximum size of a POST which will be automatically parsed by the container.
*/
public int getMaxPostSize() {
return maxPostSize;
}
/**
- * Set the maximum size of a POST which will be automatically
- * parsed by the container.
+ * Set the maximum size of a POST which will be automatically parsed by the container.
*
- * @param maxPostSize The new maximum size in bytes of a POST which will
- * be automatically parsed by the container
+ * @param maxPostSize The new maximum size in bytes of a POST which will be automatically parsed by the container
*/
+ @Override
public void setMaxPostSize(int maxPostSize) {
this.maxPostSize = maxPostSize;
setProperty("maxPostSize", String.valueOf(maxPostSize));
}
/**
- * Return the maximum size of a POST which will be saved by the container
- * during authentication.
+ * Return the maximum size of a POST which will be saved by the container during authentication.
*/
+ @Override
public int getMaxSavePostSize() {
return (maxSavePostSize);
@@ -721,11 +679,10 @@ public int getMaxSavePostSize() {
}
/**
- * Set the maximum size of a POST which will be saved by the container
- * during authentication.
+ * Set the maximum size of a POST which will be saved by the container during authentication.
*
- * @param maxSavePostSize The new maximum size in bytes of a POST which will
- * be saved by the container during authentication.
+ * @param maxSavePostSize The new maximum size in bytes of a POST which will be saved by the container during
+ * authentication.
*/
public void setMaxSavePostSize(int maxSavePostSize) {
@@ -753,7 +710,7 @@ public void setPort(int port) {
/**
* Sets the name of this Connector.
*/
- public void setName(String name){
+ public void setName(String name) {
this.name = name;
}
@@ -761,7 +718,7 @@ public void setName(String name){
* Gets the name of this Connector.
*/
@Override
- public String getName(){
+ public String getName() {
return name;
}
@@ -782,11 +739,9 @@ public String getInstanceName() {
* Return the Coyote protocol handler in use.
*/
public String getProtocol() {
- if ("org.glassfish.grizzly.tcp.http11.Http11Protocol".equals
- (getProtocolHandlerClassName())) {
+ if ("org.glassfish.grizzly.tcp.http11.Http11Protocol".equals(getProtocolHandlerClassName())) {
return "HTTP/1.1";
- } else if ("org.apache.jk.server.JkCoyoteHandler".equals
- (getProtocolHandlerClassName())) {
+ } else if ("org.apache.jk.server.JkCoyoteHandler".equals(getProtocolHandlerClassName())) {
return "AJP/1.3";
}
return null;
@@ -799,11 +754,9 @@ public String getProtocol() {
*/
public void setProtocol(String protocol) {
if (protocol.equals("HTTP/1.1")) {
- setProtocolHandlerClassName
- ("org.glassfish.grizzly.tcp.http11.Http11Protocol");
+ setProtocolHandlerClassName("org.glassfish.grizzly.tcp.http11.Http11Protocol");
} else if (protocol.equals("AJP/1.3")) {
- setProtocolHandlerClassName
- ("org.apache.jk.server.JkCoyoteHandler");
+ setProtocolHandlerClassName("org.apache.jk.server.JkCoyoteHandler");
} else {
setProtocolHandlerClassName(null);
}
@@ -817,8 +770,7 @@ public String getProtocolHandlerClassName() {
}
/**
- * Set the class name of the Coyote protocol handler which will be used
- * by the connector.
+ * Set the class name of the Coyote protocol handler which will be used by the connector.
*
* @param protocolHandlerClassName The new class name
*/
@@ -846,7 +798,7 @@ public String getProxyName() {
* @param proxyName The new proxy server name
*/
public void setProxyName(String proxyName) {
- if(proxyName != null && proxyName.length() > 0) {
+ if (proxyName != null && proxyName.length() > 0) {
this.proxyName = proxyName;
setProperty("proxyName", proxyName);
} else {
@@ -873,9 +825,8 @@ public void setProxyPort(int proxyPort) {
}
/**
- * Return the port number to which a request should be redirected if
- * it comes in on a non-SSL port and is subject to a security constraint
- * with a transport guarantee that requires SSL.
+ * Return the port number to which a request should be redirected if it comes in on a non-SSL port and is subject to a
+ * security constraint with a transport guarantee that requires SSL.
*/
@Override
public int getRedirectPort() {
@@ -903,20 +854,19 @@ public boolean getDisableUploadTimeout() {
/**
* Set the flag to specify upload time-out behavior.
*
- * @param isDisabled If true, then the timeout
- * parameter is ignored. If false, then the
- * timeout parameter is used to control uploads.
+ * @param isDisabled If true, then the timeout parameter is ignored. If false,
+ * then the timeout parameter is used to control uploads.
*/
- public void setDisableUploadTimeout( boolean isDisabled ) {
+ public void setDisableUploadTimeout(boolean isDisabled) {
disableUploadTimeout = isDisabled;
setProperty("disableUploadTimeout", String.valueOf(isDisabled));
}
/**
- * Return the maximum HTTP header size.
- */
+ * Return the maximum HTTP header size.
+ */
public int getMaxHttpHeaderSize() {
- return maxHttpHeaderSize;
+ return maxHttpHeaderSize;
}
/**
@@ -944,8 +894,7 @@ public void setKeepAlive(boolean keepAlive) {
}
/**
- * Return the maximum number of Keep-Alive requests to honor
- * per connection.
+ * Return the maximum number of Keep-Alive requests to honor per connection.
*/
public int getMaxKeepAliveRequests() {
return maxKeepAliveRequests;
@@ -960,8 +909,7 @@ public void setMaxKeepAliveRequests(int mkar) {
}
/**
- * Return the scheme that will be assigned to requests received
- * through this connector. Default value is "http".
+ * Return the scheme that will be assigned to requests received through this connector. Default value is "http".
*/
@Override
public String getScheme() {
@@ -969,8 +917,7 @@ public String getScheme() {
}
/**
- * Set the scheme that will be assigned to requests received through
- * this connector.
+ * Set the scheme that will be assigned to requests received through this connector.
*
* @param scheme The new scheme
*/
@@ -981,8 +928,8 @@ public void setScheme(String scheme) {
}
/**
- * Return the secure connection flag that will be assigned to requests
- * received through this connector. Default value is "false".
+ * Return the secure connection flag that will be assigned to requests received through this connector. Default value is
+ * "false".
*/
@Override
public boolean getSecure() {
@@ -990,8 +937,7 @@ public boolean getSecure() {
}
/**
- * Set the secure connection flag that will be assigned to requests
- * received through this connector.
+ * Set the secure connection flag that will be assigned to requests received through this connector.
*
* @param secure The new secure connection flag
*/
@@ -1001,18 +947,16 @@ public void setSecure(boolean secure) {
setProperty("secure", String.valueOf(secure));
}
- // START SJSAS 6439313
/**
- * Return the blocking connection flag that will be assigned to requests
- * received through this connector. Default value is "false".
+ * Return the blocking connection flag that will be assigned to requests received through this connector. Default value
+ * is "false".
*/
public boolean getBlocking() {
return blocking;
}
/**
- * Set the blocking connection flag that will be assigned to requests
- * received through this connector.
+ * Set the blocking connection flag that will be assigned to requests received through this connector.
*
* @param blocking The new blocking connection flag
*/
@@ -1020,7 +964,6 @@ public void setBlocking(boolean blocking) {
this.blocking = blocking;
setProperty("blocking", String.valueOf(blocking));
}
- // END SJSAS 6439313
public boolean getTomcatAuthentication() {
return tomcatAuthentication;
@@ -1039,8 +982,7 @@ public boolean getTcpNoDelay() {
}
/**
- * Set the TCP no delay flag which will be set on the socket after
- * accepting a connection.
+ * Set the TCP no delay flag which will be set on the socket after accepting a connection.
*
* @param tcpNoDelay The new TCP no delay flag
*/
@@ -1065,42 +1007,36 @@ public String getURIEncoding() {
@Override
public void setURIEncoding(String uriEncoding) {
if (Charset.isSupported(uriEncoding)) {
- this.uriEncoding = uriEncoding;
- setProperty("uRIEncoding", uriEncoding);
+ this.uriEncoding = uriEncoding;
+ setProperty("uRIEncoding", uriEncoding);
} else {
- if (log.isLoggable(Level.WARNING)) {
- log.log(Level.WARNING, uriEncoding
- + "is not supported .Setting default URLEncoding as "
- + this.uriEncoding);
+ if (log.isLoggable(WARNING)) {
+ log.log(WARNING, uriEncoding + "is not supported .Setting default URLEncoding as " + this.uriEncoding);
}
}
}
/**
- * Indicates whether the generation of an X-Powered-By response header for
- * servlet-generated responses is enabled or disabled for this Connector.
+ * Indicates whether the generation of an X-Powered-By response header for servlet-generated responses is enabled or
+ * disabled for this Connector.
*
- * @return true if generation of X-Powered-By response header is enabled,
- * false otherwise
+ * @return true if generation of X-Powered-By response header is enabled, false otherwise
*/
public boolean isXpoweredBy() {
return xpoweredBy;
}
/**
- * Enables or disables the generation of an X-Powered-By header (with value
- * Servlet/2.4) for all servlet-generated responses returned by this
- * Connector.
+ * Enables or disables the generation of an X-Powered-By header (with value Servlet/2.4) for all servlet-generated
+ * responses returned by this Connector.
*
- * @param xpoweredBy true if generation of X-Powered-By response header is
- * to be enabled, false otherwise
+ * @param xpoweredBy true if generation of X-Powered-By response header is to be enabled, false otherwise
*/
public void setXpoweredBy(boolean xpoweredBy) {
this.xpoweredBy = xpoweredBy;
setProperty("xpoweredBy", String.valueOf(xpoweredBy));
}
- // BEGIN S1AS 5000999
/**
* Sets the default host for this Connector.
*
@@ -1120,14 +1056,11 @@ public void setDefaultHost(String defaultHost) {
public String getDefaultHost() {
return defaultHost;
}
- // END S1AS 5000999
- // START S1AS 6188932
/**
* Returns the value of this connector's authPassthroughEnabled flag.
*
- * @return true if this connector is receiving its requests from
- * a trusted intermediate server, false otherwise
+ * @return true if this connector is receiving its requests from a trusted intermediate server, false otherwise
*/
@Override
public boolean getAuthPassthroughEnabled() {
@@ -1137,8 +1070,8 @@ public boolean getAuthPassthroughEnabled() {
/**
* Sets the value of this connector's authPassthroughEnabled flag.
*
- * @param authPassthroughEnabled true if this connector is receiving its
- * requests from a trusted intermediate server, false otherwise
+ * @param authPassthroughEnabled true if this connector is receiving its requests from a trusted intermediate server,
+ * false otherwise
*/
@Override
public void setAuthPassthroughEnabled(boolean authPassthroughEnabled) {
@@ -1148,8 +1081,7 @@ public void setAuthPassthroughEnabled(boolean authPassthroughEnabled) {
/**
* Gets the ProxyHandler instance associated with this CoyoteConnector.
*
- * @return ProxyHandler instance associated with this CoyoteConnector,
- * or null
+ * @return ProxyHandler instance associated with this CoyoteConnector, or null
*/
@Override
public ProxyHandler getProxyHandler() {
@@ -1166,9 +1098,6 @@ public void setProxyHandler(ProxyHandler proxyHandler) {
this.proxyHandler = proxyHandler;
}
- // END S1AS 6188932
-
- // START SJSAS 6331392
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
@@ -1176,12 +1105,13 @@ public void setEnabled(boolean enabled) {
public boolean isEnabled() {
return enabled;
}
- // END SJSAS 6331392
+ @Override
public void setJvmRoute(String jvmRoute) {
this.jvmRoute = jvmRoute;
}
+ @Override
public String getJvmRoute() {
return jvmRoute;
}
@@ -1189,8 +1119,8 @@ public String getJvmRoute() {
// --------------------------------------------------------- Public Methods
/**
- * Create (or allocate) and return a Request object suitable for
- * specifying the contents of a Request to the responsible Container.
+ * Create (or allocate) and return a Request object suitable for specifying the contents of a Request to the responsible
+ * Container.
*/
@Override
public org.apache.catalina.Request createRequest() {
@@ -1200,8 +1130,8 @@ public org.apache.catalina.Request createRequest() {
}
/**
- * Create (or allocate) and return a Response object suitable for
- * receiving the contents of a Response from the responsible Container.
+ * Create (or allocate) and return a Response object suitable for receiving the contents of a Response from the
+ * responsible Container.
*/
@Override
public org.apache.catalina.Response createResponse() {
@@ -1210,37 +1140,31 @@ public org.apache.catalina.Response createResponse() {
return response;
}
-
// -------------------------------------------------- Monitoring Methods
/**
- * Fires probe event related to the fact that the given request has
- * been entered the web container.
+ * Fires probe event related to the fact that the given request has been entered the web container.
*
* @param request the request object
* @param host the virtual server to which the request was mapped
* @param context the Context to which the request was mapped
*/
- public void requestStartEvent(HttpServletRequest request, Host host,
- Context context) {
+ public void requestStartEvent(HttpServletRequest request, Host host, Context context) {
// Deliberate noop
};
/**
- * Fires probe event related to the fact that the given request is about
- * to exit from the web container.
+ * Fires probe event related to the fact that the given request is about to exit from the web container.
*
* @param request the request object
* @param host the virtual server to which the request was mapped
* @param context the Context to which the request was mapped
* @param statusCode the response status code
*/
- public void requestEndEvent(HttpServletRequest request, Host host,
- Context context, int statusCode) {
+ public void requestEndEvent(HttpServletRequest request, Host host, Context context, int statusCode) {
// Deliberate noop
};
-
// ------------------------------------------------------ Lifecycle Methods
/**
@@ -1254,8 +1178,7 @@ public void addLifecycleListener(LifecycleListener listener) {
}
/**
- * Gets the (possibly empty) list of lifecycle listeners
- * associated with this Connector.
+ * Gets the (possibly empty) list of lifecycle listeners associated with this Connector.
*/
@Override
public List findLifecycleListeners() {
@@ -1272,16 +1195,13 @@ public void removeLifecycleListener(LifecycleListener listener) {
lifecycle.removeLifecycleListener(listener);
}
- protected ObjectName createObjectName(String domain, String type)
- throws MalformedObjectNameException {
+ protected ObjectName createObjectName(String domain, String type) throws MalformedObjectNameException {
String encodedAddr = null;
if (getAddress() != null) {
encodedAddr = URLEncoder.encode(getProperty("address"));
}
- String addSuffix = (getAddress() == null) ? "" : ",address="
- + encodedAddr;
- ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port="
- + getPort() + addSuffix);
+ String addSuffix = (getAddress() == null) ? "" : ",address=" + encodedAddr;
+ ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port=" + getPort() + addSuffix);
return _oname;
}
@@ -1289,12 +1209,10 @@ protected ObjectName createObjectName(String domain, String type)
* Initialize this connector (create ServerSocket here!)
*/
@Override
- public void initialize()
- throws LifecycleException
- {
+ public void initialize() throws LifecycleException {
if (initialized) {
- if (log.isLoggable(Level.INFO)) {
- log.log(Level.INFO, LogFacade.CONNECTOR_BEEN_INIT);
+ if (log.isLoggable(INFO)) {
+ log.log(INFO, LogFacade.CONNECTOR_BEEN_INIT);
}
return;
}
@@ -1302,151 +1220,110 @@ public void initialize()
this.initialized = true;
// If the Mapper is null, do not fail and creates one by default.
- if (mapper == null){
+ if (mapper == null) {
mapper = new Mapper();
}
- if( oname == null && (container instanceof StandardEngine)) {
+ if (oname == null && (container instanceof StandardEngine)) {
try {
// we are loaded directly, via API - and no name was given to us
- StandardEngine cb=(StandardEngine)container;
+ StandardEngine cb = (StandardEngine) container;
oname = createObjectName(domain, "Connector");
- controller=oname;
+ controller = oname;
} catch (Exception e) {
log.log(Level.SEVERE, LogFacade.ERROR_REGISTER_CONNECTOR_EXCEPTION, e);
}
- if (log.isLoggable(Level.FINE)) {
- log.log(Level.FINE, "Creating name for connector " + oname);
+ if (log.isLoggable(FINE)) {
+ log.log(FINE, "Creating name for connector " + oname);
}
}
-
- //START SJSAS 6363251
- // Initializa handler
- //handler = new CoyoteAdapter(this);
- //END SJSAS 6363251
- // Instantiate Adapter
- //START SJSAS 6363251
- if ( handler == null){
+ if (handler == null) {
try {
Class> clazz = Class.forName(defaultClassName);
- Constructor constructor =
- clazz.getConstructor(new Class>[]{Connector.class});
- handler =
- (HttpHandler)constructor.newInstance(new Object[]{this});
+ Constructor constructor = clazz.getConstructor(new Class>[] { Connector.class });
+ handler = (HttpHandler) constructor.newInstance(new Object[] { this });
} catch (Exception e) {
- throw new LifecycleException
- (rb.getString(LogFacade.FAILED_INSTANCIATE_HTTP_HANDLER_EXCEPTION), e);
+ throw new LifecycleException(rb.getString(LogFacade.FAILED_INSTANCIATE_HTTP_HANDLER_EXCEPTION), e);
}
}
- //END SJSAS 6363251
// Instantiate protocol handler
- if ( protocolHandler == null ) {
+ if (protocolHandler == null) {
try {
Class> clazz = Class.forName(protocolHandlerClassName);
// use no-arg constructor for JkCoyoteHandler
if (protocolHandlerClassName.equals("org.apache.jk.server.JkCoyoteHandler")) {
protocolHandler = (ProtocolHandler) clazz.newInstance();
- if (handler instanceof CoyoteAdapter){
+ if (handler instanceof CoyoteAdapter) {
((CoyoteAdapter) handler).setCompatWithTomcat(true);
} else {
- String msg = MessageFormat.format(rb.getString(LogFacade.INVALID_ADAPTER_IMPLEMENTATION_EXCEPTION),
- handler);
- throw new IllegalStateException
- (msg);
+ String msg = MessageFormat.format(rb.getString(LogFacade.INVALID_ADAPTER_IMPLEMENTATION_EXCEPTION), handler);
+ throw new IllegalStateException(msg);
}
- // START SJSAS 6439313
} else {
- Constructor constructor =
- clazz.getConstructor(new Class>[]{Boolean.TYPE,
- Boolean.TYPE,
- String.class});
-
- protocolHandler = (ProtocolHandler)
- constructor.newInstance(secure, blocking,
- selectorThreadImpl);
- // END SJSAS 6439313
+ Constructor constructor = clazz.getConstructor(new Class>[] { Boolean.TYPE, Boolean.TYPE, String.class });
+
+ protocolHandler = (ProtocolHandler) constructor.newInstance(secure, blocking, selectorThreadImpl);
}
} catch (Exception e) {
String msg = MessageFormat.format(rb.getString(LogFacade.PROTOCOL_HANDLER_INIT_FAILED_EXCEPTION), e);
- throw new LifecycleException
- (msg);
+ throw new LifecycleException(msg);
}
}
protocolHandler.setHandler(handler);
- IntrospectionUtils.setProperty(protocolHandler, "jkHome",
- System.getProperty("catalina.base"));
+ IntrospectionUtils.setProperty(protocolHandler, "jkHome", System.getProperty("catalina.base"));
// Configure secure socket factory
// XXX For backwards compatibility only.
if (factory instanceof CoyoteServerSocketFactory) {
- IntrospectionUtils.setProperty(protocolHandler, "secure",
- "" + true);
- CoyoteServerSocketFactory ssf =
- (CoyoteServerSocketFactory) factory;
- IntrospectionUtils.setProperty(protocolHandler, "algorithm",
- ssf.getAlgorithm());
+ IntrospectionUtils.setProperty(protocolHandler, "secure", "" + true);
+ CoyoteServerSocketFactory ssf = (CoyoteServerSocketFactory) factory;
+ IntrospectionUtils.setProperty(protocolHandler, "algorithm", ssf.getAlgorithm());
if (ssf.getClientAuth()) {
- IntrospectionUtils.setProperty(protocolHandler, "clientauth",
- "" + ssf.getClientAuth());
+ IntrospectionUtils.setProperty(protocolHandler, "clientauth", "" + ssf.getClientAuth());
}
- IntrospectionUtils.setProperty(protocolHandler, "keystore",
- ssf.getKeystoreFile());
- IntrospectionUtils.setProperty(protocolHandler, "randomfile",
- ssf.getRandomFile());
- IntrospectionUtils.setProperty(protocolHandler, "rootfile",
- ssf.getRootFile());
-
- IntrospectionUtils.setProperty(protocolHandler, "keypass",
- ssf.getKeystorePass());
- IntrospectionUtils.setProperty(protocolHandler, "keytype",
- ssf.getKeystoreType());
- IntrospectionUtils.setProperty(protocolHandler, "protocol",
- ssf.getProtocol());
- IntrospectionUtils.setProperty(protocolHandler, "protocols",
- ssf.getProtocols());
- IntrospectionUtils.setProperty(protocolHandler,
- "sSLImplementation",
- ssf.getSSLImplementation());
- IntrospectionUtils.setProperty(protocolHandler, "ciphers",
- ssf.getCiphers());
- IntrospectionUtils.setProperty(protocolHandler, "keyAlias",
- ssf.getKeyAlias());
+ IntrospectionUtils.setProperty(protocolHandler, "keystore", ssf.getKeystoreFile());
+ IntrospectionUtils.setProperty(protocolHandler, "randomfile", ssf.getRandomFile());
+ IntrospectionUtils.setProperty(protocolHandler, "rootfile", ssf.getRootFile());
+
+ IntrospectionUtils.setProperty(protocolHandler, "keypass", ssf.getKeystorePass());
+ IntrospectionUtils.setProperty(protocolHandler, "keytype", ssf.getKeystoreType());
+ IntrospectionUtils.setProperty(protocolHandler, "protocol", ssf.getProtocol());
+ IntrospectionUtils.setProperty(protocolHandler, "protocols", ssf.getProtocols());
+ IntrospectionUtils.setProperty(protocolHandler, "sSLImplementation", ssf.getSSLImplementation());
+ IntrospectionUtils.setProperty(protocolHandler, "ciphers", ssf.getCiphers());
+ IntrospectionUtils.setProperty(protocolHandler, "keyAlias", ssf.getKeyAlias());
} else {
- IntrospectionUtils.setProperty(protocolHandler, "secure",
- "" + secure);
+ IntrospectionUtils.setProperty(protocolHandler, "secure", "" + secure);
}
- /* Set the configured properties. This only sets the ones that were
- * explicitly configured. Default values are the responsibility of
- * the protocolHandler.
+ /*
+ * Set the configured properties. This only sets the ones that were explicitly configured. Default values are the
+ * responsibility of the protocolHandler.
*/
Iterator keys = properties.keySet().iterator();
- while( keys.hasNext() ) {
+ while (keys.hasNext()) {
String name = keys.next();
String value = properties.get(name);
- String trnName = translateAttributeName(name);
+ String trnName = translateAttributeName(name);
IntrospectionUtils.setProperty(protocolHandler, trnName, value);
}
-
try {
protocolHandler.init();
} catch (Exception e) {
String msg = MessageFormat.format(rb.getString(LogFacade.PROTOCOL_HANDLER_INIT_FAILED_EXCEPTION), e);
- throw new LifecycleException
- (msg);
+ throw new LifecycleException(msg);
}
}
/*
- * Translate the attribute name from the legacy Factory names to their
- * internal protocol names.
+ * Translate the attribute name from the legacy Factory names to their internal protocol names.
*/
private String translateAttributeName(String name) {
if ("clientAuth".equals(name)) {
@@ -1476,13 +1353,13 @@ private String translateAttributeName(String name) {
*/
@Override
public void start() throws LifecycleException {
- if( !initialized )
+ if (!initialized)
initialize();
// Validate and update our current state
if (started) {
- if (log.isLoggable(Level.INFO)) {
- log.log(Level.INFO, LogFacade.CONNECTOR_BEEN_STARTED);
+ if (log.isLoggable(INFO)) {
+ log.log(INFO, CONNECTOR_BEEN_STARTED);
}
return;
}
@@ -1492,9 +1369,8 @@ public void start() throws LifecycleException {
try {
protocolHandler.start();
} catch (Exception e) {
- String msg = MessageFormat.format(rb.getString(LogFacade.PROTOCOL_HANDLER_START_FAILED_EXCEPTION), e);
- throw new LifecycleException
- (msg);
+ String msg = MessageFormat.format(rb.getString(PROTOCOL_HANDLER_START_FAILED_EXCEPTION), e);
+ throw new LifecycleException(msg);
}
}
@@ -1509,7 +1385,7 @@ public void stop() throws LifecycleException {
// Validate and update our current state
if (!started) {
- log.log(Level.SEVERE, LogFacade.CONNECTOR_NOT_BEEN_STARTED);
+ log.log(Level.SEVERE, CONNECTOR_NOT_BEEN_STARTED);
return;
}
@@ -1519,14 +1395,11 @@ public void stop() throws LifecycleException {
try {
protocolHandler.destroy();
} catch (Exception e) {
- String msg = MessageFormat.format(rb.getString(LogFacade.PROTOCOL_HANDLER_DESTROY_FAILED_EXCEPTION), e);
- throw new LifecycleException
- (msg);
+ throw new LifecycleException(MessageFormat.format(rb.getString(PROTOCOL_HANDLER_DESTROY_FAILED_EXCEPTION), e));
}
}
-
// -------------------- Management methods --------------------
public boolean getClientAuth() {
@@ -1538,7 +1411,7 @@ public boolean getClientAuth() {
} else {
ServerSocketFactory factory = this.getFactory();
if (factory instanceof CoyoteServerSocketFactory) {
- ret = ((CoyoteServerSocketFactory)factory).getClientAuth();
+ ret = ((CoyoteServerSocketFactory) factory).getClientAuth();
}
}
@@ -1549,7 +1422,7 @@ public void setClientAuth(boolean clientAuth) {
setProperty("clientauth", String.valueOf(clientAuth));
ServerSocketFactory factory = this.getFactory();
if (factory instanceof CoyoteServerSocketFactory) {
- ((CoyoteServerSocketFactory)factory).setClientAuth(clientAuth);
+ ((CoyoteServerSocketFactory) factory).setClientAuth(clientAuth);
}
}
@@ -1558,7 +1431,7 @@ public String getKeystoreFile() {
if (ret == null) {
ServerSocketFactory factory = this.getFactory();
if (factory instanceof CoyoteServerSocketFactory) {
- ret = ((CoyoteServerSocketFactory)factory).getKeystoreFile();
+ ret = ((CoyoteServerSocketFactory) factory).getKeystoreFile();
}
}
@@ -1568,7 +1441,7 @@ public String getKeystoreFile() {
public void setKeystoreFile(String keystoreFile) {
setProperty("keystore", keystoreFile);
if (factory instanceof CoyoteServerSocketFactory) {
- ((CoyoteServerSocketFactory)factory).setKeystoreFile(keystoreFile);
+ ((CoyoteServerSocketFactory) factory).setKeystoreFile(keystoreFile);
}
}
@@ -1578,8 +1451,8 @@ public void setKeystoreFile(String keystoreFile) {
public String getKeystorePass() {
String ret = getProperty("keypass");
if (ret == null) {
- if (factory instanceof CoyoteServerSocketFactory ) {
- return ((CoyoteServerSocketFactory)factory).getKeystorePass();
+ if (factory instanceof CoyoteServerSocketFactory) {
+ return ((CoyoteServerSocketFactory) factory).getKeystorePass();
}
}
@@ -1592,24 +1465,23 @@ public String getKeystorePass() {
public void setKeystorePass(String keystorePass) {
setProperty("keypass", keystorePass);
ServerSocketFactory factory = getFactory();
- if( factory instanceof CoyoteServerSocketFactory ) {
- ((CoyoteServerSocketFactory)factory).setKeystorePass(keystorePass);
+ if (factory instanceof CoyoteServerSocketFactory) {
+ ((CoyoteServerSocketFactory) factory).setKeystorePass(keystorePass);
}
}
/**
* Gets the list of SSL cipher suites that are to be enabled
*
- * @return Comma-separated list of SSL cipher suites, or null if all
- * cipher suites supported by the underlying SSL implementation are being
- * enabled
+ * @return Comma-separated list of SSL cipher suites, or null if all cipher suites supported by the underlying SSL
+ * implementation are being enabled
*/
public String getCiphers() {
String ret = getProperty("ciphers");
if (ret == null) {
ServerSocketFactory factory = getFactory();
if (factory instanceof CoyoteServerSocketFactory) {
- ret = ((CoyoteServerSocketFactory)factory).getCiphers();
+ ret = ((CoyoteServerSocketFactory) factory).getCiphers();
}
}
@@ -1619,8 +1491,7 @@ public String getCiphers() {
/**
* Sets the SSL cipher suites that are to be enabled.
*
- * Only those SSL cipher suites that are actually supported by
- * the underlying SSL implementation will be enabled.
+ * Only those SSL cipher suites that are actually supported by the underlying SSL implementation will be enabled.
*
* @param ciphers Comma-separated list of SSL cipher suites
*/
@@ -1628,13 +1499,12 @@ public void setCiphers(String ciphers) {
setProperty("ciphers", ciphers);
ServerSocketFactory factory = getFactory();
if (factory instanceof CoyoteServerSocketFactory) {
- ((CoyoteServerSocketFactory)factory).setCiphers(ciphers);
+ ((CoyoteServerSocketFactory) factory).setCiphers(ciphers);
}
}
/**
- * Sets the number of seconds after which SSL sessions expire and are
- * removed from the SSL sessions cache.
+ * Sets the number of seconds after which SSL sessions expire and are removed from the SSL sessions cache.
*/
public void setSslSessionTimeout(String timeout) {
setProperty("sslSessionTimeout", timeout);
@@ -1645,8 +1515,7 @@ public String getSslSessionTimeout() {
}
/**
- * Sets the number of seconds after which SSL3 sessions expire and are
- * removed from the SSL sessions cache.
+ * Sets the number of seconds after which SSL3 sessions expire and are removed from the SSL sessions cache.
*/
public void setSsl3SessionTimeout(String timeout) {
setProperty("ssl3SessionTimeout", timeout);
@@ -1668,8 +1537,8 @@ public String getSslSessionCacheSize() {
}
/**
- * Gets the alias name of the keypair and supporting certificate chain
- * used by this Connector to authenticate itself to SSL clients.
+ * Gets the alias name of the keypair and supporting certificate chain used by this Connector to authenticate itself to
+ * SSL clients.
*
* @return The alias name of the keypair and supporting certificate chain
*/
@@ -1678,7 +1547,7 @@ public String getKeyAlias() {
if (ret == null) {
ServerSocketFactory factory = getFactory();
if (factory instanceof CoyoteServerSocketFactory) {
- ret = ((CoyoteServerSocketFactory)factory).getKeyAlias();
+ ret = ((CoyoteServerSocketFactory) factory).getKeyAlias();
}
}
@@ -1686,17 +1555,16 @@ public String getKeyAlias() {
}
/**
- * Sets the alias name of the keypair and supporting certificate chain
- * used by this Connector to authenticate itself to SSL clients.
+ * Sets the alias name of the keypair and supporting certificate chain used by this Connector to authenticate itself to
+ * SSL clients.
*
- * @param alias The alias name of the keypair and supporting certificate
- * chain
+ * @param alias The alias name of the keypair and supporting certificate chain
*/
public void setKeyAlias(String alias) {
setProperty("keyAlias", alias);
ServerSocketFactory factory = getFactory();
if (factory instanceof CoyoteServerSocketFactory) {
- ((CoyoteServerSocketFactory)factory).setKeyAlias(alias);
+ ((CoyoteServerSocketFactory) factory).setKeyAlias(alias);
}
}
@@ -1710,7 +1578,7 @@ public String getSslProtocol() {
if (ret == null) {
ServerSocketFactory factory = getFactory();
if (factory instanceof CoyoteServerSocketFactory) {
- ret = ((CoyoteServerSocketFactory)factory).getProtocol();
+ ret = ((CoyoteServerSocketFactory) factory).getProtocol();
}
}
@@ -1726,7 +1594,7 @@ public void setSslProtocol(String sslProtocol) {
setProperty("sslProtocol", sslProtocol);
ServerSocketFactory factory = getFactory();
if (factory instanceof CoyoteServerSocketFactory) {
- ((CoyoteServerSocketFactory)factory).setProtocol(sslProtocol);
+ ((CoyoteServerSocketFactory) factory).setProtocol(sslProtocol);
}
}
@@ -1740,7 +1608,7 @@ public String getSslProtocols() {
if (ret == null) {
ServerSocketFactory factory = getFactory();
if (factory instanceof CoyoteServerSocketFactory) {
- ret = ((CoyoteServerSocketFactory)factory).getProtocols();
+ ret = ((CoyoteServerSocketFactory) factory).getProtocols();
}
}
@@ -1756,36 +1624,31 @@ public void setSslProtocols(String sslProtocols) {
setProperty("sslProtocols", sslProtocols);
ServerSocketFactory factory = getFactory();
if (factory instanceof CoyoteServerSocketFactory) {
- ((CoyoteServerSocketFactory)factory).setProtocols(sslProtocols);
+ ((CoyoteServerSocketFactory) factory).setProtocols(sslProtocols);
}
}
- // START OF SJSAS 8.1 PE 6191830
/**
* Get the underlying WebContainer certificate for the request
*/
@Override
public X509Certificate[] getCertificates(org.apache.catalina.Request request) {
-
- Request cRequest = null;
+ Request connectorRequest = null;
if (request instanceof Request) {
- cRequest=(Request) request;
+ connectorRequest = (Request) request;
} else {
return null;
}
- X509Certificate certs[] = (X509Certificate[])
- cRequest.getAttribute(Globals.CERTIFICATES_ATTR);
+ X509Certificate certs[] = (X509Certificate[]) connectorRequest.getAttribute(CERTIFICATES_ATTR);
if ((certs == null) || (certs.length < 1)) {
- certs = (X509Certificate[])
- cRequest.getAttribute(Globals.SSL_CERTIFICATE_ATTR);
+ certs = (X509Certificate[]) connectorRequest.getAttribute(SSL_CERTIFICATE_ATTR);
}
+
return certs;
}
- // END OF SJSAS 8.1 PE 6191830
-
- // -------------------- JMX registration --------------------
+ // -------------------- JMX registration --------------------
protected String domain;
protected ObjectName oname;
@@ -1810,37 +1673,35 @@ public String getDomain() {
/**
* Set the domain of this object.
*/
- public void setDomain(String domain){
+ public void setDomain(String domain) {
this.domain = domain;
}
public void init() throws Exception {
-
- if( this.getService() != null ) {
- if (log.isLoggable(Level.FINE)) {
- log.log(Level.FINE, "Already configured");
+ if (this.getService() != null) {
+ if (log.isLoggable(FINE)) {
+ log.log(FINE, "Already configured");
}
return;
}
}
public void destroy() throws Exception {
- if( oname!=null && controller==oname ) {
- if (log.isLoggable(Level.FINE)) {
- log.log(Level.FINE, "Unregister itself " + oname );
+ if (oname != null && controller == oname) {
+ if (log.isLoggable(FINE)) {
+ log.log(FINE, "Unregister itself " + oname);
}
}
- if( getService() == null)
+ if (getService() == null)
return;
getService().removeConnector(this);
}
- // START SJSAS 6363251
/**
* Set the Adapter used by this connector.
*/
@Override
- public void setHandler(HttpHandler handler){
+ public void setHandler(HttpHandler handler) {
this.handler = handler;
}
@@ -1848,21 +1709,19 @@ public void setHandler(HttpHandler handler){
* Get the Adapter used by this connector.
*/
@Override
- public HttpHandler getHandler(){
+ public HttpHandler getHandler() {
return handler;
}
/**
* Set the ProtocolHandler used by this connector.
*/
- public void setProtocolHandler(ProtocolHandler protocolHandler){
+ public void setProtocolHandler(ProtocolHandler protocolHandler) {
this.protocolHandler = protocolHandler;
}
- // END SJSAS 6363251
/**
- * Get the underlying SelectorThread implementation, null if
- * the default is used.
+ * Get the underlying SelectorThread implementation, null if the default is used.
*/
public String getSelectorThreadImpl() {
return selectorThreadImpl;
diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java
index d0b11fd2e34..f02578a59ef 100644
--- a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
@@ -17,19 +18,30 @@
package org.apache.catalina.connector;
+import static jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
+import static jakarta.servlet.http.HttpServletResponse.SC_NOT_FOUND;
+import static java.util.logging.Level.FINE;
+import static java.util.logging.Level.INFO;
+import static java.util.logging.Level.SEVERE;
+import static org.apache.catalina.Globals.SESSION_PARAMETER_NAME;
+import static org.apache.catalina.LogFacade.FAILED_TO_INITIALIZE_THE_INTERCEPTOR;
+import static org.apache.catalina.LogFacade.HTTP_LISTENER_DISABLED;
+import static org.apache.catalina.LogFacade.INTERNAL_ERROR;
+import static org.apache.catalina.LogFacade.NO_HOST_MATCHES_SERVER_NAME_INFO;
+import static org.apache.catalina.LogFacade.PARSING_CLIENT_CERT_EXCEPTION;
+import static org.apache.catalina.LogFacade.REQUEST_PROCESSING_EXCEPTION;
+import static org.apache.catalina.connector.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER;
+import static org.glassfish.internal.api.Globals.getDefaultHabitat;
+
+import java.io.CharConversionException;
import java.nio.charset.Charset;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.ResourceBundle;
-import java.util.logging.Level;
import java.util.logging.Logger;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import com.sun.appserv.ProxyHandler;
-import java.io.CharConversionException;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
@@ -37,26 +49,24 @@
import org.apache.catalina.LogFacade;
import org.apache.catalina.Wrapper;
import org.apache.catalina.core.ContainerBase;
-import org.apache.catalina.util.ResponseUtil;
import org.apache.catalina.util.ServerInfo;
-import org.apache.catalina.util.StringManager;
import org.glassfish.common.util.InputValidationUtil;
import org.glassfish.grizzly.http.Method;
+import org.glassfish.grizzly.http.Note;
import org.glassfish.grizzly.http.server.AfterServiceListener;
import org.glassfish.grizzly.http.server.HttpHandler;
-import org.glassfish.grizzly.http.Note;
import org.glassfish.grizzly.http.server.util.MappingData;
import org.glassfish.grizzly.http.util.ByteChunk;
import org.glassfish.grizzly.http.util.CharChunk;
import org.glassfish.grizzly.http.util.DataChunk;
import org.glassfish.grizzly.http.util.MessageBytes;
-import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.web.valve.GlassFishValve;
import org.glassfish.web.valve.ServletContainerInterceptor;
+import com.sun.appserv.ProxyHandler;
+
/**
- * Implementation of a request processor which delegates the processing to a
- * Coyote processor.
+ * Implementation of a request processor which delegates the processing to a Coyote processor.
*
* @author Craig R. McClanahan
* @author Remy Maucherat
@@ -69,58 +79,50 @@ public class CoyoteAdapter extends HttpHandler {
private static final ResourceBundle rb = log.getResourceBundle();
// -------------------------------------------------------------- Constants
- private static final String POWERED_BY = "Servlet/3.1 JSP/2.3 " +
- "(" + ServerInfo.getServerInfo() + " Java/" +
- System.getProperty("java.vm.vendor") + "/" +
- System.getProperty("java.specification.version") + ")";
-
-
-// protected boolean v3Enabled =
-// Boolean.valueOf(System.getProperty("v3.grizzly.useMapper", "true"));
-
-
-// public static final int ADAPTER_NOTES = 1;
static final String JVM_ROUTE = System.getProperty("jvmRoute");
- private Collection interceptors = null;
-
protected static final boolean ALLOW_BACKSLASH =
Boolean.valueOf(System.getProperty("org.glassfish.grizzly.tcp.tomcat5.CoyoteAdapter.ALLOW_BACKSLASH", "false"));
private static final boolean COLLAPSE_ADJACENT_SLASHES =
- Boolean.valueOf(System.getProperty(
- "com.sun.enterprise.web.collapseAdjacentSlashes", "true"));
-
- /**
- * When mod_jk is used, the adapter must be invoked the same way
- * Tomcat does by invoking service(...) and the afterService(...). This
- * is a hack to make it compatible with Tomcat 5|6.
- */
- private boolean compatWithTomcat = false;
-
- private String serverName = ServerInfo.getPublicServerInfo();
+ Boolean.valueOf(System.getProperty("com.sun.enterprise.web.collapseAdjacentSlashes", "true"));
// Make sure this value is always aligned with {@link ContainerMapper}
// (@see com.sun.enterprise.v3.service.impl.ContainerMapper)
- protected final static Note MAPPING_DATA =
- org.glassfish.grizzly.http.server.Request.createNote("MappingData");
-
+ protected static final Note MAPPING_DATA =
+ org.glassfish.grizzly.http.server.Request.createNote("MappingData");
static final Note CATALINA_REQUEST_NOTE =
- org.glassfish.grizzly.http.server.Request.createNote(Request.class.getName());
+ org.glassfish.grizzly.http.server.Request.createNote(Request.class.getName());
static final Note CATALINA_RESPONSE_NOTE =
- org.glassfish.grizzly.http.server.Request.createNote(Response.class.getName());
+ org.glassfish.grizzly.http.server.Request.createNote(Response.class.getName());
- static final CatalinaAfterServiceListener catalinaAfterServiceListener =
- new CatalinaAfterServiceListener();
+ static final CatalinaAfterServiceListener catalinaAfterServiceListener = new CatalinaAfterServiceListener();
// Make sure this value is always aligned with {@link ContainerMapper}
// (@see com.sun.enterprise.v3.service.impl.ContainerMapper)
private final static Note DATA_CHUNK =
- org.glassfish.grizzly.http.server.Request.createNote("DataChunk");
+ org.glassfish.grizzly.http.server.Request.createNote("DataChunk");
- // ----------------------------------------------------------- Constructors
+ // ----------------------------------------------------- Instance Variables
+ private Collection interceptors;
+
+ /**
+ * When mod_jk is used, the adapter must be invoked the same way Tomcat does by invoking service(...) and the
+ * afterService(...). This is a hack to make it compatible with Tomcat 5|6.
+ */
+ private boolean compatWithTomcat;
+
+ private String serverName = ServerInfo.getPublicServerInfo();
+
+ /**
+ * The CoyoteConnector with which this processor is associated.
+ */
+ private Connector connector;
+
+
+ // ----------------------------------------------------------- Constructors
/**
* Construct a new CoyoteProcessor associated with the specified connector.
@@ -134,213 +136,171 @@ public CoyoteAdapter(Connector connector) {
}
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The CoyoteConnector with which this processor is associated.
- */
- private Connector connector = null;
-
-
// -------------------------------------------------------- Adapter Methods
-
/**
* Service method.
*/
@Override
- public void service(org.glassfish.grizzly.http.server.Request req,
- org.glassfish.grizzly.http.server.Response res)
- throws Exception {
+ public void service(org.glassfish.grizzly.http.server.Request grizzlyRequest, org.glassfish.grizzly.http.server.Response grizzlyResponse) throws Exception {
+ grizzlyResponse.getResponse().setAllowCustomReasonPhrase(USE_CUSTOM_STATUS_MSG_IN_HEADER);
- res.getResponse().setAllowCustomReasonPhrase(Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER);
-
- Request request = req.getNote(CATALINA_REQUEST_NOTE);
- Response response = req.getNote(CATALINA_RESPONSE_NOTE);
+ Request catalinaRequest = grizzlyRequest.getNote(CATALINA_REQUEST_NOTE);
+ Response catalinaResponse = grizzlyRequest.getNote(CATALINA_RESPONSE_NOTE);
// Grizzly already parsed, decoded, and mapped the request.
// Let's re-use this info here, before firing the
// requestStartEvent probe, so that the mapping data will be
// available to any probe event listener via standard
// ServletRequest APIs (such as getContextPath())
- MappingData md = req.getNote(MAPPING_DATA);
- final boolean v3Enabled = md != null;
- if (request == null) {
+ MappingData mappingData = grizzlyRequest.getNote(MAPPING_DATA);
+ final boolean v3Enabled = mappingData != null;
+ if (catalinaRequest == null) {
// Create objects
- request = (Request) connector.createRequest();
- response = (Response) connector.createResponse();
+ catalinaRequest = (Request) connector.createRequest();
+ catalinaResponse = (Response) connector.createResponse();
// Link objects
- request.setResponse(response);
- response.setRequest(request);
+ catalinaRequest.setResponse(catalinaResponse);
+ catalinaResponse.setRequest(catalinaRequest);
// Set as notes
- req.setNote(CATALINA_REQUEST_NOTE, request);
- req.setNote(CATALINA_RESPONSE_NOTE, response);
-// res.setNote(ADAPTER_NOTES, response);
+ grizzlyRequest.setNote(CATALINA_REQUEST_NOTE, catalinaRequest);
+ grizzlyRequest.setNote(CATALINA_RESPONSE_NOTE, catalinaResponse);
// Set query string encoding
- req.getRequest().getRequestURIRef().setDefaultURIEncoding(Charset.forName(connector.getURIEncoding()));
+ grizzlyRequest.getRequest().getRequestURIRef().setDefaultURIEncoding(Charset.forName(connector.getURIEncoding()));
}
- request.setCoyoteRequest(req);
- response.setCoyoteResponse(res);
+ catalinaRequest.setGrizzlyRequest(grizzlyRequest);
+ catalinaResponse.setCoyoteResponse(grizzlyResponse);
if (v3Enabled && !compatWithTomcat) {
- request.setMappingData(md);
- request.updatePaths(md);
+ catalinaRequest.setMappingData(mappingData);
+ catalinaRequest.updatePaths(mappingData);
}
- req.addAfterServiceListener(catalinaAfterServiceListener);
+ grizzlyRequest.addAfterServiceListener(catalinaAfterServiceListener);
try {
- doService(req, request, res, response, v3Enabled);
+ doService(grizzlyRequest, catalinaRequest, grizzlyResponse, catalinaResponse, v3Enabled);
// Request may want to initialize async processing
- request.onExitService();
+ catalinaRequest.onExitService();
} catch (Throwable t) {
- log.log(Level.SEVERE, LogFacade.REQUEST_PROCESSING_EXCEPTION, t);
+ log.log(SEVERE, REQUEST_PROCESSING_EXCEPTION, t);
}
}
private void enteringServletContainer(Request req, Response res) {
- if (interceptors == null)
+ if (interceptors == null) {
return;
- for(ServletContainerInterceptor interceptor:interceptors) {
- try{
+ }
+
+ for (ServletContainerInterceptor interceptor : interceptors) {
+ try {
interceptor.preInvoke(req, res);
} catch (Throwable th) {
- log.log(Level.SEVERE, LogFacade.INTERNAL_ERROR, th);
+ log.log(SEVERE, INTERNAL_ERROR, th);
}
}
}
private void leavingServletContainer(Request req, Response res) {
- if (interceptors == null)
+ if (interceptors == null) {
return;
- for(ServletContainerInterceptor interceptor:interceptors) {
- try{
+ }
+
+ for (ServletContainerInterceptor interceptor : interceptors) {
+ try {
interceptor.postInvoke(req, res);
} catch (Throwable th) {
- log.log(Level.SEVERE, LogFacade.INTERNAL_ERROR, th);
+ log.log(SEVERE, INTERNAL_ERROR, th);
}
}
}
private void initServletInterceptors() {
try {
- ServiceLocator services = org.glassfish.internal.api.Globals.getDefaultHabitat();
- interceptors = services.getAllServices(ServletContainerInterceptor.class);
+ interceptors = getDefaultHabitat().getAllServices(ServletContainerInterceptor.class);
} catch (Throwable th) {
- log.log(Level.SEVERE, LogFacade.FAILED_TO_INITIALIZE_THE_INTERCEPTOR, th);
+ log.log(SEVERE, FAILED_TO_INITIALIZE_THE_INTERCEPTOR, th);
}
}
+ private void doService(
+ final org.glassfish.grizzly.http.server.Request grizzlyRequest, final Request catalinaRequest,
+ final org.glassfish.grizzly.http.server.Response grizzlyResponse, final Response catalinaResponse, final boolean v3Enabled) throws Exception {
- private void doService(final org.glassfish.grizzly.http.server.Request req,
- final Request request,
- final org.glassfish.grizzly.http.server.Response res,
- final Response response,
- final boolean v3Enabled)
- throws Exception {
-
- // START SJSAS 6331392
// Check connector for disabled state
if (!connector.isEnabled()) {
- String msg = MessageFormat.format(rb.getString(LogFacade.HTTP_LISTENER_DISABLED),
- String.valueOf(connector.getPort()));
- if (log.isLoggable(Level.FINE)) {
- log.log(Level.FINE, msg);
+ String msg = MessageFormat.format(rb.getString(HTTP_LISTENER_DISABLED), String.valueOf(connector.getPort()));
+ if (log.isLoggable(FINE)) {
+ log.log(FINE, msg);
}
- response.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
+ catalinaResponse.sendError(SC_NOT_FOUND, msg);
return;
}
- // END SJSAS 6331392
-
-//// "X-Powered-By" header is set by GlassfishHttpCodecFilter
-// if (connector.isXpoweredBy()) {
-// response.addHeader("X-Powered-By", POWERED_BY);
-// }
-
- // Parse and set Catalina and configuration specific
- // request parameters
- if ( postParseRequest(req, request, res, response, v3Enabled) ) {
+ // Parse and set Catalina and configuration specific request parameters
+ if (postParseRequest(grizzlyRequest, catalinaRequest, grizzlyResponse, catalinaResponse, v3Enabled)) {
- // START S1AS 6188932
- boolean authPassthroughEnabled =
- connector.getAuthPassthroughEnabled();
+ boolean authPassthroughEnabled = connector.getAuthPassthroughEnabled();
ProxyHandler proxyHandler = connector.getProxyHandler();
if (authPassthroughEnabled && proxyHandler != null) {
- // START SJSAS 6397218
- if (proxyHandler.getSSLKeysize(
- (HttpServletRequest)request.getRequest()) > 0) {
- request.setSecure(true);
+ // Otherwise Servlet request.isSecure() value is not propagated when authPassthroughEnabled is set to true
+ if (proxyHandler.getSSLKeysize(catalinaRequest.getRequest()) > 0) {
+ catalinaRequest.setSecure(true);
}
- // END SJSAS 6397218
X509Certificate[] certs = null;
try {
- certs = proxyHandler.getSSLClientCertificateChain(
- request.getRequest());
+ certs = proxyHandler.getSSLClientCertificateChain(catalinaRequest.getRequest());
} catch (CertificateException ce) {
- log.log(Level.SEVERE, LogFacade.PARSING_CLIENT_CERT_EXCEPTION,
- ce);
+ log.log(SEVERE, PARSING_CLIENT_CERT_EXCEPTION, ce);
}
if (certs != null) {
- request.setAttribute(Globals.CERTIFICATES_ATTR,
- certs);
+ catalinaRequest.setAttribute(Globals.CERTIFICATES_ATTR, certs);
}
}
- // END S1AS 6188932
-
-//// "Server" header is set by GlassfishHttpCodecFilter
-// if (serverName != null && !serverName.isEmpty()) {
-// response.addHeader("Server", serverName);
-// }
// Invoke the web container
- connector.requestStartEvent(request.getRequest(),
- request.getHost(), request.getContext());
+ connector.requestStartEvent(catalinaRequest.getRequest(), catalinaRequest.getHost(), catalinaRequest.getContext());
Container container = connector.getContainer();
- enteringServletContainer(request, response);
+ enteringServletContainer(catalinaRequest, catalinaResponse);
try {
- request.lockSession();
- if (container.getPipeline().hasNonBasicValves() ||
- container.hasCustomPipeline()) {
- container.getPipeline().invoke(request, response);
+ catalinaRequest.lockSession();
+ if (container.getPipeline().hasNonBasicValves() || container.hasCustomPipeline()) {
+ container.getPipeline().invoke(catalinaRequest, catalinaResponse);
} else {
// Invoke host directly
- Host host = request.getHost();
+ Host host = catalinaRequest.getHost();
if (host == null) {
- response.sendError(HttpServletResponse.SC_BAD_REQUEST);
-
- String msg = MessageFormat.format(rb.getString(LogFacade.NO_HOST_MATCHES_SERVER_NAME_INFO),
- request.getRequest().getServerName());
- response.setDetailMessage(msg);
+ catalinaResponse.sendError(SC_BAD_REQUEST);
+ catalinaResponse.setDetailMessage(
+ MessageFormat.format(
+ rb.getString(NO_HOST_MATCHES_SERVER_NAME_INFO),
+ catalinaRequest.getRequest().getServerName()));
return;
}
- if (host.getPipeline().hasNonBasicValves() ||
- host.hasCustomPipeline()) {
- host.getPipeline().invoke(request, response);
+
+ if (host.getPipeline().hasNonBasicValves() || host.hasCustomPipeline()) {
+ host.getPipeline().invoke(catalinaRequest, catalinaResponse);
} else {
GlassFishValve hostValve = host.getPipeline().getBasic();
- hostValve.invoke(request, response);
+ hostValve.invoke(catalinaRequest, catalinaResponse);
// Error handling
- hostValve.postInvoke(request, response);
+ hostValve.postInvoke(catalinaRequest, catalinaResponse);
}
}
} finally {
try {
- connector.requestEndEvent(request.getRequest(),
- request.getHost(), request.getContext(),
- response.getStatus());
+ connector.requestEndEvent(catalinaRequest.getRequest(), catalinaRequest.getHost(), catalinaRequest.getContext(), catalinaResponse.getStatus());
} finally {
- leavingServletContainer(request, response);
+ leavingServletContainer(catalinaRequest, catalinaResponse);
}
}
}
@@ -348,170 +308,117 @@ private void doService(final org.glassfish.grizzly.http.server.Request req,
}
// ------------------------------------------------------ Protected Methods
-
/**
* Parse additional request parameters.
*/
- protected boolean postParseRequest(final org.glassfish.grizzly.http.server.Request req,
- final Request request,
- final org.glassfish.grizzly.http.server.Response res,
- final Response response,
- final boolean v3Enabled)
- throws Exception {
+ protected boolean postParseRequest(
+ final org.glassfish.grizzly.http.server.Request grizzlyRequest, final Request catalinaRequest,
+ final org.glassfish.grizzly.http.server.Response grizzlyResponse, final Response catalinaResponse, final boolean v3Enabled) throws Exception {
+
// XXX the processor may have set a correct scheme and port prior to this point,
// in ajp13 protocols dont make sense to get the port from the connector...
// otherwise, use connector configuration
- request.setSecure(req.isSecure());
+ catalinaRequest.setSecure(grizzlyRequest.isSecure());
// URI decoding
DataChunk decodedURI;
try {
- decodedURI = req.getRequest().getRequestURIRef().getDecodedRequestURIBC();
+ decodedURI = grizzlyRequest.getRequest().getRequestURIRef().getDecodedRequestURIBC();
} catch (CharConversionException cce) {
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid URI");
+ catalinaResponse.sendError(SC_BAD_REQUEST, "Invalid URI");
return false;
}
if (compatWithTomcat || !v3Enabled) {
-// decodedURI.duplicate(req.requestURI());
-// try {
-// req.getURLDecoder().convert(decodedURI, false);
-// } catch (IOException ioe) {
-// res.setStatus(400);
-// res.setMessage("Invalid URI: " + ioe.getMessage());
-// return false;
-// }
-
- /* GlassFish Issue 2339
- // Normalize decoded URI
- if (!normalize(req.decodedURI())) {
- res.setStatus(400);
- res.setMessage("Invalid URI");
- return false;
- }
- */
// Set the remote principal
- String principal = req.getRemoteUser();
+ String principal = grizzlyRequest.getRemoteUser();
if (principal != null) {
- request.setUserPrincipal(new CoyotePrincipal(principal));
+ catalinaRequest.setUserPrincipal(new CoyotePrincipal(principal));
}
// Set the authorization type
- String authtype = req.getAuthType();
+ String authtype = grizzlyRequest.getAuthType();
if (authtype != null) {
- request.setAuthType(authtype);
+ catalinaRequest.setAuthType(authtype);
}
-
- /* CR 6309511
- // URI character decoding
- convertURI(decodedURI, request);
-
- // Parse session Id
- parseSessionId(req, request);
- */
- // START CR 6309511
-// URI character decoding
-// request.convertURI(decodedURI);
-
- // START GlassFish Issue 2339
- // Normalize decoded URI
-// if (!normalize(decodedURI)) {
-// res.setStatus(400);
-// res.setMessage("Invalid URI");
-// return false;
-// }
- // END GlassFish Issue 2339
}
- // END CR 6309511
/*
- * Remove any parameters from the URI, so they won't be considered
- * by the mapping algorithm, and save them in a temporary CharChunk,
- * so that any session id param may be parsed once the target
- * context, which may use a custom session parameter name, has been
- * identified
+ * Remove any parameters from the URI, so they won't be considered by the mapping algorithm, and save them in a
+ * temporary CharChunk, so that any session id param may be parsed once the target context, which may use a custom
+ * session parameter name, has been identified
*/
- final CharChunk uriParamsCC = request.getURIParams();
+ final CharChunk uriParamsCC = catalinaRequest.getURIParams();
final CharChunk uriCC = decodedURI.getCharChunk();
final int semicolon = uriCC.indexOf(';');
if (semicolon > 0) {
final int absSemicolon = uriCC.getStart() + semicolon;
- uriParamsCC.setChars(uriCC.getBuffer(), absSemicolon,
- uriCC.getEnd() - absSemicolon);
- decodedURI.setChars(uriCC.getBuffer(), uriCC.getStart(),
- absSemicolon - uriCC.getStart());
+ uriParamsCC.setChars(uriCC.getBuffer(), absSemicolon, uriCC.getEnd() - absSemicolon);
+ decodedURI.setChars(uriCC.getBuffer(), uriCC.getStart(), absSemicolon - uriCC.getStart());
}
if (compatWithTomcat || !v3Enabled) {
- /*mod_jk*/
+ /* mod_jk */
DataChunk localDecodedURI = decodedURI;
if (semicolon > 0) {
- localDecodedURI = req.getNote(DATA_CHUNK);
+ localDecodedURI = grizzlyRequest.getNote(DATA_CHUNK);
if (localDecodedURI == null) {
localDecodedURI = DataChunk.newInstance();
- req.setNote(DATA_CHUNK, localDecodedURI);
+ grizzlyRequest.setNote(DATA_CHUNK, localDecodedURI);
}
localDecodedURI.duplicate(decodedURI);
}
- connector.getMapper().map(req.getRequest().serverName(), localDecodedURI,
- request.getMappingData());
- MappingData md = request.getMappingData();
- req.setNote(MAPPING_DATA, md);
- request.updatePaths(md);
+
+ connector.getMapper()
+ .map(
+ grizzlyRequest.getRequest().serverName(),
+ localDecodedURI,
+ catalinaRequest.getMappingData());
+
+ MappingData md = catalinaRequest.getMappingData();
+ grizzlyRequest.setNote(MAPPING_DATA, md);
+ catalinaRequest.updatePaths(md);
}
- // FIXME: the code below doesnt belongs to here,
- // this is only have sense
- // in Http11, not in ajp13..
- // At this point the Host header has been processed.
- // Override if the proxyPort/proxyHost are set
+ // FIXME: the code below doesn't belongs to here, this is only have sense in Http11, not in ajp13..
+ // At this point the Host header has been processed. Override if the proxyPort/proxyHost are set
String proxyName = connector.getProxyName();
int proxyPort = connector.getProxyPort();
if (proxyPort != 0) {
- req.setServerPort(proxyPort);
+ grizzlyRequest.setServerPort(proxyPort);
}
if (proxyName != null) {
- req.setServerName(proxyName);
+ grizzlyRequest.setServerName(proxyName);
}
- Context ctx = (Context) request.getMappingData().context;
+ Context catalinaContext = (Context) catalinaRequest.getMappingData().context;
// Parse session id
- if (ctx != null) {
- if (req.isRequestedSessionIdFromURL() &&
- Globals.SESSION_PARAMETER_NAME.equals(ctx.getSessionParameterName())) {
- request.obtainSessionId();
+ if (catalinaContext != null) {
+ if (grizzlyRequest.isRequestedSessionIdFromURL() && SESSION_PARAMETER_NAME.equals(catalinaContext.getSessionParameterName())) {
+ catalinaRequest.obtainSessionId();
} else if (!uriParamsCC.isNull()) {
-// String sessionParam = ";" + ctx.getSessionParameterName() + "=";
- request.parseSessionId(ctx.getSessionParameterName(), uriParamsCC);
+ catalinaRequest.parseSessionId(catalinaContext.getSessionParameterName(), uriParamsCC);
}
}
- // START GlassFish 1024
- request.setDefaultContext(request.getMappingData().isDefaultContext);
- // END GlassFish 1024
+ catalinaRequest.setDefaultContext(catalinaRequest.getMappingData().isDefaultContext);
+ catalinaRequest.setContext(catalinaContext);
- // START SJSAS 6253524
- // request.setContext((Context) request.getMappingData().context);
- // END SJSAS 6253524
- // START SJSAS 6253524
- request.setContext(ctx);
- // END SJSAS 6253524
-
- if (ctx != null && !uriParamsCC.isNull()) {
- request.parseSessionVersion(uriParamsCC);
+ if (catalinaContext != null && !uriParamsCC.isNull()) {
+ catalinaRequest.parseSessionVersion(uriParamsCC);
}
if (!uriParamsCC.isNull()) {
- request.parseJReplica(uriParamsCC);
+ catalinaRequest.parseJReplica(uriParamsCC);
}
- request.setWrapper((Wrapper) request.getMappingData().wrapper);
+ catalinaRequest.setWrapper((Wrapper) catalinaRequest.getMappingData().wrapper);
// Filter trace method
- if (!connector.getAllowTrace() && Method.TRACE.equals(req.getMethod())) {
- Wrapper wrapper = request.getWrapper();
+ if (!connector.getAllowTrace() && Method.TRACE.equals(grizzlyRequest.getMethod())) {
+ Wrapper wrapper = catalinaRequest.getWrapper();
String header = null;
if (wrapper != null) {
String[] methods = wrapper.getServletMethods();
@@ -529,113 +436,86 @@ protected boolean postParseRequest(final org.glassfish.grizzly.http.server.Reque
}
}
}
- res.setStatus(405, "TRACE method is not allowed");
- res.addHeader("Allow", header);
+ grizzlyResponse.setStatus(405, "TRACE method is not allowed");
+ grizzlyResponse.addHeader("Allow", header);
+
return false;
}
// Possible redirect
- DataChunk redirectPathMB = request.getMappingData().redirectPath;
- // START SJSAS 6253524
- // if (!redirectPathMB.isNull()) {
- // END SJSAS 6253524
- // START SJSAS 6253524
- if (!redirectPathMB.isNull()
- && (!ctx.hasAdHocPaths()
- || (ctx.getAdHocServletName(((HttpServletRequest)
- request.getRequest()).getServletPath()) == null))) {
- // END SJSAS 6253524
+ DataChunk redirectPathMB = catalinaRequest.getMappingData().redirectPath;
+ if (!redirectPathMB.isNull() && (!catalinaContext.hasAdHocPaths() || (catalinaContext.getAdHocServletName(catalinaRequest.getRequest().getServletPath()) == null))) {
String redirectPath = redirectPathMB.toString();
- String query = request.getQueryString();
- if (request.isRequestedSessionIdFromURL()) {
- // This is not optimal, but as this is not very common, it
- // shouldn't matter
- redirectPath = redirectPath + ";" + ctx.getSessionParameterName() + "="
- + request.getRequestedSessionId();
- }
- // START GlassFish 936
- redirectPath = response.encode(redirectPath);
- // END GlassFish 936
+ String query = catalinaRequest.getQueryString();
+ if (catalinaRequest.isRequestedSessionIdFromURL()) {
+ // This is not optimal, but as this is not very common, it shouldn't matter
+ redirectPath = redirectPath + ";" + catalinaContext.getSessionParameterName() + "=" + catalinaRequest.getRequestedSessionId();
+ }
+
+ redirectPath = catalinaResponse.encode(redirectPath);
if (query != null) {
- // This is not optimal, but as this is not very common, it
- // shouldn't matter
+ // This is not optimal, but as this is not very common, it shouldn't matter
redirectPath = redirectPath + "?" + query;
}
- // START CR 6590921
- boolean authPassthroughEnabled =
- connector.getAuthPassthroughEnabled();
+ boolean authPassthroughEnabled = connector.getAuthPassthroughEnabled();
ProxyHandler proxyHandler = connector.getProxyHandler();
if (authPassthroughEnabled && proxyHandler != null) {
-
- if (proxyHandler.getSSLKeysize(
- (HttpServletRequest)request.getRequest()) > 0) {
- request.setSecure(true);
+ if (proxyHandler.getSSLKeysize(catalinaRequest.getRequest()) > 0) {
+ catalinaRequest.setSecure(true);
}
}
- // END CR 6590921
+
// Issue a permanent redirect
// Validating the redirectPath for header injection
if (InputValidationUtil.validateStringforCRLF(redirectPath)) {
- response.sendError(403, "Forbidden");
+ catalinaResponse.sendError(403, "Forbidden");
} else {
- response.sendRedirect(InputValidationUtil.removeLinearWhiteSpaces(redirectPath),
- false);
+ catalinaResponse.sendRedirect(InputValidationUtil.removeLinearWhiteSpaces(redirectPath), false);
}
return false;
}
// Parse session Id
- /* CR 6309511
- parseSessionCookiesId(req, request);
- */
- // START CR 6309511
- request.parseSessionCookiesId();
- // END CR 6309511
-
- // START SJSAS 6346226
- request.parseJrouteCookie();
- // END SJSAS 6346226
+ catalinaRequest.parseSessionCookiesId();
+ catalinaRequest.parseJrouteCookie();
return true;
}
-
/**
* Normalize URI.
*
- * This method normalizes "\", "//", "/./" and "/../". This method will
- * return false when trying to go above the root, or if the URI contains
- * a null byte.
+ * This method normalizes "\", "//", "/./" and "/../". This method will return false when trying to go above the root,
+ * or if the URI contains a null byte.
*
* @param uriMB URI to be normalized
*/
public static boolean normalize(MessageBytes uriMB) {
-
int type = uriMB.getType();
if (type == MessageBytes.T_CHARS) {
return normalizeChars(uriMB);
- } else {
- return normalizeBytes(uriMB);
}
- }
+ return normalizeBytes(uriMB);
+ }
private static boolean normalizeBytes(MessageBytes uriMB) {
-
ByteChunk uriBC = uriMB.getByteChunk();
byte[] b = uriBC.getBytes();
int start = uriBC.getStart();
int end = uriBC.getEnd();
// An empty URL is not acceptable
- if (start == end)
+ if (start == end) {
return false;
+ }
// URL * is acceptable
- if ((end - start == 1) && b[start] == (byte) '*')
- return true;
+ if ((end - start == 1) && b[start] == (byte) '*') {
+ return true;
+ }
int pos = 0;
int index = 0;
@@ -676,9 +556,7 @@ private static boolean normalizeBytes(MessageBytes uriMB) {
// Note: It is possible to extend the URI by 1 without any side effect
// as the next character is a non-significant WS.
if (((end - start) > 2) && (b[end - 1] == (byte) '.')) {
- if ((b[end - 2] == (byte) '/')
- || ((b[end - 2] == (byte) '.')
- && (b[end - 3] == (byte) '/'))) {
+ if ((b[end - 2] == (byte) '/') || ((b[end - 2] == (byte) '.') && (b[end - 3] == (byte) '/'))) {
b[end] = (byte) '/';
end++;
}
@@ -691,10 +569,10 @@ private static boolean normalizeBytes(MessageBytes uriMB) {
// Resolve occurrences of "/./" in the normalized path
while (true) {
index = uriBC.indexOf("/./", 0, 3, index);
- if (index < 0)
+ if (index < 0) {
break;
- copyBytes(b, start + index, start + index + 2,
- end - start - index - 2);
+ }
+ copyBytes(b, start + index, start + index + 2, end - start - index - 2);
end = end - 2;
uriBC.setEnd(end);
}
@@ -704,19 +582,20 @@ private static boolean normalizeBytes(MessageBytes uriMB) {
// Resolve occurrences of "/../" in the normalized path
while (true) {
index = uriBC.indexOf("/../", 0, 4, index);
- if (index < 0)
+ if (index < 0) {
break;
+ }
// Prevent from going outside our context
- if (index == 0)
+ if (index == 0) {
return false;
+ }
int index2 = -1;
- for (pos = start + index - 1; (pos >= 0) && (index2 < 0); pos --) {
+ for (pos = start + index - 1; (pos >= 0) && (index2 < 0); pos--) {
if (b[pos] == (byte) '/') {
index2 = pos;
}
}
- copyBytes(b, start + index2, start + index + 3,
- end - start - index - 3);
+ copyBytes(b, start + index2, start + index + 3, end - start - index - 3);
end = end + index2 - index - 3;
uriBC.setEnd(end);
index = index2;
@@ -725,20 +604,18 @@ private static boolean normalizeBytes(MessageBytes uriMB) {
uriBC.setBytes(b, start, end);
return true;
-
}
-
- private static boolean normalizeChars(MessageBytes uriMB) {
-
- CharChunk uriCC = uriMB.getCharChunk();
- char[] c = uriCC.getChars();
- int start = uriCC.getStart();
- int end = uriCC.getEnd();
+ private static boolean normalizeChars(MessageBytes uriMessageBytes) {
+ CharChunk uriCharChunk = uriMessageBytes.getCharChunk();
+ char[] c = uriCharChunk.getChars();
+ int start = uriCharChunk.getStart();
+ int end = uriCharChunk.getEnd();
// URL * is acceptable
- if ((end - start == 1) && c[start] == (char) '*')
- return true;
+ if ((end - start == 1) && c[start] == '*') {
+ return true;
+ }
int pos = 0;
int index = 0;
@@ -746,9 +623,9 @@ private static boolean normalizeChars(MessageBytes uriMB) {
// Replace '\' with '/'
// Check for null char
for (pos = start; pos < end; pos++) {
- if (c[pos] == (char) '\\') {
+ if (c[pos] == '\\') {
if (ALLOW_BACKSLASH) {
- c[pos] = (char) '/';
+ c[pos] = '/';
} else {
return false;
}
@@ -759,15 +636,15 @@ private static boolean normalizeChars(MessageBytes uriMB) {
}
// The URL must start with '/'
- if (c[start] != (char) '/') {
+ if (c[start] != '/') {
return false;
}
// Replace "//" with "/"
if (COLLAPSE_ADJACENT_SLASHES) {
for (pos = start; pos < (end - 1); pos++) {
- if (c[pos] == (char) '/') {
- while ((pos + 1 < end) && (c[pos + 1] == (char) '/')) {
+ if (c[pos] == '/') {
+ while ((pos + 1 < end) && (c[pos + 1] == '/')) {
copyChars(c, pos, pos + 1, end - pos - 1);
end--;
}
@@ -778,66 +655,61 @@ private static boolean normalizeChars(MessageBytes uriMB) {
// If the URI ends with "/." or "/..", then we append an extra "/"
// Note: It is possible to extend the URI by 1 without any side effect
// as the next character is a non-significant WS.
- if (((end - start) > 2) && (c[end - 1] == (char) '.')) {
- if ((c[end - 2] == (char) '/')
- || ((c[end - 2] == (char) '.')
- && (c[end - 3] == (char) '/'))) {
- c[end] = (char) '/';
+ if (((end - start) > 2) && (c[end - 1] == '.')) {
+ if ((c[end - 2] == '/') || ((c[end - 2] == '.') && (c[end - 3] == '/'))) {
+ c[end] = '/';
end++;
}
}
- uriCC.setEnd(end);
+ uriCharChunk.setEnd(end);
index = 0;
// Resolve occurrences of "/./" in the normalized path
while (true) {
- index = uriCC.indexOf("/./", 0, 3, index);
- if (index < 0)
+ index = uriCharChunk.indexOf("/./", 0, 3, index);
+ if (index < 0) {
break;
- copyChars(c, start + index, start + index + 2,
- end - start - index - 2);
+ }
+ copyChars(c, start + index, start + index + 2, end - start - index - 2);
end = end - 2;
- uriCC.setEnd(end);
+ uriCharChunk.setEnd(end);
}
index = 0;
// Resolve occurrences of "/../" in the normalized path
while (true) {
- index = uriCC.indexOf("/../", 0, 4, index);
- if (index < 0)
+ index = uriCharChunk.indexOf("/../", 0, 4, index);
+ if (index < 0) {
break;
+ }
// Prevent from going outside our context
- if (index == 0)
+ if (index == 0) {
return false;
+ }
int index2 = -1;
- for (pos = start + index - 1; (pos >= 0) && (index2 < 0); pos --) {
- if (c[pos] == (char) '/') {
+ for (pos = start + index - 1; (pos >= 0) && (index2 < 0); pos--) {
+ if (c[pos] == '/') {
index2 = pos;
}
}
- copyChars(c, start + index2, start + index + 3,
- end - start - index - 3);
+ copyChars(c, start + index2, start + index + 3, end - start - index - 3);
end = end + index2 - index - 3;
- uriCC.setEnd(end);
+ uriCharChunk.setEnd(end);
index = index2;
}
- uriCC.setChars(c, start, end);
+ uriCharChunk.setChars(c, start, end);
return true;
-
}
-
// ------------------------------------------------------ Protected Methods
-
/**
- * Copy an array of bytes to a different position. Used during
- * normalization.
+ * Copy an array of bytes to a different position. Used during normalization.
*/
protected static void copyBytes(byte[] b, int dest, int src, int len) {
for (int pos = 0; pos < len; pos++) {
@@ -845,10 +717,8 @@ protected static void copyBytes(byte[] b, int dest, int src, int len) {
}
}
-
/**
- * Copy an array of chars to a different position. Used during
- * normalization.
+ * Copy an array of chars to a different position. Used during normalization.
*/
private static void copyChars(char[] c, int dest, int src, int len) {
for (int pos = 0; pos < len; pos++) {
@@ -856,17 +726,15 @@ private static void copyChars(char[] c, int dest, int src, int len) {
}
}
-
/**
* Log a message on the Logger associated with our Container (if any)
*
* @param message Message to be logged
*/
protected void log(String message) {
- log.log(Level.INFO, message);
+ log.log(INFO, message);
}
-
/**
* Log a message on the Logger associated with our Container (if any)
*
@@ -874,58 +742,25 @@ protected void log(String message) {
* @param throwable Associated exception
*/
protected void log(String message, Throwable throwable) {
- log.log(Level.SEVERE, message, throwable);
+ log.log(SEVERE, message, throwable);
}
-
- /**
- * Character conversion of the a US-ASCII MessageBytes.
- */
- /* CR 6309511
- protected void convertMB(MessageBytes mb) {
-
- // This is of course only meaningful for bytes
- if (mb.getType() != MessageBytes.T_BYTES)
- return;
-
- ByteChunk bc = mb.getByteChunk();
- CharChunk cc = mb.getCharChunk();
- cc.allocate(bc.getLength(), -1);
-
- // Default encoding: fast conversion
- byte[] bbuf = bc.getBuffer();
- char[] cbuf = cc.getBuffer();
- int start = bc.getStart();
- for (int i = 0; i < bc.getLength(); i++) {
- cbuf[i] = (char) (bbuf[i + start] & 0xff);
- }
- mb.setChars(cbuf, 0, bc.getLength());
-
- }
- */
-
-
- // START SJSAS 6349248
/**
- * Notify all container event listeners that a particular event has
- * occurred for this Adapter. The default implementation performs
- * this notification synchronously using the calling thread.
+ * Notify all container event listeners that a particular event has occurred for this Adapter. The default
+ * implementation performs this notification synchronously using the calling thread.
*
* @param type Event type
* @param data Event data
*/
public void fireAdapterEvent(String type, Object data) {
- if ( connector != null && connector.getContainer() != null) {
- try{
- ((ContainerBase)connector.getContainer())
- .fireContainerEvent(type,data);
- } catch (Throwable t){
- log.log(Level.SEVERE, LogFacade.REQUEST_PROCESSING_EXCEPTION, t);
+ if (connector != null && connector.getContainer() != null) {
+ try {
+ ((ContainerBase) connector.getContainer()).fireContainerEvent(type, data);
+ } catch (Throwable t) {
+ log.log(SEVERE, REQUEST_PROCESSING_EXCEPTION, t);
}
}
}
- // END SJSAS 6349248
-
/**
* Return true when an instance is executed the same way it does in Tomcat.
@@ -934,18 +769,15 @@ public boolean isCompatWithTomcat() {
return compatWithTomcat;
}
-
/**
- * true if this class needs to be compatible with Tomcat
- * Adapter class. Since Tomcat Adapter implementation doesn't support
- * the afterService method, the afterService method must be invoked
- * inside the service method.
+ * true if this class needs to be compatible with Tomcat Adapter class. Since Tomcat Adapter implementation
+ * doesn't support the afterService method, the afterService method must be invoked inside the service method.
*/
public void setCompatWithTomcat(boolean compatWithTomcat) {
this.compatWithTomcat = compatWithTomcat;
// Add server header
- if (compatWithTomcat){
+ if (compatWithTomcat) {
serverName = "Apache/" + serverName;
} else {
// Recalculate.
@@ -953,7 +785,6 @@ public void setCompatWithTomcat(boolean compatWithTomcat) {
}
}
-
/**
* Gets the port of this CoyoteAdapter.
*
@@ -964,31 +795,30 @@ public int getPort() {
}
/**
- * AfterServiceListener, which is responsible for recycle catalina request and response
- * objects.
+ * AfterServiceListener, which is responsible for recycle catalina request and response objects.
*/
static final class CatalinaAfterServiceListener implements AfterServiceListener {
@Override
- public void onAfterService(final org.glassfish.grizzly.http.server.Request request) {
- final Request servletRequest = request.getNote(CATALINA_REQUEST_NOTE);
- final Response servletResponse = request.getNote(CATALINA_RESPONSE_NOTE);
+ public void onAfterService(final org.glassfish.grizzly.http.server.Request grizzlyRequest) {
+ final Request catalinaRequest = grizzlyRequest.getNote(CATALINA_REQUEST_NOTE);
+ final Response catalinaResponse = grizzlyRequest.getNote(CATALINA_RESPONSE_NOTE);
- if (servletRequest != null) {
+ if (catalinaRequest != null) {
try {
- if (!servletRequest.isUpgrade()) {
- servletResponse.finishResponse();
+ if (!catalinaRequest.isUpgrade()) {
+ catalinaResponse.finishResponse();
} else {
- servletResponse.setUpgrade(servletRequest.isUpgrade());
+ catalinaResponse.setUpgrade(catalinaRequest.isUpgrade());
}
} catch (Exception e) {
- log.log(Level.SEVERE, LogFacade.REQUEST_PROCESSING_EXCEPTION, e);
+ log.log(SEVERE, REQUEST_PROCESSING_EXCEPTION, e);
} finally {
try {
- servletRequest.unlockSession();
+ catalinaRequest.unlockSession();
} finally {
- servletRequest.recycle();
- servletResponse.recycle();
+ catalinaRequest.recycle();
+ catalinaResponse.recycle();
}
}
}
diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyotePrincipal.java b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyotePrincipal.java
index be322679d4e..0962575eac6 100644
--- a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyotePrincipal.java
+++ b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyotePrincipal.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
@@ -21,8 +22,8 @@
import java.security.Principal;
/**
- * Generic implementation of java.security.Principal that
- * is used to represent principals authenticated at the protocol handler level.
+ * Generic implementation of java.security.Principal that is used to represent principals authenticated
+ * at the protocol handler level.
*
* @author Remy Maucherat
* @version $Revision: 1.2 $ $Date: 2005/12/08 01:28:34 $
@@ -32,45 +33,35 @@ public class CoyotePrincipal implements Principal, Serializable {
private static final long serialVersionUID = 1L;
-
// ----------------------------------------------------------- Constructors
-
public CoyotePrincipal(String name) {
-
this.name = name;
-
}
-
// ------------------------------------------------------------- Properties
-
/**
* The username of the user represented by this Principal.
*/
- protected String name = null;
+ protected String name;
+ @Override
public String getName() {
- return (this.name);
+ return name;
}
-
// --------------------------------------------------------- Public Methods
-
/**
- * Return a String representation of this object, which exposes only
- * information that should be public.
+ * Return a String representation of this object, which exposes only information that should be public.
*/
+ @Override
public String toString() {
-
StringBuilder sb = new StringBuilder("CoyotePrincipal[");
- sb.append(this.name);
+ sb.append(name);
sb.append("]");
return (sb.toString());
-
}
-
}
diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteWriter.java b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteWriter.java
index 8f910f4ef7c..43f06ee38bf 100644
--- a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteWriter.java
+++ b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteWriter.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
@@ -17,12 +18,13 @@
package org.apache.catalina.connector;
-import org.apache.catalina.LogFacade;
+import static org.apache.catalina.LogFacade.OBJECT_INVALID_SCOPE_EXCEPTION;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ResourceBundle;
+import org.apache.catalina.LogFacade;
/**
* Coyote implementation of the servlet writer.
@@ -30,53 +32,40 @@
* @author Remy Maucherat
* @author Kin-man Chung
*/
-public class CoyoteWriter
- extends PrintWriter {
+public class CoyoteWriter extends PrintWriter {
private static final ResourceBundle rb = LogFacade.getLogger().getResourceBundle();
-
// -------------------------------------------------------------- Constants
-
// No need for a do privileged block - every web app has permission to read
// this by default
- private static final char[] LINE_SEP =
- System.getProperty("line.separator").toCharArray();
-
-
+ private static final char[] LINE_SEP = System.getProperty("line.separator").toCharArray();
// ----------------------------------------------------- Instance Variables
-
protected OutputBuffer ob;
protected boolean error = false;
-
// ----------------------------------------------------------- Constructors
-
public CoyoteWriter(OutputBuffer ob) {
super(ob);
this.ob = ob;
}
-
// --------------------------------------------------------- Public Methods
-
/**
- * Prevent cloning the facade.
- */
- protected Object clone()
- throws CloneNotSupportedException {
+ * Prevent cloning the facade.
+ */
+ @Override
+ protected Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
-
// -------------------------------------------------------- Package Methods
-
/**
* Clear facade.
*/
@@ -91,15 +80,14 @@ void recycle() {
error = false;
}
-
// --------------------------------------------------------- Writer Methods
-
+ @Override
public void flush() {
// Disallow operation if the object has gone out of scope
if (ob == null) {
- throw new IllegalStateException(rb.getString(LogFacade.OBJECT_INVALID_SCOPE_EXCEPTION));
+ throw new IllegalStateException(rb.getString(OBJECT_INVALID_SCOPE_EXCEPTION));
}
if (error)
@@ -113,41 +101,40 @@ public void flush() {
}
-
+ @Override
public void close() {
-
// Disallow operation if the object has gone out of scope
if (ob == null) {
- throw new IllegalStateException(rb.getString(LogFacade.OBJECT_INVALID_SCOPE_EXCEPTION));
+ throw new IllegalStateException(rb.getString(OBJECT_INVALID_SCOPE_EXCEPTION));
}
// We don't close the PrintWriter - super() is not called,
// so the stream can be reused. We close ob.
try {
ob.close();
- } catch (IOException ex ) {
+ } catch (IOException ex) {
// Ignore
}
error = false;
}
-
+ @Override
public boolean checkError() {
// Disallow operation if the object has gone out of scope
if (ob == null) {
- throw new IllegalStateException(rb.getString(LogFacade.OBJECT_INVALID_SCOPE_EXCEPTION));
+ throw new IllegalStateException(rb.getString(OBJECT_INVALID_SCOPE_EXCEPTION));
}
flush();
return error;
}
-
+ @Override
public void write(int c) {
// Disallow operation if the object has gone out of scope
if (ob == null) {
- throw new IllegalStateException(rb.getString(LogFacade.OBJECT_INVALID_SCOPE_EXCEPTION));
+ throw new IllegalStateException(rb.getString(OBJECT_INVALID_SCOPE_EXCEPTION));
}
if (error)
@@ -161,12 +148,12 @@ public void write(int c) {
}
-
+ @Override
public void write(char buf[], int off, int len) {
// Disallow operation if the object has gone out of scope
if (ob == null) {
- throw new IllegalStateException(rb.getString(LogFacade.OBJECT_INVALID_SCOPE_EXCEPTION));
+ throw new IllegalStateException(rb.getString(OBJECT_INVALID_SCOPE_EXCEPTION));
}
if (error)
@@ -179,17 +166,16 @@ public void write(char buf[], int off, int len) {
}
}
-
+ @Override
public void write(char buf[]) {
write(buf, 0, buf.length);
}
-
+ @Override
public void write(String s, int off, int len) {
-
// Disallow operation if the object has gone out of scope
if (ob == null) {
- throw new IllegalStateException(rb.getString(LogFacade.OBJECT_INVALID_SCOPE_EXCEPTION));
+ throw new IllegalStateException(rb.getString(OBJECT_INVALID_SCOPE_EXCEPTION));
}
if (error)
@@ -203,17 +189,16 @@ public void write(String s, int off, int len) {
}
-
+ @Override
public void write(String s) {
write(s, 0, s.length());
}
-
public void write(byte[] buff, int off, int len) {
// Disallow operation if the object has gone out of scope
if (ob == null) {
- throw new IllegalStateException(rb.getString(LogFacade.OBJECT_INVALID_SCOPE_EXCEPTION));
+ throw new IllegalStateException(rb.getString(OBJECT_INVALID_SCOPE_EXCEPTION));
}
if (error)
@@ -226,10 +211,9 @@ public void write(byte[] buff, int off, int len) {
}
}
-
// ---------------------------------------------------- PrintWriter Methods
-
+ @Override
public void print(boolean b) {
if (b) {
write("true");
@@ -238,37 +222,37 @@ public void print(boolean b) {
}
}
-
+ @Override
public void print(char c) {
write(c);
}
-
+ @Override
public void print(int i) {
write(String.valueOf(i));
}
-
+ @Override
public void print(long l) {
write(String.valueOf(l));
}
-
+ @Override
public void print(float f) {
write(String.valueOf(f));
}
-
+ @Override
public void print(double d) {
write(String.valueOf(d));
}
-
+ @Override
public void print(char s[]) {
write(s);
}
-
+ @Override
public void print(String s) {
if (s == null) {
s = "null";
@@ -276,65 +260,65 @@ public void print(String s) {
write(s);
}
-
+ @Override
public void print(Object obj) {
write(String.valueOf(obj));
}
-
+ @Override
public void println() {
write(LINE_SEP);
}
-
+ @Override
public void println(boolean b) {
print(b);
println();
}
-
+ @Override
public void println(char c) {
print(c);
println();
}
-
+ @Override
public void println(int i) {
print(i);
println();
}
-
+ @Override
public void println(long l) {
print(l);
println();
}
-
+ @Override
public void println(float f) {
print(f);
println();
}
-
+ @Override
public void println(double d) {
print(d);
println();
}
-
+ @Override
public void println(char c[]) {
print(c);
println();
}
-
+ @Override
public void println(String s) {
print(s);
println();
}
-
+ @Override
public void println(Object o) {
print(o);
println();
diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Request.java b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Request.java
index bdabcacaee2..0bf9345723d 100644
--- a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Request.java
+++ b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Request.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
@@ -17,6 +18,52 @@
package org.apache.catalina.connector;
+import static com.sun.logging.LogCleanerUtil.getSafeHeaderValue;
+import static jakarta.servlet.DispatcherType.REQUEST;
+import static jakarta.servlet.RequestDispatcher.ERROR_EXCEPTION;
+import static jakarta.servlet.RequestDispatcher.INCLUDE_SERVLET_PATH;
+import static jakarta.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+import static java.util.logging.Level.FINEST;
+import static java.util.logging.Level.SEVERE;
+import static java.util.logging.Level.WARNING;
+import static org.apache.catalina.Globals.CERTIFICATES_ATTR;
+import static org.apache.catalina.Globals.CIPHER_SUITE_ATTR;
+import static org.apache.catalina.Globals.DISPATCHER_TYPE_ATTR;
+import static org.apache.catalina.Globals.ISO_8859_1_ENCODING;
+import static org.apache.catalina.Globals.JREPLICA_PARAMETER;
+import static org.apache.catalina.Globals.JREPLICA_SESSION_NOTE;
+import static org.apache.catalina.Globals.KEY_SIZE_ATTR;
+import static org.apache.catalina.Globals.REQUEST_FACADE_HELPER;
+import static org.apache.catalina.Globals.SESSION_COOKIE_NAME;
+import static org.apache.catalina.Globals.SESSION_VERSIONS_REQUEST_ATTRIBUTE;
+import static org.apache.catalina.Globals.SESSION_VERSION_COOKIE_NAME;
+import static org.apache.catalina.Globals.SESSION_VERSION_PARAMETER;
+import static org.apache.catalina.Globals.SSL_SESSION_ID_ATTR;
+import static org.apache.catalina.LogFacade.ALREADY_AUTHENTICATED;
+import static org.apache.catalina.LogFacade.ASYNC_ALREADY_COMPLETE_EXCEPTION;
+import static org.apache.catalina.LogFacade.ATTRIBUTE_EVENT_LISTENER_EXCEPTION;
+import static org.apache.catalina.LogFacade.BREAKING_BACKGROUND_LOCK_EXCEPTION;
+import static org.apache.catalina.LogFacade.GETINPUTSTREAM_BEEN_CALLED_EXCEPTION;
+import static org.apache.catalina.LogFacade.INTERNAL_LOGOUT_ERROR;
+import static org.apache.catalina.LogFacade.INVALID_URI_CHAR_ENCODING;
+import static org.apache.catalina.LogFacade.INVALID_URI_ENCODING;
+import static org.apache.catalina.LogFacade.LOGIN_WITH_AUTH_CONFIG;
+import static org.apache.catalina.LogFacade.NO_AUTHENTICATOR;
+import static org.apache.catalina.LogFacade.NULL_ATTRIBUTE_NAME_EXCEPTION;
+import static org.apache.catalina.LogFacade.REQUEST_CALLED_WITHOUT_MULTIPART_CONFIG_EXCEPTION;
+import static org.apache.catalina.LogFacade.REQUEST_NOT_PUT_INTO_ASYNC_MODE_EXCEPTION;
+import static org.apache.catalina.LogFacade.REQUEST_WITHIN_SCOPE_OF_FILTER_OR_SERVLET_EXCEPTION;
+import static org.apache.catalina.LogFacade.START_ASYNC_CALLED_AGAIN_EXCEPTION;
+import static org.apache.catalina.LogFacade.START_ASYNC_CALLED_OUTSIDE_SCOPE_EXCEPTION;
+import static org.apache.catalina.LogFacade.UNABLE_DETERMINE_CLIENT_ADDRESS;
+import static org.apache.catalina.LogFacade.UNABLE_PERFORM_ERROR_DISPATCH;
+import static org.apache.catalina.LogFacade.UNABLE_RESOLVE_IP_EXCEPTION;
+import static org.apache.catalina.LogFacade.UNABLE_SET_REQUEST_CHARS;
+import static org.apache.catalina.authenticator.Constants.REQ_SSOID_NOTE;
+import static org.apache.catalina.authenticator.Constants.REQ_SSO_VERSION_NOTE;
+import static org.apache.catalina.connector.Constants.AUTHORIZATION_HEADER;
+import static org.apache.catalina.connector.Constants.JROUTE_COOKIE;
+
import java.io.BufferedReader;
import java.io.CharConversionException;
import java.io.File;
@@ -35,44 +82,29 @@
import java.security.PrivilegedExceptionAction;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.security.auth.Subject;
-import jakarta.servlet.AsyncContext;
-import jakarta.servlet.DispatcherType;
-import jakarta.servlet.FilterChain;
-import jakarta.servlet.RequestDispatcher;
-import jakarta.servlet.ServletConnection;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.ServletException;
-import jakarta.servlet.ServletInputStream;
-import jakarta.servlet.ServletRequest;
-import jakarta.servlet.ServletRequestAttributeEvent;
-import jakarta.servlet.ServletRequestAttributeListener;
-import jakarta.servlet.ServletResponse;
-import jakarta.servlet.SessionCookieConfig;
-import jakarta.servlet.http.Cookie;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.http.HttpSession;
-import jakarta.servlet.http.HttpUpgradeHandler;
-import jakarta.servlet.http.Part;
-import jakarta.servlet.http.PushBuilder;
-import jakarta.servlet.http.WebConnection;
-import com.sun.appserv.ProxyHandler;
-import jakarta.servlet.http.MappingMatch;
+import javax.security.auth.Subject;
-import static com.sun.logging.LogCleanerUtil.neutralizeForLog;
import org.apache.catalina.Context;
-import org.apache.catalina.LogFacade;
import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.HttpRequest;
import org.apache.catalina.HttpResponse;
+import org.apache.catalina.LogFacade;
import org.apache.catalina.Manager;
import org.apache.catalina.Pipeline;
import org.apache.catalina.Realm;
@@ -88,7 +120,9 @@
import org.apache.catalina.security.SecurityUtil;
import org.apache.catalina.session.PersistentManagerBase;
import org.apache.catalina.session.StandardSession;
-import org.apache.catalina.util.*;
+import org.apache.catalina.util.Enumerator;
+import org.apache.catalina.util.ParameterMap;
+import org.apache.catalina.util.RequestUtil;
import org.glassfish.grizzly.Buffer;
import org.glassfish.grizzly.CompletionHandler;
import org.glassfish.grizzly.EmptyCompletionHandler;
@@ -106,8 +140,31 @@
import org.glassfish.grizzly.memory.Buffers;
import org.glassfish.grizzly.utils.Charsets;
import org.glassfish.web.valve.GlassFishValve;
+
+import com.sun.appserv.ProxyHandler;
+
+import jakarta.servlet.AsyncContext;
+import jakarta.servlet.DispatcherType;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.RequestDispatcher;
+import jakarta.servlet.ServletConnection;
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletInputStream;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletRequestAttributeEvent;
+import jakarta.servlet.ServletRequestAttributeListener;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.SessionCookieConfig;
+import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletMapping;
-import static com.sun.logging.LogCleanerUtil.getSafeHeaderValue;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpSession;
+import jakarta.servlet.http.HttpUpgradeHandler;
+import jakarta.servlet.http.Part;
+import jakarta.servlet.http.PushBuilder;
+import jakarta.servlet.http.WebConnection;
/**
* Wrapper object for the Coyote request.
@@ -117,8 +174,7 @@
* @author Rajiv Mordani
* @version $Revision: 1.67.2.9 $ $Date: 2008/04/17 18:37:34 $
*/
-public class Request
- implements HttpRequest, HttpServletRequest {
+public class Request implements HttpRequest, HttpServletRequest {
private static final Logger log = LogFacade.getLogger();
private static final ResourceBundle rb = log.getResourceBundle();
@@ -127,214 +183,204 @@ public class Request
/**
* Descriptive information about this Request implementation.
*/
- protected static final String info =
- "org.apache.catalina.connector.Request/1.0";
+ protected static final String info = "org.apache.catalina.connector.Request/1.0";
/**
* Whether or not to enforce scope checking of this object.
*/
- private static boolean enforceScope = false;
+ private static boolean enforceScope;
- /**
- * The notes key for the password used to authenticate this user.
- */
- private static final String SESS_PASSWORD_NOTE =
- "org.apache.catalina.session.PASSWORD";
-
-
- /**
- * The notes key for the username used to authenticate this user.
- */
- private static final String SESS_USERNAME_NOTE =
- "org.apache.catalina.session.USERNAME";
-
- // END CR 6309511
- // START OF SJSAS 6231069
- /*
- protected SimpleDateFormat formats[] = {
- new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
- new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
- new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
- }*/
/**
* The set of SimpleDateFormat formats to use in getDateHeader().
*
- * Notice that because SimpleDateFormat is not thread-safe, we can't
- * declare formats[] as a static variable.
+ * Notice that because SimpleDateFormat is not thread-safe, we can't declare formats[] as a static variable.
*/
- private static ThreadLocal staticDateFormats = new ThreadLocal() {
+ private static ThreadLocal