String password, String httpMethod, String uri, String qop, String nonce, String nc, String cnonce) throws IllegalArgumentException { String a1Md5 = encodePasswordInA1Format(username, realm, password); String a2 = httpMethod + ":" + uri; String a2Md5 = md5Hex(a2); return md5Hex(digest);
String password, String httpMethod, String uri, String qop, String nonce, String nc, String cnonce) throws IllegalArgumentException { String a1Md5 = encodePasswordInA1Format(username, realm, password); String a2 = httpMethod + ":" + uri; String a2Md5 = md5Hex(a2); return md5Hex(digest);
static String encodePasswordInA1Format(String username, String realm, String password) { String a1 = username + ":" + realm + ":" + password; return md5Hex(a1); }
private static String generateNonce(int validitySeconds) { long expiryTime = System.currentTimeMillis() + (validitySeconds * 1000); String toDigest = expiryTime + ":" + "key"; String signatureValue = md5Hex(toDigest); String nonceValue = expiryTime + ":" + signatureValue; return new String(Base64.getEncoder().encode(nonceValue.getBytes())); }
private String createAuthorizationHeader(MockHttpServletRequest request) { String uri = request.getRequestURI(); String responseDigest = generateDigest(this.username, this.realm, this.password, request.getMethod(), uri, this.qop, this.nonce, this.nc, this.cnonce); return "Digest username=\"" + this.username + "\", realm=\"" + this.realm + "\", nonce=\"" + this.nonce + "\", uri=\"" + uri + "\", response=\"" + responseDigest + "\", qop=" + this.qop + ", nc=" + this.nc + ", cnonce=\"" + this.cnonce + "\""; }
private String createAuthorizationHeader(MockHttpServletRequest request) { String uri = request.getRequestURI(); String responseDigest = generateDigest(this.username, this.realm, this.password, request.getMethod(), uri, this.qop, this.nonce, this.nc, this.cnonce); return "Digest username=\"" + this.username + "\", realm=\"" + this.realm + "\", nonce=\"" + this.nonce + "\", uri=\"" + uri + "\", response=\"" + responseDigest + "\", qop=" + this.qop + ", nc=" + this.nc + ", cnonce=\"" + this.cnonce + "\""; }
static String encodePasswordInA1Format(String username, String realm, String password) { String a1 = username + ":" + realm + ":" + password; return md5Hex(a1); }
private static String generateNonce(int validitySeconds) { long expiryTime = System.currentTimeMillis() + (validitySeconds * 1000); String toDigest = expiryTime + ":" + "key"; String signatureValue = md5Hex(toDigest); String nonceValue = expiryTime + ":" + signatureValue; return new String(Base64.getEncoder().encode(nonceValue.getBytes())); }
/** * Creates a DigestRequestPostProcessor that enables easily adding digest based * authentication to a request. * * @return the DigestRequestPostProcessor to use */ public static DigestRequestPostProcessor digest() { return new DigestRequestPostProcessor(); }
@Override public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) { request.addHeader("Authorization", createAuthorizationHeader(request)); return request; }
/** * Creates a DigestRequestPostProcessor that enables easily adding digest based * authentication to a request. * * @return the DigestRequestPostProcessor to use */ public static DigestRequestPostProcessor digest() { return new DigestRequestPostProcessor(); }
@Override public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) { request.addHeader("Authorization", createAuthorizationHeader(request)); return request; }