Skip to content

Commit

Permalink
[AS7-1837] Switch to use the HexConverter provided through JBoss SASL…
Browse files Browse the repository at this point in the history
… instead of a local duplicate.
  • Loading branch information
darranl authored and stuartwdouglas committed Sep 22, 2011
1 parent a1c2652 commit 77df53b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
import java.util.Map;

import org.jboss.as.domain.management.security.UserNotFoundException;
import org.jboss.as.domain.management.util.HexUtil;
import org.jboss.com.sun.net.httpserver.Authenticator;
import org.jboss.com.sun.net.httpserver.Headers;
import org.jboss.com.sun.net.httpserver.HttpExchange;
import org.jboss.com.sun.net.httpserver.HttpPrincipal;
import org.jboss.logging.Logger;
import org.jboss.sasl.util.HexConverter;

/**
* An authenticator to handle Digest authentication.
Expand Down Expand Up @@ -176,21 +176,21 @@ private HttpPrincipal validateUser(HttpExchange httpExchange, Map<String, String
md.update(COLON);
md.update(new String(pcb.getPassword()).getBytes());

byte[] ha1 = HexUtil.convertToHexBytes(md.digest());
byte[] ha1 = HexConverter.convertToHexBytes(md.digest());

md.update(httpExchange.getRequestMethod().getBytes());
md.update(COLON);
md.update(challengeParameters.get(URI).getBytes());

byte[] ha2 = HexUtil.convertToHexBytes(md.digest());
byte[] ha2 = HexConverter.convertToHexBytes(md.digest());

md.update(ha1);
md.update(COLON);
md.update(challengeParameters.get(NONCE).getBytes());
md.update(COLON);
md.update(ha2);

byte[] expectedResponse = HexUtil.convertToHexBytes(md.digest());
byte[] expectedResponse = HexConverter.convertToHexBytes(md.digest());
byte[] actualResponse = challengeParameters.get(RESPONSE).getBytes();

if (MessageDigest.isEqual(expectedResponse, actualResponse)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.HashSet;
import java.util.Set;

import org.jboss.as.domain.management.util.HexUtil;
import org.jboss.sasl.util.HexConverter;

/**
* A simple NonceFactory for single use nonces.
Expand Down Expand Up @@ -55,7 +55,7 @@ public class NonceFactory {
public String createNonce() {
byte[] newNonce = new byte[NONCE_BYTES];
srand.nextBytes(newNonce);
String nonceString = HexUtil.convertToHexString(newNonce);
String nonceString = HexConverter.convertToHexString(newNonce);
synchronized (issuedNonces) {
issuedNonces.add(nonceString);
}
Expand Down

This file was deleted.

0 comments on commit 77df53b

Please sign in to comment.