use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class BaseFactoriesTest method getApplicationIdAvpsHash.
// Util methods for several applications
public static int getApplicationIdAvpsHash(DiameterMessage msg) {
int result = NO_APP_ID_AVPS;
int vsaiResult = 1;
for (DiameterAvp avp : msg.getAvps()) {
if (avp.getCode() == Avp.AUTH_APPLICATION_ID) {
result += AUTH_APP_ID;
} else if (avp.getCode() == Avp.ACCT_APPLICATION_ID) {
result += ACCT_APP_ID;
}
if (avp.getCode() == Avp.VENDOR_SPECIFIC_APPLICATION_ID) {
result += VENDOR_SPECIFIC_APP_ID;
GroupedAvp vsai = (GroupedAvp) avp;
for (DiameterAvp subAvp : vsai.getExtensionAvps()) {
if (subAvp.getCode() == Avp.AUTH_APPLICATION_ID) {
vsaiResult *= AUTH_APP_ID;
} else if (subAvp.getCode() == Avp.ACCT_APPLICATION_ID) {
vsaiResult *= ACCT_APP_ID;
}
}
}
}
if (result == VENDOR_SPECIFIC_APP_ID) {
result *= vsaiResult;
}
return result;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class CxDxClientSessionImpl method createPushProfileAnswer.
/* (non-Javadoc)
* @see net.java.slee.resource.diameter.cxdx.CxDxClientSession#createPushProfileAnswer()
*/
public PushProfileAnswer createPushProfileAnswer() {
// Make sure we have the correct type of Request
if (!(lastRequest instanceof PushProfileRequest)) {
logger.warn("Invalid type of answer for this activity.");
return null;
}
try {
// Create the answer
PushProfileAnswer ppa = (PushProfileAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, PushProfileAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
// Fill session related AVPs, if present
fillSessionAVPs(ppa);
return ppa;
} catch (InternalException e) {
logger.error("Failed to create Push-Profile-Answer.", e);
}
return null;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class DiameterMessageFactoryImpl method getApplicationId.
private ApplicationId getApplicationId(DiameterAvp[] avps) {
ApplicationId applicationId = null;
long vendorId = 0L;
// Try to get Application-Id from Message AVPs
if (avps != null) {
for (DiameterAvp avp : avps) {
if (avp.getCode() == DiameterAvpCodes.VENDOR_ID) {
vendorId = avp.intValue();
}
if (avp.getCode() == DiameterAvpCodes.VENDOR_SPECIFIC_APPLICATION_ID) {
applicationId = getApplicationId(((GroupedAvp) avp).getExtensionAvps());
break;
}
if (avp.getCode() == DiameterAvpCodes.ACCT_APPLICATION_ID) {
applicationId = ApplicationId.createByAccAppId(vendorId, avp.intValue());
break;
} else if (avp.getCode() == DiameterAvpCodes.AUTH_APPLICATION_ID) {
applicationId = ApplicationId.createByAuthAppId(vendorId, avp.intValue());
break;
}
}
}
return applicationId;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class CreditControlMessageFactoryImpl 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 CxDxServerSessionImpl method createMultimediaAuthenticationAnswer.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.cxdx.CxDxServerSession#createMultimediaAuthenticationAnswer()
*/
public MultimediaAuthenticationAnswer createMultimediaAuthenticationAnswer() {
// Make sure we have the correct type of Request
if (!(lastRequest instanceof MultimediaAuthenticationRequest)) {
logger.warn("Invalid type of answer for this activity.");
return null;
}
try {
// Create the answer
MultimediaAuthenticationAnswer maa = (MultimediaAuthenticationAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, MultimediaAuthenticationAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
// Fill session related AVPs, if present
fillSessionAVPs(maa);
return maa;
} catch (InternalException e) {
logger.error("Failed to create Multimedia-Authentication-Answer.", e);
}
return null;
}
Aggregations