EncryptedExtensionsHandler extends HandshakeMessageHandler<EncryptedExtensionsMessage> { @Override public void adjustTLSContext(EncryptedExtensionsMessage message) { if (message.getExtensions() != null) { LOGGER.debug("Adjusting for EncryptedExtensions:"); for (ExtensionMessage extension : message.getExtensions()) { LOGGER.debug("Adjusting " + message.toCompactString()); HandshakeMessageType handshakeMessageType = HandshakeMessageType.ENCRYPTED_EXTENSIONS; if (extension instanceof HRRKeyShareExtensionMessage) { handshakeMessageType = HandshakeMessageType.HELLO_RETRY_REQUEST; } ExtensionHandler handler = HandlerFactory.getExtensionHandler(tlsContext, extension.getExtensionTypeConstant(), handshakeMessageType); handler.adjustTLSContext(extension); } } } EncryptedExtensionsHandler(TlsContext tlsContext); @Override EncryptedExtensionsParser getParser(byte[] message, int pointer); @Override EncryptedExtensionsPreparator getPreparator(EncryptedExtensionsMessage message); @Override EncryptedExtensionsSerializer getSerializer(EncryptedExtensionsMessage message); @Override void adjustTLSContext(EncryptedExtensionsMessage message);  }
@Test public void testAdjustTLSContextWithoutExtensions() { EncryptedExtensionsMessage message = new EncryptedExtensionsMessage(); handler.adjustTLSContext(message); assertTrue(context.getProposedExtensions().isEmpty()); assertTrue(context.getNegotiatedExtensionSet().isEmpty()); }
@Test public void testAdjustTLSContextWithSNI() { EncryptedExtensionsMessage message = new EncryptedExtensionsMessage(); message.addExtension(new ServerNameIndicationExtensionMessage()); handler.adjustTLSContext(message); assertTrue(context.isExtensionNegotiated(ExtensionType.SERVER_NAME_INDICATION)); }