use of org.jdiameter.api.validation.Dictionary 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());
}
}
}
}
use of org.jdiameter.api.validation.Dictionary in project jain-slee.diameter by RestComm.
the class ValidatorImpl method validate.
/*
* (non-Javadoc)
*
* @see net.java.slee.resource.diameter.Validator#
* validate(net.java.slee.resource.diameter.base.events.avp.DiameterAvp)
*/
@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());
}
}
}
}
Aggregations