public String createResponse(String challenge)
      throws IllegalArgumentException, KeyNotFoundException, ProtocolVersionException {
    byte[] decodedChallenge = decode(challenge);
    Challenge deserializedChallenge = CrtAuthCodec.deserializeChallenge(decodedChallenge);
    if (!deserializedChallenge.getServerName().equals(serverName)) {
      throw new IllegalArgumentException(
          String.format("Server name mismatch (%s != %s). Possible MITM attack.",
                        deserializedChallenge.getServerName(), serverName)
      );
    }
    byte[] signature = signer.sign(decodedChallenge, deserializedChallenge.getFingerprint());
    return encode(CrtAuthCodec.serialize(new Response(decodedChallenge, signature)));
  }
public String createResponse ( String challenge ) throws IllegalArgumentException , KeyNotFoundException , ProtocolVersionException { byte [ ] decodedChallenge = decode ( challenge ) ; Challenge deserializedChallenge = CrtAuthCodec . deserializeChallenge ( decodedChallenge ) ; if ( ! deserializedChallenge . getServerName ( ) . equals ( serverName ) ) { throw new IllegalArgumentException ( String . format ( "Server name mismatch (%s != %s). Possible MITM attack." , deserializedChallenge . getServerName ( ) , serverName ) ) ; } byte [ ] signature = signer . sign ( decodedChallenge , deserializedChallenge . getFingerprint ( ) ) ; return encode ( CrtAuthCodec . serialize ( new Response ( decodedChallenge , signature ) ) ) ; }
Generate a response String using the Signer of this instance, additionally verifying that the
embedded serverName matches the serverName of this instance.

@param challenge A challenge String obtained from a server.
@return The response String to be returned to the server.
@throws IllegalArgumentException if there is something wrong with the challenge.