Buggy code:
public class Client implements IClientCli , Runnable { private final int WAITING_FOR_AUTHENTICATION = 0 ; private final int AUTHENTICATED = 2 ; private final String B64 = "a-zA-Z0-9//+" ; private int status = WAITING_FOR_AUTHENTICATION ; private PrintWriter tcpOutputStream ; private Socket tcpSocket ; private DatagramSocket udpSocket ; private ServerSocket srvSocket ; private Logger logger = new Logger ( ) ; private Config config ; private Shell shell ; private boolean active = false ; private String lastMsg = "" ; private List < TcpWorker > tcpWorkerList = Collections . synchronizedList ( new ArrayList < TcpWorker > ( ) ) ; private ExecutorService threadPool = Executors . newCachedThreadPool ( ) ; private Thread tcpReaderThread ; private Thread udpReaderThread ; private TcpReader tcpReader ; private UdpReader udpReader ; private HashMAC hashMAC ; private SecurityTool security ; public Client ( String componentName , Config config , InputStream userRequestStream , PrintStream userResponseStream ) { } private void acquirePorts ( ) throws IOException { } public HashMAC getHashMAC ( ) { } @ Override public void run ( ) { } public ExecutorService getThreadPool ( ) { } public Shell getShell ( ) { } @ Override public String login ( String username , String password ) throws IOException { } @ Override @ Command public String logout ( ) throws IOException { } @ Override @ Command public String send ( String message ) throws IOException { } @ Override @ Command public String list ( ) throws IOException { } @ Override @ Command public String msg ( String receiver , String message ) throws IOException { } @ Override @ Command public String lookup ( String username ) throws IOException { } @ Override @ Command public String register ( String address ) throws IOException { } public void setLastMsg ( String message ) { } @ Override @ Command public String lastMsg ( ) throws IOException { } @ Override @ Command public String exit ( ) throws IOException { } private void cleanUp ( ) throws IOException { } public boolean isActive ( ) { } public List < TcpWorker > getTcpWorkerList ( ) { } public static void main ( String [ ] args ) throws Exception { } @ Override @ Command public String authenticate ( String username ) throws IOException { if ( ( status ) == ( AUTHENTICATED ) ) return "You<seq2seq4repair_space>are<seq2seq4repair_space>already<seq2seq4repair_space>logged<seq2seq4repair_space>in" ; <START_BUG> KeyInformations keyPaths = new KeyInformations ( ( ( ( ( config . getString ( "keys.dir" ) ) + ( File . pathSeparator ) ) + username ) + ".pem" ) , config . getString ( "chatserver.key" ) ) ; <END_BUG> security = new SecurityTool ( tcpOutputStream , keyPaths ) ; tcpReader . setSecurity ( security ) ; SecureRandom secureRandom = new SecureRandom ( ) ; final byte [ ] challenge = new byte [ 32 ] ; secureRandom . nextBytes ( challenge ) ; byte [ ] base64Challenge = Base64 . encode ( challenge ) ; security . printlnRSA ( ( ( ( "!authenticate<seq2seq4repair_space>" + username ) + "<seq2seq4repair_space>" ) + ( new String ( base64Challenge , StandardCharsets . UTF_8 ) ) ) ) ; String response = getResponse ( ) ; if ( response . startsWith ( "!Error" ) ) { return response ; } try { response = security . decode ( response , "RSA" ) ; } catch ( Exception e ) { logger . exception ( e ) ; return null ; } assert response . matches ( ( ( ( ( ( ( ( ( "!ok<seq2seq4repair_space>[" + ( B64 ) ) + "]{43}=<seq2seq4repair_space>[" ) + ( B64 ) ) + "]{43}=<seq2seq4repair_space>[" ) + ( B64 ) ) + "]{43}=<seq2seq4repair_space>[" ) + ( B64 ) ) + "]{22}==" ) ) : "2nd<seq2seq4repair_space>message" ; String [ ] message = response . split ( "<seq2seq4repair_space>" ) ; if ( ( ! ( message [ 1 ] . equals ( new String ( base64Challenge , StandardCharsets . UTF_8 ) ) ) ) || ( ! ( message [ 0 ] . equals ( "!ok" ) ) ) ) { tcpOutputStream . println ( "!Error:<seq2seq4repair_space>Wrong<seq2seq4repair_space>challenge<seq2seq4repair_space>response.<seq2seq4repair_space>Authentication<seq2seq4repair_space>failed." ) ; return "Can't<seq2seq4repair_space>assure<seq2seq4repair_space>safe<seq2seq4repair_space>connection<seq2seq4repair_space>to<seq2seq4repair_space>server.<seq2seq4repair_space>Authentication<seq2seq4repair_space>failed." ; } security . setSecretKey ( new SecretKeySpec ( Base64 . decode ( message [ 3 ] . getBytes ( StandardCharsets . UTF_8 ) ) , "AES" ) ) ; security . setIvVector ( Base64 . decode ( message [ 4 ] . getBytes ( StandardCharsets . UTF_8 ) ) ) ; security . println ( message [ 2 ] ) ; try { response = security . decode ( getResponse ( ) , "AES" ) ; } catch ( Exception e ) { logger . exception ( e ) ; return null ; } if ( response . startsWith ( "!Error" ) ) { return response ; } tcpReader . setStatus ( AUTHENTICATED ) ; status = AUTHENTICATED ; return response ; } private String getResponse ( ) { } }

Fix:
KeyInformations keyPaths = new KeyInformations ( ( ( ( ( config . getString ( "keys.dir" ) ) + ( File . separator ) ) + username ) + ".pem" ) , config . getString ( "chatserver.key" ) ) ;