Merged branch 'jetty-9.4.x' into 'master'.

This commit is contained in:
Simone Bordet 2016-08-17 22:12:22 +02:00
commit fb8c738a63
3 changed files with 15 additions and 1 deletions

View File

@ -38,6 +38,12 @@ import org.eclipse.jetty.util.Attributes;
*/
public interface Authentication
{
/**
* Constant used to indicate that any realm will match.
* @see #matches(String, URI, String)
*/
public static final String ANY_REALM = "<<ANY_REALM>>";
/**
* Matches {@link Authentication}s based on the given parameters
* @param type the {@link Authentication} type such as "Basic" or "Digest"

View File

@ -52,7 +52,7 @@ public abstract class AbstractAuthentication implements Authentication
if (!getType().equalsIgnoreCase(type))
return false;
if (!this.realm.equals(realm))
if (!this.realm.equals(ANY_REALM) && !this.realm.equals(realm))
return false;
return matchesURI(this.uri, uri);

View File

@ -119,6 +119,14 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
test_Authentication(new BasicAuthentication(uri, realm, "basic", "basic"));
}
@Test
public void test_BasicAnyRealm() throws Exception
{
startBasic(new EmptyServerHandler());
URI uri = URI.create(scheme + "://localhost:" + connector.getLocalPort());
test_Authentication(new BasicAuthentication(uri, Authentication.ANY_REALM, "basic", "basic"));
}
@Test
public void test_DigestAuthentication() throws Exception
{