@Override public boolean sendMessage(IMessage message) throws TransportException, OverloadException, InternalException { if (dictionary != null && dictionary.isEnabled()) { logger.debug("Message validation is ENABLED. Going to validate message before sending."); dictionary.validate(message, false); } return !stopping && fsm.handleEvent(new FsmEvent(EventTypes.SEND_MSG_EVENT, message)); }
static void init(String clazz, boolean validatorEnabled, ValidatorLevel validatorSendLevel, ValidatorLevel validatorReceiveLevel) throws InternalException { try { Class.forName(clazz).getMethod("getInstance", String.class).invoke(null, new Object[] {null}); DictionaryImpl.INSTANCE.setEnabled(validatorEnabled); DictionaryImpl.INSTANCE.setSendLevel(validatorSendLevel); DictionaryImpl.INSTANCE.setReceiveLevel(validatorReceiveLevel); } catch (Exception e) { throw new InternalException(e); } } }
if (!dictionary.isEnabled()) { Message msg = (Message) parent; MessageRepresentation msgRep = dictionary.getMessage(msg.getCommandCode(), msg.getApplicationId(), msg.isRequest()); GroupedAvpImpl gAvp = (GroupedAvpImpl) parent; org.jdiameter.api.validation.AvpRepresentation parentAvpRep = dictionary.getAvp(gAvp.getCode(), gAvp.getVendorId()); org.jdiameter.api.validation.AvpRepresentation avpRep = dictionary.getAvp(avpCode, vendorId);
@Override public void validate(DiameterAvp avp) throws AvpNotAllowedException { Dictionary dictionary = DictionarySingleton.getDictionary(); if (dictionary.isConfigured() && dictionary.isEnabled()) { AvpRepresentation rep = dictionary.getAvp(avp.getCode(), avp.getVendorId()); // check for grouped? if (rep != null && rep.isGrouped()) { try { GroupedAvpImpl impl = (GroupedAvpImpl) avp; rep.validate(impl.getGenericData()); } catch (ClassCastException cce) { throw new AvpNotAllowedException("Failed to validate avp, its not grouped!", cce, avp.getCode(), avp.getVendorId()); } } } }
@Override public void validate(DiameterMessage msg) throws AvpNotAllowedException { Dictionary dictionary = DictionarySingleton.getDictionary(); if (dictionary.isConfigured() && dictionary.isEnabled()) { DiameterCommand com = msg.getCommand(); MessageRepresentation rep = dictionary.getMessage(com.getCode(), com.getApplicationId(), com.isRequest()); if (rep != null) { DiameterMessageImpl impl = (DiameterMessageImpl) msg; try { rep.validate(impl.getGenericData(), ValidatorLevel.ALL); } catch (org.jdiameter.api.validation.AvpNotAllowedException e) { throw new AvpNotAllowedException("Failed to validate message.", e, e.getAvpCode(), e.getVendorId()); } } } }
ValidatorLevel incomingLevel = dictionary.getReceiveLevel(); if (incoming && dictionary != null && dictionary.isEnabled() && incomingLevel != ValidatorLevel.OFF) { logger.debug("Performing validation to INCOMING message since validator is ENABLED."); dictionary.validate((Message) event.getData(), incoming); new Object[] { (dictionary != null && dictionary.isEnabled()), incoming, incomingLevel });
if (!dictionary.isEnabled()) { Message msg = (Message) parent; MessageRepresentation msgRep = dictionary.getMessage(msg.getCommandCode(), msg.getApplicationId(), msg.isRequest()); GroupedAvpImpl gAvp = (GroupedAvpImpl) parent; org.jdiameter.api.validation.AvpRepresentation parentAvpRep = dictionary.getAvp(gAvp.getCode(), gAvp.getVendorId()); org.jdiameter.api.validation.AvpRepresentation avpRep = dictionary.getAvp(avpCode, vendorId);