Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 9 additions & 30 deletions exist-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -430,37 +430,16 @@
<version>${aspectj.version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jaas</artifactId>
<version>${jetty.version}</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<!-- conflicts with antlr 2.7.7 -->
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.antlr</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Force newer MINA version for jetty-jaas -->
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.2.5</version>
</dependency>
<!-- JAAS is now in jetty-security (core module) in Jetty 12 -->

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>${jetty.version}</version>
<!-- NOTE: needed for both scopes: <scope>runtime</scope><scope>test</scope> -->
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
<version>${jetty.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -636,16 +615,16 @@
removed. Unfortunately, at this time, it is required for
Monex's Remote Console to function.
-->
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-annotations</artifactId>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-webapp</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
Expand Down Expand Up @@ -1036,10 +1015,10 @@ The BaseX Team. The original license statement is also included below.]]></pream
<ignoredUnusedDeclaredDependency>org.xmlresolver:xmlresolver:jar:${xmlresolver.version}</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.exist-db.thirdparty.org.eclipse.wst.xml:xpath2:jar:1.2.0</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>edu.princeton.cup:java-cup:jar:10k</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.eclipse.jetty:jetty-jaas:jar:${jetty.version}</ignoredUnusedDeclaredDependency>
<!-- JAAS is now in jetty-security in Jetty 12 -->
<ignoredUnusedDeclaredDependency>org.eclipse.jetty:jetty-deploy:jar:${jetty.version}</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.eclipse.jetty:jetty-jmx:jar:${jetty.version}</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.eclipse.jetty:jetty-annotations:jar:${jetty.version}</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.eclipse.jetty.ee10:jetty-ee10-annotations:jar:${jetty.version}</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.eclipse.jetty:jetty-security:jar:${jetty.version}</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>${project.groupId}:exist-jetty-config:jar:${project.version}</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.apache.mina:mina-core</ignoredUnusedDeclaredDependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void initialiseWrapper() {
parseURLParameters(this.request.getQueryString());

//If POST request, Parse out parameters from the Content Body
if ("POST".equals(request.getMethod().toUpperCase())) {
if ("POST".equalsIgnoreCase(request.getMethod())) {
//If there is some Content
final int contentLength = request.getContentLength();
if (contentLength > 0 || contentLength == -1) {
Expand Down Expand Up @@ -281,7 +281,7 @@ public BufferedReader getReader() throws IOException {
@Override
public String toString() {
// If POST request AND there is some content AND its not a file upload
if ("POST".equals(request.getMethod().toUpperCase())
if ("POST".equalsIgnoreCase(request.getMethod())
&& (request.getContentLength() > 0 || request.getContentLength() == -1)
&& !request.getContentType().toUpperCase().startsWith("MULTIPART/")) {

Expand Down Expand Up @@ -441,11 +441,7 @@ public boolean isRequestedSessionIdFromURL() {
return request.isRequestedSessionIdFromURL();
}

@Override
@Deprecated
public boolean isRequestedSessionIdFromUrl() {
return request.isRequestedSessionIdFromUrl();
}
// isRequestedSessionIdFromUrl() removed in Servlet 6.0

@Override
public boolean authenticate(final HttpServletResponse httpServletResponse) throws IOException, ServletException {
Expand Down Expand Up @@ -572,11 +568,7 @@ public RequestDispatcher getRequestDispatcher(final String name) {
return request.getRequestDispatcher(name);
}

@Override
@Deprecated
public String getRealPath(final String path) {
return request.getSession().getServletContext().getRealPath(path);
}
// getRealPath(String) removed in Servlet 6.0 — use ServletContext.getRealPath() instead

@Override
public int getRemotePort() {
Expand Down Expand Up @@ -633,6 +625,21 @@ public DispatcherType getDispatcherType() {
return request.getDispatcherType();
}

@Override
public String getRequestId() {
return request.getRequestId();
}

@Override
public String getProtocolRequestId() {
return request.getProtocolRequestId();
}

@Override
public ServletConnection getServletConnection() {
return request.getServletConnection();
}

@Override
public void close() throws IOException {
this.is.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ private ModelAndView getFromCache(final String url, final Subject user) throws E
return null;
}

try (final DBBroker broker = pool.get(Optional.ofNullable(user))) {
try (@SuppressWarnings("PMD.UnusedLocalVariable") final DBBroker broker = pool.get(Optional.ofNullable(user))) {

if (model.getSourceInfo().source instanceof DBSource) {
((DBSource) model.getSourceInfo().source).validate(Permission.EXECUTE);
Expand Down Expand Up @@ -506,25 +506,27 @@ void clearCaches() {
* @param request the http request
* @param response the http response
*/
private void doRewrite(URLRewrite action, RequestWrapper request, final HttpServletResponse response) throws IOException, ServletException {
if (action.getTarget() != null && !(action instanceof Redirect)) {
final String uri = action.resolve(request);
final URLRewrite staticRewrite = rewriteConfig.lookup(uri, request.getServerName(), true, action);
private void doRewrite(final URLRewrite action, final RequestWrapper request, final HttpServletResponse response) throws IOException, ServletException {
URLRewrite effectiveAction = action;
RequestWrapper effectiveRequest = request;
if (effectiveAction.getTarget() != null && !(effectiveAction instanceof Redirect)) {
final String uri = effectiveAction.resolve(effectiveRequest);
final URLRewrite staticRewrite = rewriteConfig.lookup(uri, effectiveRequest.getServerName(), true, effectiveAction);

if (staticRewrite != null) {
staticRewrite.copyFrom(action);
action = staticRewrite;
final RequestWrapper modifiedRequest = new RequestWrapper(request);
modifiedRequest.setPaths(uri, action.getPrefix());
staticRewrite.copyFrom(effectiveAction);
effectiveAction = staticRewrite;
final RequestWrapper modifiedRequest = new RequestWrapper(effectiveRequest);
modifiedRequest.setPaths(uri, effectiveAction.getPrefix());

if (LOG.isTraceEnabled()) {
LOG.trace("Forwarding to : {} url: {}", action.toString(), action.getURI());
LOG.trace("Forwarding to : {} url: {}", effectiveAction.toString(), effectiveAction.getURI());
}
request = modifiedRequest;
effectiveRequest = modifiedRequest;
}
}
action.prepareRequest(request);
action.doRewrite(request, response);
effectiveAction.prepareRequest(effectiveRequest);
effectiveAction.doRewrite(effectiveRequest, response);
}

protected ServletConfig getConfig() {
Expand All @@ -543,6 +545,7 @@ private URLRewrite parseAction(final HttpServletRequest request, final Element a
return rewrite;
}

@SuppressWarnings("PMD.UnusedPrivateMethod") // called from switch expression in service()
private void parseViews(final HttpServletRequest request, final Element view, final ModelAndView modelView) throws ServletException {
Node node = view.getFirstChild();
while (node != null) {
Expand All @@ -557,6 +560,7 @@ private void parseViews(final HttpServletRequest request, final Element view, fi
}
}

@SuppressWarnings("PMD.UnusedPrivateMethod") // called from switch expression in service()
private void parseErrorHandlers(final HttpServletRequest request, final Element view, final ModelAndView modelView) throws ServletException {
Node node = view.getFirstChild();
while (node != null) {
Expand Down Expand Up @@ -685,28 +689,30 @@ private Sequence runQuery(final DBBroker broker, final RequestWrapper request, f
}
}

String adjustPathForSourceLookup(final String basePath, String path) {
String adjustPathForSourceLookup(final String basePath, final String path) {
if (LOG.isTraceEnabled()) {
LOG.trace("request path={}", path);
}

if (basePath.startsWith(XmldbURI.EMBEDDED_SERVER_URI_PREFIX) && path.startsWith(basePath.replace(XmldbURI.EMBEDDED_SERVER_URI_PREFIX, ""))) {
path = path.replace(basePath.replace(XmldbURI.EMBEDDED_SERVER_URI_PREFIX, ""), "");
String adjustedPath = path;
if (basePath.startsWith(XmldbURI.EMBEDDED_SERVER_URI_PREFIX) && adjustedPath.startsWith(basePath.replace(XmldbURI.EMBEDDED_SERVER_URI_PREFIX, ""))) {
adjustedPath = adjustedPath.replace(basePath.replace(XmldbURI.EMBEDDED_SERVER_URI_PREFIX, ""), "");

} else if (path.startsWith("/db/")) {
path = path.substring(4);
} else if (adjustedPath.startsWith("/db/")) {
adjustedPath = adjustedPath.substring(4);
}

if (path.startsWith("/")) {
path = path.substring(1);
if (adjustedPath.startsWith("/")) {
adjustedPath = adjustedPath.substring(1);
}

if (LOG.isTraceEnabled()) {
LOG.trace("adjusted request path={}", path);
LOG.trace("adjusted request path={}", adjustedPath);
}
return path;
return adjustedPath;
}

@SuppressWarnings("PMD.UnusedPrivateMethod") // called indirectly from getSourceInfo()
private SourceInfo findSource(final HttpServletRequest request, final DBBroker broker, final String basePath) {
if (LOG.isTraceEnabled()) {
LOG.trace("basePath={}", basePath);
Expand Down Expand Up @@ -977,9 +983,6 @@ private static class ModelAndView {
private boolean useCache = false;
private SourceInfo sourceInfo = null;

private ModelAndView() {
}

public void setSourceInfo(final SourceInfo sourceInfo) {
this.sourceInfo = sourceInfo;
}
Expand Down Expand Up @@ -1179,12 +1182,10 @@ public String getPathTranslated() {
return super.getSession().getServletContext().getRealPath(pathInfo);
}

protected void setData(@Nullable byte[] data) {
if (data == null) {
data = new byte[0];
}
contentLength = data.length;
sis = new CachingServletInputStream(data);
protected void setData(@Nullable final byte[] data) {
final byte[] effectiveData = data == null ? new byte[0] : data;
contentLength = effectiveData.length;
sis = new CachingServletInputStream(effectiveData);
}

public void addParameter(final String name, final String value) {
Expand Down Expand Up @@ -1380,11 +1381,7 @@ public void setStatus(final int i) {
super.setStatus(i);
}

@Override
public void setStatus(final int i, final String msg) {
this.status = i;
super.setStatus(i, msg);
}
// setStatus(int, String) removed in Servlet 6.0

@Override
public void sendError(final int i, final String msg) throws IOException {
Expand Down Expand Up @@ -1413,10 +1410,8 @@ public void flushBuffer() throws IOException {
}

public void flush() throws IOException {
if (cache) {
if (contentType != null) {
super.setContentType(contentType);
}
if (cache && contentType != null) {
super.setContentType(contentType);
}
if (sos != null) {
final ServletOutputStream out = super.getOutputStream();
Expand Down
Loading
Loading