AlertHandler extends ProtocolMessageHandler<AlertMessage> { @Override public void adjustTLSContext(AlertMessage message) { if (tlsContext.getTalkingConnectionEndType() == tlsContext.getChooser().getMyConnectionPeer() && AlertLevel.FATAL.getValue() == message.getLevel().getValue()) { LOGGER.debug("Setting received Fatal Alert in Context"); tlsContext.setReceivedFatalAlert(true); } } AlertHandler(TlsContext tlsContext); @Override AlertParser getParser(byte[] message, int pointer); @Override AlertPreparator getPreparator(AlertMessage message); @Override AlertSerializer getSerializer(AlertMessage message); @Override void adjustTLSContext(AlertMessage message);  }
@Test public void testAdjustTLSContext() { context.setConnection(new OutboundConnection()); context.setTalkingConnectionEndType(ConnectionEndType.SERVER); AlertMessage message = new AlertMessage(); message.setDescription(AlertDescription.ACCESS_DENIED.getValue()); message.setLevel(AlertLevel.WARNING.getValue()); handler.adjustTLSContext(message); assertFalse(context.isReceivedFatalAlert()); message.setLevel(AlertLevel.FATAL.getValue()); handler.adjustTLSContext(message); assertTrue(context.isReceivedFatalAlert()); }