WorkflowConfigurationFactory { public WorkflowTrace createWorkflowTrace(WorkflowTraceType type, RunningModeType mode) { this.mode = mode; switch (type) { case HELLO: return createHelloWorkflow(); case FULL: return createFullWorkflow(); case HANDSHAKE: return createHandshakeWorkflow(); case SHORT_HELLO: return createShortHelloWorkflow(); case SSL2_HELLO: return createSsl2HelloWorkflow(); case CLIENT_RENEGOTIATION_WITHOUT_RESUMPTION: return createClientRenegotiationWorkflow(); case CLIENT_RENEGOTIATION: return createClientRenegotiationWithResumptionWorkflow(); case SERVER_RENEGOTIATION: return createServerRenegotiationWorkflow(); case HTTPS: return createHttpsWorkflow(); case RESUMPTION: return createResumptionWorkflow(); case FULL_RESUMPTION: return createFullResumptionWorkflow(); case SIMPLE_MITM_PROXY: return createSimpleMitmProxyWorkflow(); case ZERO_RTT: return createZeroRttWorkflow(); case FULL_ZERO_RTT: return createFullZeroRttWorkflow(); case FALSE_START: return createFalseStartWorkflow(); case RSA_SYNC_PROXY: return createSyncProxyWorkflow(); case DYNAMIC_HANDSHAKE: return createDynamicHandshakeWorkflow(); case DYNAMIC_HELLO: return createDynamicHelloWorkflow(); } throw new ConfigurationException("Unknown WorkflowTraceType " + type.name()); } WorkflowConfigurationFactory(Config config); WorkflowTrace createWorkflowTrace(WorkflowTraceType type, RunningModeType mode); WorkflowTrace createTlsEntryWorkflowtrace(AliasedConnection connection); WorkflowTrace createHelloWorkflow(AliasedConnection connection); boolean shouldServerSendACertificate(CipherSuite suite); ClientKeyExchangeMessage createClientKeyExchangeMessage(KeyExchangeAlgorithm algorithm); ServerKeyExchangeMessage createServerKeyExchangeMessage(KeyExchangeAlgorithm algorithm); void addClientKeyExchangeMessage(List<ProtocolMessage> messages); void addServerKeyExchangeMessage(List<ProtocolMessage> messages); WorkflowTrace addStartTlsActions(AliasedConnection connection, StarttlsType type, WorkflowTrace workflowTrace);  }
@Test @Ignore public void testCreateWorkflowTrace() { RunningModeType mode = RunningModeType.CLIENT; final WorkflowTrace hello0 = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.HELLO, mode); final WorkflowTrace hello1 = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.HELLO, mode); Assert.assertTrue(workflowTracesEqual(hello0, hello1)); final List<WorkflowTrace> list = new ArrayList<>(WorkflowTraceType.values().length); for (WorkflowTraceType workflowTraceType : WorkflowTraceType.values()) { if (workflowTraceType == WorkflowTraceType.SIMPLE_MITM_PROXY) { mode = RunningModeType.MITM; } else { mode = RunningModeType.CLIENT; } if (workflowTraceType == WorkflowTraceType.DYNAMIC_HELLO && mode != RunningModeType.CLIENT) { continue; } WorkflowTrace newTrace = workflowConfigurationFactory.createWorkflowTrace(workflowTraceType, mode); Assert.assertNotNull(newTrace.getMessageActions()); Assert.assertFalse(newTrace.getMessageActions().isEmpty()); for (MessageAction action : newTrace.getMessageActions()) { if (action instanceof ReceiveAction) { Assert.assertNotNull(((ReceiveAction) action).getExpectedMessages()); Assert.assertFalse(((ReceiveAction) action).getExpectedMessages().isEmpty()); } else { Assert.assertNotNull(action.getMessages()); Assert.assertFalse(action.getMessages().isEmpty()); } } for (WorkflowTrace trace : list) { if (workflowTracesEqual(trace, newTrace)) { Assert.fail(MessageFormat.format( "The WorkflowConfigurationFactory is expected to produce different WorkflowTraces " + "for each WorkflowTraceType but there is a duplicate pair: {0} {1}", trace, newTrace)); } } list.add(newTrace); } }
@Test public void testNoExceptions() { for (CipherSuite suite : CipherSuite.getImplemented()) { for (ProtocolVersion version : ProtocolVersion.values()) { for (WorkflowTraceType type : WorkflowTraceType.values()) { try { config.setDefaultSelectedCipherSuite(suite); config.setSupportedVersions(version); config.setHighestProtocolVersion(version); config.setDefaultServerSupportedCiphersuites(suite); config.setDefaultClientSupportedCiphersuites(suite); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); config.setDefaultRunningMode(RunningModeType.CLIENT); workflowConfigurationFactory.createWorkflowTrace(type, RunningModeType.CLIENT); if (type == WorkflowTraceType.DYNAMIC_HELLO) { continue; } config.setDefaultRunningMode(RunningModeType.SERVER); workflowConfigurationFactory.createWorkflowTrace(type, RunningModeType.SERVER); config.setDefaultRunningMode(RunningModeType.MITM); workflowConfigurationFactory.createWorkflowTrace(type, RunningModeType.MITM); } catch (ConfigurationException E) { } } } } }
@Test public void testAddStartTlsAction() { config.setStarttlsType(StarttlsType.FTP); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); WorkflowTrace workflowTrace = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.HELLO, RunningModeType.CLIENT); Assert.assertEquals(GenericReceiveAsciiAction.class, workflowTrace.getTlsActions().get(0).getClass()); Assert.assertEquals(SendAsciiAction.class, workflowTrace.getTlsActions().get(1).getClass()); Assert.assertEquals(GenericReceiveAsciiAction.class, workflowTrace.getTlsActions().get(2).getClass()); config.setStarttlsType(StarttlsType.IMAP); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); workflowTrace = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.HELLO, RunningModeType.CLIENT); Assert.assertEquals(GenericReceiveAsciiAction.class, workflowTrace.getTlsActions().get(0).getClass()); Assert.assertEquals(SendAsciiAction.class, workflowTrace.getTlsActions().get(1).getClass()); Assert.assertEquals(GenericReceiveAsciiAction.class, workflowTrace.getTlsActions().get(2).getClass()); config.setStarttlsType(StarttlsType.POP3); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); workflowTrace = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.HELLO, RunningModeType.CLIENT); Assert.assertEquals(GenericReceiveAsciiAction.class, workflowTrace.getTlsActions().get(0).getClass()); Assert.assertEquals(SendAsciiAction.class, workflowTrace.getTlsActions().get(1).getClass()); Assert.assertEquals(GenericReceiveAsciiAction.class, workflowTrace.getTlsActions().get(2).getClass()); config.setStarttlsType(StarttlsType.SMTP); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); workflowTrace = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.HELLO, RunningModeType.CLIENT); Assert.assertEquals(GenericReceiveAsciiAction.class, workflowTrace.getTlsActions().get(0).getClass()); Assert.assertEquals(SendAsciiAction.class, workflowTrace.getTlsActions().get(1).getClass()); Assert.assertEquals(GenericReceiveAsciiAction.class, workflowTrace.getTlsActions().get(2).getClass()); Assert.assertEquals(SendAsciiAction.class, workflowTrace.getTlsActions().get(3).getClass()); Assert.assertEquals(GenericReceiveAsciiAction.class, workflowTrace.getTlsActions().get(4).getClass()); }