ActivateEncryptionAction extends ConnectionBoundAction { @Override public void execute(State state) throws WorkflowExecutionException { TlsContext tlsContext = state.getTlsContext(getConnectionAlias()); if (isExecuted()) { throw new WorkflowExecutionException("Action already executed!"); } KeySet keySet; try { keySet = KeySetGenerator.generateKeySet(tlsContext); } catch (NoSuchAlgorithmException | CryptoException ex) { throw new UnsupportedOperationException("The specified Algorithm is not supported", ex); } LOGGER.debug("Setting new Cipher in RecordLayer"); RecordCipher recordCipher = RecordCipherFactory.getRecordCipher(tlsContext, keySet); tlsContext.getRecordLayer().setRecordCipher(recordCipher); tlsContext.getRecordLayer().updateDecryptionCipher(); tlsContext.setReadSequenceNumber(0); tlsContext.getRecordLayer().updateEncryptionCipher(); tlsContext.setWriteSequenceNumber(0); LOGGER.info("Activated Encryption/Decryption"); setExecuted(true); } ActivateEncryptionAction(); @Override boolean equals(Object o); @Override void execute(State state); @Override void reset(); @Override boolean executedAsPlanned();  }
@Test public void testExecute() throws Exception { action.execute(state); assertTrue(action.isExecuted()); TlsRecordLayer layer = TlsRecordLayer.class.cast(tlsContext.getRecordLayer()); assertFalse(layer.getRecordCipher() instanceof RecordNullCipher); assertFalse(layer.getEncryptorCipher() instanceof RecordNullCipher); assertFalse(layer.getDecryptorCipher() instanceof RecordNullCipher); }