return new DigestScheme(challenge);
super.processChallenge(challenge); if (getParameter("realm") == null) { throw new MalformedChallengeException("missing realm in challange"); if (getParameter("nonce") == null) { throw new MalformedChallengeException("missing nonce in challange"); String qop = getParameter("qop"); if (qop != null) { StringTokenizer tok = new StringTokenizer(qop,","); cnonce = createCnonce(); this.complete = true;
+ credentials.getClass().getName()); getParameters().put("methodname", method.getName()); StringBuffer buffer = new StringBuffer(method.getPath()); String query = method.getQueryString(); getParameters().put("uri", buffer.toString()); String charset = getParameter("charset"); if (charset == null) { getParameters().put("charset", method.getParams().getCredentialCharset()); String digest = createDigest( usernamepassword.getUserName(), usernamepassword.getPassword()); return "Digest " + createDigestHeader(usernamepassword.getUserName(), digest);
/** * Gets an ID based upon the realm and the nonce value. This ensures that requests * to the same realm with different nonce values will succeed. This differentiation * allows servers to request re-authentication using a fresh nonce value. * * @deprecated no longer used */ public String getID() { String id = getRealm(); String nonce = getParameter("nonce"); if (nonce != null) { id += "-" + nonce; } return id; }
+ credentials.getClass().getName()); getParameters().put("methodname", method); getParameters().put("uri", uri); String digest = createDigest( usernamepassword.getUserName(), usernamepassword.getPassword()); return "Digest " + createDigestHeader(usernamepassword.getUserName(), digest);
String uri = getParameter("uri"); String realm = getParameter("realm"); String nonce = getParameter("nonce"); String qop = getParameter("qop"); String method = getParameter("methodname"); String algorithm = getParameter("algorithm"); String charset = getParameter("charset"); if (charset == null) { charset = "ISO-8859-1"; String tmp2=encode(md5Helper.digest(EncodingUtil.getBytes(a1, charset))); StringBuffer tmp3 = new StringBuffer(tmp2.length() + nonce.length() + cnonce.length() + 2); tmp3.append(tmp2); LOG.warn("Unhandled algorithm " + algorithm + " requested"); String md5a1 = encode(md5Helper.digest(EncodingUtil.getBytes(a1, charset))); a2 = method + ":" + uri; String md5a2 = encode(md5Helper.digest(EncodingUtil.getAsciiBytes(a2))); String qopOption = getQopVariantString(); StringBuffer tmp2 = new StringBuffer(md5a1.length() + nonce.length() + NC.length() + cnonce.length() + qopOption.length() + md5a2.length() + 5); encode(md5Helper.digest(EncodingUtil.getAsciiBytes(serverDigestValue)));
+ "String)"); String uri = getParameter("uri"); String realm = getParameter("realm"); String nonce = getParameter("nonce"); String opaque = getParameter("opaque"); String response = digest; String algorithm = getParameter("algorithm"); params.add(new NameValuePair("qop", getQopVariantString())); params.add(new NameValuePair("nc", NC)); params.add(new NameValuePair("cnonce", this.cnonce));
/** * Constructor for the digest authetication scheme. * * @param challenge authentication challenge * * @throws MalformedChallengeException is thrown if the authentication challenge * is malformed * * @deprecated Use parameterless constructor and {@link AuthScheme#processChallenge(String)} * method */ public DigestScheme(final String challenge) throws MalformedChallengeException { this(); processChallenge(challenge); }
/** * Tests if the Digest authentication process has been completed. * * @return <tt>true</tt> if Digest authorization has been processed, * <tt>false</tt> otherwise. * * @since 3.0 */ public boolean isComplete() { String s = getParameter("stale"); if ("true".equalsIgnoreCase(s)) { return false; } else { return this.complete; } }
/** * Creates a random cnonce value based on the current time. * * @return The cnonce value as String. * @throws HttpClientError if MD5 algorithm is not supported. */ public static String createCnonce() { LOG.trace("enter DigestScheme.createCnonce()"); String cnonce; final String digAlg = "MD5"; MessageDigest md5Helper; try { md5Helper = MessageDigest.getInstance(digAlg); } catch (NoSuchAlgorithmException e) { throw new HttpClientError( "Unsupported algorithm in HTTP Digest authentication: " + digAlg); } cnonce = Long.toString(System.currentTimeMillis()); cnonce = encode(md5Helper.digest(EncodingUtil.getAsciiBytes(cnonce))); return cnonce; } }
+ credentials.getClass().getName()); getParameters().put("methodname", method); getParameters().put("uri", uri); String digest = createDigest( usernamepassword.getUserName(), usernamepassword.getPassword()); return "Digest " + createDigestHeader(usernamepassword.getUserName(), digest);
String uri = getParameter("uri"); String realm = getParameter("realm"); String nonce = getParameter("nonce"); String qop = getParameter("qop"); String method = getParameter("methodname"); String algorithm = getParameter("algorithm"); String charset = getParameter("charset"); if (charset == null) { charset = "ISO-8859-1"; String tmp2=encode(md5Helper.digest(EncodingUtil.getBytes(a1, charset))); StringBuffer tmp3 = new StringBuffer(tmp2.length() + nonce.length() + cnonce.length() + 2); tmp3.append(tmp2); LOG.warn("Unhandled algorithm " + algorithm + " requested"); String md5a1 = encode(md5Helper.digest(EncodingUtil.getBytes(a1, charset))); a2 = method + ":" + uri; String md5a2 = encode(md5Helper.digest(EncodingUtil.getAsciiBytes(a2))); String qopOption = getQopVariantString(); StringBuffer tmp2 = new StringBuffer(md5a1.length() + nonce.length() + NC.length() + cnonce.length() + qopOption.length() + md5a2.length() + 5); encode(md5Helper.digest(EncodingUtil.getAsciiBytes(serverDigestValue)));
/** * Gets an ID based upon the realm and the nonce value. This ensures that requests * to the same realm with different nonce values will succeed. This differentiation * allows servers to request re-authentication using a fresh nonce value. * * @deprecated no longer used */ public String getID() { String id = getRealm(); String nonce = getParameter("nonce"); if (nonce != null) { id += "-" + nonce; } return id; }
+ "String)"); String uri = getParameter("uri"); String realm = getParameter("realm"); String nonce = getParameter("nonce"); String opaque = getParameter("opaque"); String response = digest; String algorithm = getParameter("algorithm"); params.add(new NameValuePair("qop", getQopVariantString())); params.add(new NameValuePair("nc", NC)); params.add(new NameValuePair("cnonce", this.cnonce));
/** * Constructor for the digest authetication scheme. * * @param challenge authentication challenge * * @throws MalformedChallengeException is thrown if the authentication challenge * is malformed * * @deprecated Use parameterless constructor and {@link AuthScheme#processChallenge(String)} * method */ public DigestScheme(final String challenge) throws MalformedChallengeException { this(); processChallenge(challenge); }
/** * Tests if the Digest authentication process has been completed. * * @return <tt>true</tt> if Digest authorization has been processed, * <tt>false</tt> otherwise. * * @since 3.0 */ public boolean isComplete() { String s = getParameter("stale"); if ("true".equalsIgnoreCase(s)) { return false; } else { return this.complete; } }
/** * Creates a random cnonce value based on the current time. * * @return The cnonce value as String. * @throws HttpClientError if MD5 algorithm is not supported. */ public static String createCnonce() { LOG.trace("enter DigestScheme.createCnonce()"); String cnonce; final String digAlg = "MD5"; MessageDigest md5Helper; try { md5Helper = MessageDigest.getInstance(digAlg); } catch (NoSuchAlgorithmException e) { throw new HttpClientError( "Unsupported algorithm in HTTP Digest authentication: " + digAlg); } cnonce = Long.toString(System.currentTimeMillis()); cnonce = encode(md5Helper.digest(EncodingUtil.getAsciiBytes(cnonce))); return cnonce; } }
+ credentials.getClass().getName()); getParameters().put("methodname", method.getName()); StringBuffer buffer = new StringBuffer(method.getPath()); String query = method.getQueryString(); getParameters().put("uri", buffer.toString()); String charset = getParameter("charset"); if (charset == null) { getParameters().put("charset", method.getParams().getCredentialCharset()); String digest = createDigest( usernamepassword.getUserName(), usernamepassword.getPassword()); return "Digest " + createDigestHeader(usernamepassword.getUserName(), digest);
+ credentials.getClass().getName()); getParameters().put("methodname", method); getParameters().put("uri", uri); String digest = createDigest( usernamepassword.getUserName(), usernamepassword.getPassword()); return "Digest " + createDigestHeader(usernamepassword.getUserName(), digest);
String uri = getParameter("uri"); String realm = getParameter("realm"); String nonce = getParameter("nonce"); String qop = getParameter("qop"); String method = getParameter("methodname"); String algorithm = getParameter("algorithm"); String charset = getParameter("charset"); if (charset == null) { charset = "ISO-8859-1"; String tmp2=encode(md5Helper.digest(EncodingUtil.getBytes(a1, charset))); StringBuffer tmp3 = new StringBuffer(tmp2.length() + nonce.length() + cnonce.length() + 2); tmp3.append(tmp2); LOG.warn("Unhandled algorithm " + algorithm + " requested"); String md5a1 = encode(md5Helper.digest(EncodingUtil.getBytes(a1, charset))); a2 = method + ":" + uri; String md5a2 = encode(md5Helper.digest(EncodingUtil.getAsciiBytes(a2))); String qopOption = getQopVariantString(); StringBuffer tmp2 = new StringBuffer(md5a1.length() + nonce.length() + NC.length() + cnonce.length() + qopOption.length() + md5a2.length() + 5); encode(md5Helper.digest(EncodingUtil.getAsciiBytes(serverDigestValue)));