public void visit(InitSessionResponseMessage message) { LOGGER.debug("Process InitSessionResponseMessage: " + message); remoteSourceJobId_ = message.getSourceJobId(); InitSessionObject initSessionObject = null; initSessionContext_.acquireReadLock(); try { initSessionObject = initSessionContext_.tryGetInitSessionObject(sessionId_); } catch (SessionRuntimeException e) { endWithErrorAndClear(e, ErrorNotificationMethod.ALL); return; } finally { initSessionContext_.releaseReadLock(); } try { DiffieHellmanResponsePackage diffieHellmanResponsePackage = (DiffieHellmanResponsePackage) encryptionAPI_.decrypt(message.getEncryptedData(), privateKeyPeerId_); KeyAgreement keyAgreement = DiffieHellmanProtocol.thirdStepDHKeyAgreement( initSessionObject.getKeyAgreement(), diffieHellmanResponsePackage); initSessionObject.setSessionKey( DiffieHellmanProtocol.fourthStepDHKeyAgreement(keyAgreement)); InitSessionEndMessage initSessionEndMessage = new InitSessionEndMessage(initSessionObject, getJobId()); outQueue_.add(initSessionEndMessage); if (peerAddress_.equals(myAddress_)) { endWithSuccess(); } else { endWithSuccessAndClear(); } } catch (CryptoException e) { endWithErrorAndClear(e, ErrorNotificationMethod.ALL); } }