MCPcopy Create free account
hub / github.com/FongMi/TV / digest

Method digest

catvod/src/main/java/com/github/catvod/utils/Auth.java:25–41  ·  view source on GitHub ↗
(String userInfo, String header, Request request)

Source from the content-addressed store, hash-verified

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();

Callers 2

interceptMethod · 0.95
md5Method · 0.45

Calls 10

parseDigestMethod · 0.95
digestUriMethod · 0.95
selectQopMethod · 0.95
newCnonceMethod · 0.95
md5Method · 0.95
digestResponseMethod · 0.95
buildHeaderMethod · 0.95
splitMethod · 0.80
substringMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected