HelloRetryRequestHandler extends HandshakeMessageHandler<HelloRetryRequestMessage> { @Override public void adjustTLSContext(HelloRetryRequestMessage message) { adjustProtocolVersion(message); adjustSelectedCiphersuite(message); if (message.getExtensions() != null) { for (ExtensionMessage extension : message.getExtensions()) { HandshakeMessageType handshakeMessageType = HandshakeMessageType.HELLO_RETRY_REQUEST; if (extension instanceof KeyShareExtensionMessage) { handshakeMessageType = HandshakeMessageType.CLIENT_HELLO; } ExtensionHandler handler = HandlerFactory.getExtensionHandler(tlsContext, extension.getExtensionTypeConstant(), handshakeMessageType); handler.adjustTLSContext(extension); } } } HelloRetryRequestHandler(TlsContext tlsContext); @Override HelloRetryRequestParser getParser(byte[] message, int pointer); @Override HelloRetryRequestPreparator getPreparator(HelloRetryRequestMessage message); @Override HelloRetryRequestSerializer getSerializer(HelloRetryRequestMessage message); @Override void adjustTLSContext(HelloRetryRequestMessage message);  }
@Test public void testAdjustTLSContext() { HelloRetryRequestMessage message = new HelloRetryRequestMessage(); ExtensionMessage extensionMessage = new EncryptThenMacExtensionMessage(); ProtocolVersion protocolVersion = ProtocolVersion.SSL2; CipherSuite cipherSuite = CipherSuite.TLS_DH_DSS_WITH_DES_CBC_SHA; ExtensionType extensionType = ExtensionType.ENCRYPT_THEN_MAC; message.setProtocolVersion(protocolVersion.getValue()); message.setSelectedCipherSuite(cipherSuite.getByteValue()); message.setExtensionBytes(extensionType.getValue()); message.addExtension(extensionMessage); handler.adjustTLSContext(message); assertSame(context.getSelectedProtocolVersion(), protocolVersion); assertSame(context.getSelectedCipherSuite(), cipherSuite); assertTrue(context.isExtensionProposed(extensionType)); }