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 .