Search in sources :

Example 1 with DiameterCommand

use of net.java.slee.resource.diameter.base.events.DiameterCommand in project jain-slee.diameter by RestComm.

the class ValidatorImpl method validate.

// NOTE: this class possibly should be Singleton, however some impl may use something more to perform validation
// hence, its not static, each RA provides instance through RA Sbb Interface.
/*
   * (non-Javadoc)
   * 
   * @see
   * net.java.slee.resource.diameter.Validator#validate(net.java.slee.resource
   * .diameter.base.events.DiameterMessage)
   */
@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());
            }
        }
    }
}
Also used : DiameterCommand(net.java.slee.resource.diameter.base.events.DiameterCommand) Dictionary(org.jdiameter.api.validation.Dictionary) MessageRepresentation(org.jdiameter.api.validation.MessageRepresentation) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Aggregations

DiameterCommand (net.java.slee.resource.diameter.base.events.DiameterCommand)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 Dictionary (org.jdiameter.api.validation.Dictionary)1 MessageRepresentation (org.jdiameter.api.validation.MessageRepresentation)1 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)1