private void validateResponseValue(byte[] fromServer) throws SaslException {
  if (fromServer == null) {
    throw new SaslException("DIGEST-MD5: Authenication failed. " + "Expecting 'rspauth' authentication success message");
  }
  try {
    byte[] expected=generateResponseValue("",digestUri,negotiatedQop,username,negotiatedRealm,passwd,nonce,cnonce,nonceCount,authzidBytes);
    if (!Arrays.equals(expected,fromServer)) {
      throw new SaslException("Server's rspauth value does not match what client expects");
    }
  }
 catch (  NoSuchAlgorithmException e) {
    throw new SaslException("Problem generating response value for verification",e);
  }
catch (  IOException e) {
    throw new SaslException("Problem generating response value for verification",e);
  }
}

private void validateResponseValue ( byte [ ] fromServer ) throws SaslException { if ( fromServer == null ) { throw new SaslException ( "DIGEST-MD5: Authenication failed. " + "Expecting 'rspauth' authentication success message" ) ; } try { byte [ ] expected = generateResponseValue ( "" , digestUri , negotiatedQop , username , negotiatedRealm , passwd , nonce , cnonce , nonceCount , authzidBytes ) ; if ( ! Arrays . equals ( expected , fromServer ) ) { throw new SaslException ( "Server's rspauth value does not match what client expects" ) ; } } catch ( NoSuchAlgorithmException e ) { throw new SaslException ( "Problem generating response value for verification" , e ) ; } catch ( IOException e ) { throw new SaslException ( "Problem generating response value for verification" , e ) ; } }
from rfc 2831 , section 2 . 1 . 3 : step three [ server ] sends a message formatted as follows : response - auth = " rspauth " " = " response - value where response - value is calculated as above , using the values sent in step two , except that if qop is " auth " , then a2 is a2 = { " : " , digest - uri - value } and if qop is " auth - int " or " auth - conf " then a2 is a2 = { " : " , digest - uri - value , " : 00000000000000000000000000000000 " }
