use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class S6aServerSessionImpl method createAuthenticationInformationAnswer.
public AuthenticationInformationAnswer createAuthenticationInformationAnswer() {
// Make sure we have the correct type of Request
if (!(lastRequest instanceof AuthenticationInformationRequest)) {
logger.warn("Invalid type of answer for this activity.");
return null;
}
try {
// Create the answer
AuthenticationInformationAnswer aia = (AuthenticationInformationAnswer) this.s6aMessageFactory.createS6aMessage(lastRequest.getHeader(), new DiameterAvp[] {}, AuthenticationInformationAnswer.COMMAND_CODE, s6aMessageFactory.getApplicationId());
// Fill session related AVPs, if present
fillSessionAVPs(aia);
return aia;
} catch (InternalException e) {
logger.error("Failed to create Authentication-Information-Answer.", e);
}
return null;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class RoMessageFactoryImpl method addAvp.
protected void addAvp(DiameterAvp avp, AvpSet set) {
// proper function?
if (avp instanceof GroupedAvp) {
AvpSet avpSet = set.addGroupedAvp(avp.getCode(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
DiameterAvp[] groupedAVPs = ((GroupedAvp) avp).getExtensionAvps();
for (DiameterAvp avpFromGroup : groupedAVPs) {
addAvp(avpFromGroup, avpSet);
}
} else if (avp != null) {
set.addAvp(avp.getCode(), avp.byteArrayValue(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
}
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class RoMessageFactoryImpl method createMessage.
public Message createMessage(DiameterHeader header, DiameterAvp[] avps) throws AvpNotAllowedException {
Message msg = createRawMessage(header);
AvpSet set = msg.getAvps();
for (DiameterAvp avp : avps) {
addAvp(avp, set);
}
return msg;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class RxMessageFactoryImpl method addAvp.
protected void addAvp(DiameterAvp avp, AvpSet set) {
if (avp instanceof GroupedAvp) {
AvpSet avpSet = set.addGroupedAvp(avp.getCode(), avp.getVendorId(), avp.getMandatoryRule() != DiameterAvp.FLAG_RULE_MUSTNOT, avp.getProtectedRule() == DiameterAvp.FLAG_RULE_MUST);
DiameterAvp[] groupedAVPs = ((GroupedAvp) avp).getExtensionAvps();
for (DiameterAvp avpFromGroup : groupedAVPs) {
addAvp(avpFromGroup, avpSet);
}
} else if (avp != null) {
set.addAvp(avp.getCode(), avp.byteArrayValue(), avp.getVendorId(), avp.getMandatoryRule() != DiameterAvp.FLAG_RULE_MUSTNOT, avp.getProtectedRule() == DiameterAvp.FLAG_RULE_MUST);
}
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class BaseFactoriesTest method testMessageCreationVendorSpecificApplicationIdAvp.
@Test
public void testMessageCreationVendorSpecificApplicationIdAvp() {
// Relates to Issue #1555 (http://code.google.com/p/mobicents/issues/detail?id=1555)
List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
try {
long vendorId = 2312L;
long acctApplicationId = 23121L;
DiameterAvp avpVendorId = avpFactory.createAvp(DiameterAvpCodes.VENDOR_ID, vendorId);
DiameterAvp avpAcctApplicationId = avpFactory.createAvp(DiameterAvpCodes.ACCT_APPLICATION_ID, acctApplicationId);
avps.add(avpFactory.createAvp(DiameterAvpCodes.VENDOR_SPECIFIC_APPLICATION_ID, new DiameterAvp[] { avpVendorId, avpAcctApplicationId }));
DiameterAvp[] avpArray = new DiameterAvp[avps.size()];
avpArray = avps.toArray(avpArray);
AccountingRequest acr = messageFactory.createAccountingRequest(avpArray);
VendorSpecificApplicationIdAvp vsaidAvp = acr.getVendorSpecificApplicationId();
assertNotNull("Vendor-Specific-Application-Id should be present in message.", vsaidAvp);
// hack: vendor id is Avp vendor-id value, need to do this way.
long msgAppVendorId = vsaidAvp.getVendorIdsAvp()[0];
assertTrue("Vendor-Specific-Application-Id / Vendor-Id should be [" + vendorId + "] it is [" + msgAppVendorId + "]", vendorId == msgAppVendorId);
long msgAppId = vsaidAvp.getAcctApplicationId();
assertTrue("Vendor-Specific-Application-Id / Acct-Application-Id should be [" + acctApplicationId + "] it is [" + msgAppId + "]", acctApplicationId == msgAppId);
} catch (Exception e) {
e.printStackTrace();
fail(e.getLocalizedMessage());
}
}
Aggregations