Merged branch 'jetty-9.3.x' into 'master'.
This commit is contained in:
commit
6128bd6d45
|
@ -135,6 +135,8 @@ public abstract class AuthenticationProtocolHandler implements ProtocolHandler
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
final Authentication.Result authnResult = authentication.authenticate(request, response, headerInfo, conversation);
|
final Authentication.Result authnResult = authentication.authenticate(request, response, headerInfo, conversation);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Authentication result {}", authnResult);
|
LOG.debug("Authentication result {}", authnResult);
|
||||||
|
@ -157,6 +159,13 @@ public abstract class AuthenticationProtocolHandler implements ProtocolHandler
|
||||||
}
|
}
|
||||||
}).send(null);
|
}).send(null);
|
||||||
}
|
}
|
||||||
|
catch (Throwable x)
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Authentication failed", x);
|
||||||
|
forwardFailureComplete(request, null, response, x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void forwardSuccessComplete(HttpRequest request, Response response)
|
private void forwardSuccessComplete(HttpRequest request, Response response)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,8 @@ import org.eclipse.jetty.client.api.Authentication;
|
||||||
import org.eclipse.jetty.client.api.AuthenticationStore;
|
import org.eclipse.jetty.client.api.AuthenticationStore;
|
||||||
import org.eclipse.jetty.client.api.ContentResponse;
|
import org.eclipse.jetty.client.api.ContentResponse;
|
||||||
import org.eclipse.jetty.client.api.Request;
|
import org.eclipse.jetty.client.api.Request;
|
||||||
|
import org.eclipse.jetty.client.api.Response;
|
||||||
|
import org.eclipse.jetty.client.api.Result;
|
||||||
import org.eclipse.jetty.client.util.BasicAuthentication;
|
import org.eclipse.jetty.client.util.BasicAuthentication;
|
||||||
import org.eclipse.jetty.client.util.DigestAuthentication;
|
import org.eclipse.jetty.client.util.DigestAuthentication;
|
||||||
import org.eclipse.jetty.security.Authenticator;
|
import org.eclipse.jetty.security.Authenticator;
|
||||||
|
@ -47,6 +49,7 @@ import org.eclipse.jetty.server.Handler;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
|
import org.eclipse.jetty.util.Attributes;
|
||||||
import org.eclipse.jetty.util.URIUtil;
|
import org.eclipse.jetty.util.URIUtil;
|
||||||
import org.eclipse.jetty.util.security.Constraint;
|
import org.eclipse.jetty.util.security.Constraint;
|
||||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
|
@ -320,4 +323,47 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
Assert.assertNotNull(response);
|
Assert.assertNotNull(response);
|
||||||
Assert.assertEquals(401, response.getStatus());
|
Assert.assertEquals(401, response.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_Authentication_ThrowsException() throws Exception
|
||||||
|
{
|
||||||
|
startBasic(new EmptyServerHandler());
|
||||||
|
|
||||||
|
// Request without Authentication would cause a 401,
|
||||||
|
// but the client will throw an exception trying to
|
||||||
|
// send the credentials to the server.
|
||||||
|
final String cause = "thrown_explicitly_by_test";
|
||||||
|
client.getAuthenticationStore().addAuthentication(new Authentication()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean matches(String type, URI uri, String realm)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result authenticate(Request request, ContentResponse response, HeaderInfo headerInfo, Attributes context)
|
||||||
|
{
|
||||||
|
throw new RuntimeException(cause);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
client.newRequest("localhost", connector.getLocalPort())
|
||||||
|
.scheme(scheme)
|
||||||
|
.path("/secure")
|
||||||
|
.timeout(5, TimeUnit.SECONDS)
|
||||||
|
.send(new Response.CompleteListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onComplete(Result result)
|
||||||
|
{
|
||||||
|
Assert.assertTrue(result.isFailed());
|
||||||
|
Assert.assertEquals(cause, result.getFailure().getMessage());
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||||
<!--
|
|
||||||
Copyright (c) 2009-2011 Intalio, Inc.
|
|
||||||
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
and Apache License v2.0 which accompanies this distribution.
|
|
||||||
The Eclipse Public License is available at
|
|
||||||
http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
The Apache License v2.0 is available at
|
|
||||||
http://www.opensource.org/licenses/apache2.0.php
|
|
||||||
You may elect to redistribute this code under either of these licenses.
|
|
||||||
Contributors:
|
|
||||||
Hugues Malphettes - initial API and implementation
|
|
||||||
-->
|
|
||||||
<Configure class="org.eclipse.jetty.servlet.ServletContextHandler">
|
<Configure class="org.eclipse.jetty.servlet.ServletContextHandler">
|
||||||
<!-- this configures the servlet session manager -->
|
<!-- this configures the servlet session manager -->
|
||||||
<Set name="SessionHandler">
|
<Set name="SessionHandler">
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -330,7 +330,7 @@
|
||||||
<Bundle-Vendor>Eclipse Jetty Project</Bundle-Vendor>
|
<Bundle-Vendor>Eclipse Jetty Project</Bundle-Vendor>
|
||||||
<Bundle-Classpath>.</Bundle-Classpath>
|
<Bundle-Classpath>.</Bundle-Classpath>
|
||||||
<Export-Package>${bundle-symbolic-name}.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</Export-Package>
|
<Export-Package>${bundle-symbolic-name}.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</Export-Package>
|
||||||
<Bundle-Copyright>Copyright (c) 2008-2015 Mort Bay Consulting Pty. Ltd.</Bundle-Copyright>
|
<Bundle-Copyright>Copyright (c) 2008-2016 Mort Bay Consulting Pty. Ltd.</Bundle-Copyright>
|
||||||
<Import-Package>javax.servlet*;version="[2.6.0,3.2)",javax.transaction*;version="[1.1,1.3)",org.eclipse.jetty*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))",*</Import-Package>
|
<Import-Package>javax.servlet*;version="[2.6.0,3.2)",javax.transaction*;version="[1.1,1.3)",org.eclipse.jetty*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))",*</Import-Package>
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
Loading…
Reference in New Issue