Skip to content

Commit

Permalink
Update Jetty to most up to date version that supports Java SE 1.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwhisenhunt committed Mar 16, 2018
1 parent d6eb235 commit 348d358
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
16 changes: 14 additions & 2 deletions google-oauth-client-jetty/pom.xml
Expand Up @@ -84,8 +84,20 @@
<artifactId>google-oauth-client-java6</artifactId>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
Expand Up @@ -16,15 +16,19 @@

import com.google.api.client.extensions.java6.auth.oauth2.VerificationCodeReceiver;
import com.google.api.client.util.Throwables;

import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.AbstractHandler;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.util.concurrent.Semaphore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;

/**
* OAuth 2.0 verification code receiver that runs a Jetty server on a free port, waiting for a
Expand Down Expand Up @@ -56,12 +60,12 @@ public final class LocalServerReceiver implements VerificationCodeReceiver {
final Semaphore waitUnlessSignaled = new Semaphore(0 /* initially zero permit */);

/** Port to use or {@code -1} to select an unused port in {@link #getRedirectUri()}. */
private int port;
private int port;

/** Host name to use. */
private final String host;

/** Callback path of redirect_uri */
/** Callback path of redirect_uri. */
private final String callbackPath;

/**
Expand Down Expand Up @@ -115,10 +119,9 @@ public LocalServerReceiver() {

@Override
public String getRedirectUri() throws IOException {
server = new Server(port != -1 ? port : 0);
Connector connector = server.getConnectors()[0];
connector.setHost(host);
server.addHandler(new CallbackHandler());
server = new Server(new InetSocketAddress(host, port != -1 ? port : 0));
ServerConnector connector = (ServerConnector) server.getConnectors()[0];
server.setHandler(new CallbackHandler());
try {
server.start();
port = connector.getLocalPort();
Expand Down Expand Up @@ -228,12 +231,12 @@ public Builder setPort(int port) {
return this;
}

/** Returns the callback path of redirect_uri */
/** Returns the callback path of redirect_uri. */
public String getCallbackPath() {
return callbackPath;
}

/** Set the callback path of redirect_uri */
/** Set the callback path of redirect_uri. */
public Builder setCallbackPath(String callbackPath) {
this.callbackPath = callbackPath;
return this;
Expand All @@ -254,7 +257,8 @@ class CallbackHandler extends AbstractHandler {

@Override
public void handle(
String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
String target, Request baseRequest,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
if (!CALLBACK_PATH.equals(target)) {
return;
Expand All @@ -273,8 +277,7 @@ public void handle(
writeLandingHtml(response);
}
response.flushBuffer();
}
finally {
} finally {
waitUnlessSignaled.release();
}
}
Expand Down
21 changes: 18 additions & 3 deletions pom.xml
Expand Up @@ -182,8 +182,23 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${project.jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${project.jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>${project.jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
<version>${project.jetty.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -497,7 +512,7 @@
<project.gson.version>2.1</project.gson.version>
<project.jackson-core-asl.version>1.9.11</project.jackson-core-asl.version>
<project.jackson-core2.version>2.9.2</project.jackson-core2.version>
<project.jetty.version>6.1.26</project.jetty.version>
<project.jetty.version>9.2.24.v20180105</project.jetty.version>
<project.protobuf-java.version>2.4.1</project.protobuf-java.version>
<project.guava.version>19.0</project.guava.version>
<project.xpp3.version>1.1.4c</project.xpp3.version>
Expand Down

0 comments on commit 348d358

Please sign in to comment.