ServerNameIndicationExtensionParser extends ExtensionParser<ServerNameIndicationExtensionMessage> { @Override public void parseExtensionMessageContent(ServerNameIndicationExtensionMessage msg) { if (msg.getExtensionLength().getValue() > 0) { parseServerNameListLength(msg); parseServerNameListBytes(msg); int position = 0; pairList = new LinkedList<>(); while (position < msg.getServerNameListLength().getValue()) { ServerNamePairParser parser = new ServerNamePairParser(position, msg.getServerNameListBytes() .getValue()); pairList.add(parser.parse()); if (position == parser.getPointer()) { throw new ParserException("Ran into infinite Loop while parsing ServerNamePair"); } position = parser.getPointer(); } parseServerNameList(msg); } else { LOGGER.debug("Received empty SNI Extension"); } } ServerNameIndicationExtensionParser(int startposition, byte[] array); @Override void parseExtensionMessageContent(ServerNameIndicationExtensionMessage msg);  }
@Test public void testParseExtensionMessageContent() { ServerNameIndicationExtensionParser parser = new ServerNameIndicationExtensionParser(start, extension); ServerNameIndicationExtensionMessage msg = parser.parse(); assertArrayEquals(msg.getExtensionBytes().getValue(), completeExtension); assertArrayEquals(type.getValue(), msg.getExtensionType().getValue()); assertEquals(extensionLength, msg.getExtensionLength().getValue().intValue()); assertArrayEquals(msg.getServerNameListBytes().getValue(), sniListBytes); assertEquals(sniListLength, msg.getServerNameListLength().getValue().intValue()); }