private static String toHexString(byte[] data) { StringBuilder buffer = StringUtils.stringBuilder(); for (int i = 0; i < data.length; i++) { buffer.append(Integer.toHexString((data[i] & 0xf0) >>> 4)); buffer.append(Integer.toHexString(data[i] & 0x0f)); } return buffer.toString(); }
public String toRelativeUrl() { StringBuilder sb = StringUtils.stringBuilder(); if (MiscUtils.isNonEmpty(path)) sb.append(path); else sb.append('/'); if (query != null) sb.append('?').append(query); return sb.toString(); }
public String toUrl() { if (url == null) { StringBuilder sb = StringUtils.stringBuilder(); sb.append(scheme).append("://"); if (userInfo != null) sb.append(userInfo).append('@'); sb.append(host); if (port != -1) sb.append(':').append(port); if (path != null) sb.append(path); if (query != null) sb.append('?').append(query); url = sb.toString(); sb.setLength(0); } return url; }
private void newResponse(MessageDigest md) { // BEWARE: compute first as it used the cached StringBuilder String digestUri = AuthenticatorUtils.computeRealmURI(uri, useAbsoluteURI, omitQuery); StringBuilder sb = StringUtils.stringBuilder(); // WARNING: DON'T MOVE, BUFFER IS RECYCLED!!!! byte[] secretDigest = secretDigest(sb, md); byte[] dataDigest = dataDigest(sb, digestUri, md); appendBase16(sb, secretDigest); appendDataBase(sb); appendBase16(sb, dataDigest); byte[] responseDigest = md5FromRecycledStringBuilder(sb, md); response = toHexString(responseDigest); }