public DigestAuthenticationMechanism(final String realmName, final String domain, final String mechanismName, final IdentityManager identityManager) { this(Collections.singletonList(DigestAlgorithm.MD5), Collections.singletonList(DigestQop.AUTH), realmName, domain, new SimpleNonceManager(), DEFAULT_NAME, identityManager); }
return validateNonceWithCount(new Nonce(nonce), nonceCount, exchange.getIoThread()); Nonce value = verifyUnknownNonce(nonce, nonceCount); if (value == null) { return false; return addInvalidNonce(value, exchange.getIoThread()); } else { return validateNonceWithCount(value, nonceCount, exchange.getIoThread());
return createNewNonceString(); return createNewNonceString(); nonce = createNewNonceString(); } else { long now = System.currentTimeMillis(); Nonce replacement = createNewNonce(holder); if (value.executorKey != null) {
private byte[] generateHash(final byte[] prefix, final byte[] timeStamp) { MessageDigest digest = getDigest(hashAlg); digest.update(prefix); digest.update(timeStamp); return digest.digest(secret.getBytes(StandardCharsets.UTF_8)); }
private Nonce createNewNonce(NonceHolder previousNonce) { byte[] prefix = new byte[8]; random.nextBytes(prefix); long timeStamp = System.currentTimeMillis(); byte[] now = Long.toString(timeStamp).getBytes(StandardCharsets.UTF_8); String nonce = createNonce(prefix, now); return new Nonce(nonce, timeStamp, previousNonce); }
private String createNonce(final byte[] prefix, final byte[] timeStamp) { byte[] hashedPart = generateHash(prefix, timeStamp); byte[] complete = new byte[9 + timeStamp.length + hashedPart.length]; System.arraycopy(prefix, 0, complete, 0, 8); complete[8] = (byte) timeStamp.length; System.arraycopy(timeStamp, 0, complete, 9, timeStamp.length); System.arraycopy(hashedPart, 0, complete, 9 + timeStamp.length, hashedPart.length); return FlexBase64.encodeString(complete, false); }
private String createNewNonceString() { return createNewNonce(null).nonce; }
public SimpleNonceManager(final String hashAlg) { // Verify it is a valid algorithm (at least for now) MessageDigest digest = getDigest(hashAlg); this.hashAlg = hashAlg; this.hashLength = digest.getDigestLength(); // Create a new secret only valid within this NonceManager instance. Random rand = new SecureRandom(); byte[] secretBytes = new byte[32]; rand.nextBytes(secretBytes); secret = FlexBase64.encodeString(digest.digest(secretBytes), false); }
System.arraycopy(complete, offset + 9, timeStampBytes, 0, timeStampBytes.length); String expectedNonce = createNonce(prefix, timeStampBytes);
private String createNonce(final byte[] prefix, final byte[] timeStamp) { byte[] hashedPart = generateHash(prefix, timeStamp); byte[] complete = new byte[9 + timeStamp.length + hashedPart.length]; System.arraycopy(prefix, 0, complete, 0, 8); complete[8] = (byte) timeStamp.length; System.arraycopy(timeStamp, 0, complete, 9, timeStamp.length); System.arraycopy(hashedPart, 0, complete, 9 + timeStamp.length, hashedPart.length); return FlexBase64.encodeString(complete, false); }
private String createNewNonceString() { return createNewNonce(null).nonce; }
public DigestAuthenticationMechanism(final String realmName, final String domain, final String mechanismName, final IdentityManager identityManager, boolean validateUri) { this(Collections.singletonList(DigestAlgorithm.MD5), Collections.singletonList(DigestQop.AUTH), realmName, domain, new SimpleNonceManager(), DEFAULT_NAME, identityManager, validateUri); }
return validateNonceWithCount(new Nonce(nonce), nonceCount, exchange.getIoThread()); Nonce value = verifyUnknownNonce(nonce, nonceCount); if (value == null) { return false; return addInvalidNonce(value, exchange.getIoThread()); } else { return validateNonceWithCount(value, nonceCount, exchange.getIoThread());
return createNewNonceString(); return createNewNonceString(); nonce = createNewNonceString(); } else { long now = System.currentTimeMillis(); Nonce replacement = createNewNonce(holder); if (value.executorKey != null) {
private byte[] generateHash(final byte[] prefix, final byte[] timeStamp) { MessageDigest digest = getDigest(hashAlg); digest.update(prefix); digest.update(timeStamp); return digest.digest(secret.getBytes(StandardCharsets.UTF_8)); }
private Nonce createNewNonce(NonceHolder previousNonce) { byte[] prefix = new byte[8]; random.nextBytes(prefix); long timeStamp = System.currentTimeMillis(); byte[] now = Long.toString(timeStamp).getBytes(StandardCharsets.UTF_8); String nonce = createNonce(prefix, now); return new Nonce(nonce, timeStamp, previousNonce); }
private String createNonce(final byte[] prefix, final byte[] timeStamp) { byte[] hashedPart = generateHash(prefix, timeStamp); byte[] complete = new byte[9 + timeStamp.length + hashedPart.length]; System.arraycopy(prefix, 0, complete, 0, 8); complete[8] = (byte) timeStamp.length; System.arraycopy(timeStamp, 0, complete, 9, timeStamp.length); System.arraycopy(hashedPart, 0, complete, 9 + timeStamp.length, hashedPart.length); return FlexBase64.encodeString(complete, false); }
private String createNewNonceString() { return createNewNonce(null).nonce; }
public DigestAuthenticationMechanism(final String realmName, final String domain, final String mechanismName, final IdentityManager identityManager) { this(Collections.singletonList(DigestAlgorithm.MD5), Collections.singletonList(DigestQop.AUTH), realmName, domain, new SimpleNonceManager(), DEFAULT_NAME, identityManager); }
return validateNonceWithCount(new Nonce(nonce), nonceCount, exchange.getIoThread()); Nonce value = verifyUnknownNonce(nonce, nonceCount); if (value == null) { return false; return addInvalidNonce(value, exchange.getIoThread()); } else { return validateNonceWithCount(value, nonceCount, exchange.getIoThread());