View Javadoc

1   package com.bradmcevoy.http.http11.auth;
2   
3   import com.bradmcevoy.http.Auth;
4   import com.bradmcevoy.http.Request;
5   import com.bradmcevoy.http.Request.Method;
6   
7   /**
8    * This class encapsulates all of the information from a client as a response
9    * to a Digest authentication request.
10   *
11   * @author brad
12   */
13  public class DigestResponse {
14      private final Method method;
15      private final String user;
16      private final String realm;
17      private final String nonce;
18      private final String uri;
19      private final String responseDigest;
20      private final String qop;
21      private final String nc;
22      private final String cnonce;
23  
24      public DigestResponse( Auth auth, Request request ) {
25          this.method = request.getMethod();
26          user = auth.getUser();
27          realm = auth.getRealm();
28          nonce = auth.getNonce();
29          uri = auth.getUri();
30          responseDigest = auth.getResponseDigest();
31          qop = auth.getQop();
32          nc = auth.getNc();
33          cnonce = auth.getCnonce();
34      }
35  
36      public DigestResponse( Method method, String user, String realm, String nonce, String uri, String responseDigest, String qop, String nc, String cnonce ) {
37          this.method = method;
38          this.user = user;
39          this.realm = realm;
40          this.nonce = nonce;
41          this.uri = uri;
42          this.responseDigest = responseDigest;
43          this.qop = qop;
44          this.nc = nc;
45          this.cnonce = cnonce;
46      }
47  
48  
49  
50      public Method getMethod() {
51          return method;
52      }
53  
54  
55      
56  
57  
58      public String getUser() {
59          return user;
60      }
61  
62  
63      public String getRealm() {
64          return realm;
65      }
66  
67      public String getNonce() {
68          return nonce;
69      }
70  
71      public String getUri() {
72          return uri;
73      }
74  
75      /**
76       * This is the response to the challenge. It is effectively The Answer
77       * from the user agent.
78       *
79       * Note the overloaded meanings of the word "response". This class is a response to a challenge, but is sent in a request from
80       * the user agent.
81       *
82       * @return
83       */
84      public String getResponseDigest() {
85          return responseDigest;
86      }
87  
88      public String getQop() {
89          return qop;
90      }
91  
92      public String getNc() {
93          return nc;
94      }
95  
96      public String getCnonce() {
97          return cnonce;
98      }
99  }