1 package com.bradmcevoy.http;
2
3 /**
4 * Implementations of this interface are authentication methods for use
5 * with HTTP.
6 *
7 * These include basic, digest, ntlm etc
8 *
9 * @author brad
10 */
11 public interface AuthenticationHandler {
12 /**
13 * Returns true if this supports authenticating with the given Auth data
14 * on the given resource.
15 *
16 * Only the first AuthenticationHandler which returns true for supports
17 * will be used for authentication. Ie supports implementations should be
18 * mutually exclusive
19 *
20 * @param r
21 * @param auth
22 * @return
23 */
24 boolean supports(Resource r, Request request);
25
26 /**
27 * Authenticate the details in the request for access to the given
28 * resource.
29 *
30 * @param resource
31 * @param request
32 * @return
33 */
34 Object authenticate( Resource resource, Request request);
35
36
37 /**
38 * Create a challenge for this authentication method. This should be completely
39 * formatted as per http://tools.ietf.org/html/rfc2617
40 *
41 * @param resource
42 * @param request
43 * @return
44 */
45 String getChallenge( Resource resource, Request request );
46
47 /**
48 * Returns true if this authentication handler is compatible with the given
49 * resource
50 *
51 * This is used when authorisation has failed, in generating challenge responses
52 *
53 * If you don't want to add a challenge response, return false
54 *
55 * @param resource
56 * @return - true if this can authenticate the resource, and it should issue a
57 * http challenge
58 */
59 boolean isCompatible( Resource resource );
60 }