159160161162163164165166167168169
// H( unq(username-value) ":" unq(realm-value) ":" passwd ) // ":" unq(nonce-value) // ":" unq(cnonce-value) hash.putBytes(a1.getBytes("US-ASCII")); //$NON-NLS-1$ String tmp2 = encode(hash.doFinal()); StringBuffer tmp3 = new StringBuffer(tmp2.length() + nonce.length() + cnonce.length() + 2); tmp3.append(tmp2); tmp3.append(':'); tmp3.append(nonce); tmp3.append(':');
173174175176177178179180181182183
} hash.reset(); hash.putBytes(a1.getBytes("US-ASCII")); //$NON-NLS-1$ String md5a1 = encode(hash.doFinal()); String a2 = null; if (qopVariant == QOP_AUTH_INT) { // we do not have access to the entity-body or its hash // TODO: add Method ":" digest-uri-value ":" H(entity-body)
185186187188189190191192193194195
a2 = method + ":" + uri; //$NON-NLS-1$ } hash.reset(); hash.putBytes(a2.getBytes("US-ASCII")); //$NON-NLS-1$ String md5a2 = encode(hash.doFinal()); // 3.2.2.1 String serverDigestValue; if (qopVariant == QOP_MISSING) {
219220221222223224225226227228229
serverDigestValue = tmp2.toString(); } hash.reset(); hash.putBytes(serverDigestValue.getBytes("US-ASCII")); //$NON-NLS-1$ String serverDigest = encode(hash.doFinal()); return serverDigest; } public static String createCnonce() {
232233234235236237238239240241242
Hash hash = new Hash(new MD5Digest()); cnonce = Long.toString(System.currentTimeMillis()); hash.putBytes(cnonce.getBytes()); cnonce = encode(hash.doFinal()); return cnonce; } private static String encode(byte[] binaryData) {
223224225226227228229230231232233
private byte[] makePassphraseKey(String passphrase) { // Generate the key using the passphrase Hash md5 = new Hash("MD5"); md5.putBytes(passphrase.getBytes()); byte[] key1 = md5.doFinal(); md5.reset(); md5.putBytes(passphrase.getBytes()); md5.putBytes(key1); byte[] key2 = md5.doFinal();
228229230231232233234235236237238
byte[] key1 = md5.doFinal(); md5.reset(); md5.putBytes(passphrase.getBytes()); md5.putBytes(key1); byte[] key2 = md5.doFinal(); byte[] key = new byte[32]; System.arraycopy(key1, 0, key, 0, 16); System.arraycopy(key2, 0, key, 16, 16); return key;
6263646566676869707172
*/ public String getFingerprint() { Hash md5 = new Hash("MD5"); md5.putBytes(getEncoded()); byte[] digest = md5.doFinal(); int bits = getBitLength(); bits = (((bits % 8) != 0) ? (bits += (bits % 8)) : bits); String ret = String.valueOf(bits);
222223224225226227228229230231232
hash.putString(session.getId()); } hash.putInt(id); hash.putString(user.getPrincipalName()); hash.putString(address.getHostAddress()); byte[] tmp = hash.doFinal(); uid = Util.toHexString(tmp); CoreServlet.getServlet().addCoreListener(this); }