(String userInfo, String header, Request request)
| 23 | } |
| 24 | |
| 25 | public static String digest(String userInfo, String header, Request request) { |
| 26 | Map<String, String> params = parseDigest(header.substring(7)); |
| 27 | String[] credentials = userInfo.split(":", 2); |
| 28 | String username = credentials[0]; |
| 29 | String password = credentials.length > 1 ? credentials[1] : ""; |
| 30 | String realm = params.getOrDefault("realm", ""); |
| 31 | String nonce = params.getOrDefault("nonce", ""); |
| 32 | String opaque = params.get("opaque"); |
| 33 | String uri = digestUri(request); |
| 34 | String qop = selectQop(params.get("qop")); |
| 35 | String nc = "00000001"; |
| 36 | String cnonce = newCnonce(); |
| 37 | String ha1 = Util.md5(username + ":" + realm + ":" + password); |
| 38 | String ha2 = Util.md5(request.method() + ":" + uri); |
| 39 | String response = digestResponse(ha1, ha2, nonce, nc, cnonce, qop); |
| 40 | return buildHeader(username, realm, nonce, uri, nc, cnonce, qop, response, opaque); |
| 41 | } |
| 42 | |
| 43 | private static String digestUri(Request request) { |
| 44 | String query = request.url().encodedQuery(); |
no test coverage detected