public void onConnection() throws CommunicationException { Handshake handshake = new Handshake(); handshake.setAuthType(csr.getAuthenticationType()); if (usingEncryption) { keyGen = new DhKeyGenerator(); byte[] publicKey; try { publicKey = keyGen.createPublicKey(); } catch (CryptoException e) { throw new CommunicationException(RuntimePlugin.Event.TEIID40051, e); } handshake.setPublicKey(publicKey); } this.objectSocket.write(handshake); }