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;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class GxMessageFactoryImpl method createGxCreditControlAnswer.
public GxCreditControlAnswer createGxCreditControlAnswer(final GxCreditControlRequest request) {
// Create the answer from the request
final GxCreditControlRequestImpl ccr = (GxCreditControlRequestImpl) request;
// final GxCreditControlAnswerImpl msg = new GxCreditControlAnswerImpl(createMessage(ccr.getHeader(), new DiameterAvp[]{}));
final Message raw = createGxMessage(ccr.getHeader(), new DiameterAvp[] {}, GxCreditControlRequest.commandCode);
raw.setProxiable(ccr.getHeader().isProxiable());
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
final GxCreditControlAnswerImpl msg = new GxCreditControlAnswerImpl(raw);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_HOST);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_REALM);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_HOST);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_REALM);
msg.setSessionId(request.getSessionId());
// Now copy the needed AVPs
final DiameterAvp[] messageAvps = request.getAvps();
if (messageAvps != null) {
for (DiameterAvp a : messageAvps) {
try {
if (ids.contains(a.getCode())) {
msg.addAvp(a);
}
} catch (Exception e) {
logger.error("Failed to add AVP to answer. Code[" + a.getCode() + "]", e);
}
}
}
addOrigin(msg);
return msg;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class AvpFlagsTest method testCorrectFlagsSupportedFeatures.
@Test
public void testCorrectFlagsSupportedFeatures() {
List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
DiameterAvp avpFeatureListID = AvpUtilities.createAvp(Avp.FEATURE_LIST_ID, TGPP_VENDOR_ID, 1);
avps.add(AvpUtilities.createAvp(Avp.SUPPORTED_FEATURES, TGPP_VENDOR_ID, new DiameterAvp[] { avpFeatureListID }));
GxCreditControlRequest ccr = gxMessageFactory.createGxCreditControlRequest();
GxCreditControlAnswer cca = gxMessageFactory.createGxCreditControlAnswer(ccr);
cca.setExtensionAvps(avps.toArray(avps.toArray(new DiameterAvp[avps.size()])));
Message msg = ((DiameterMessageImpl) cca).getGenericData();
AvpUtilities.addAvp(msg, Avp.SUPPORTED_FEATURES, TGPP_VENDOR_ID, msg.getAvps(), new DiameterAvp[] { avpFeatureListID });
// Attribute Name AVP Code Section Value Type Must May Should not Must not May Encr.
// Supported-Features 628 6.3.29 Grouped V M - - - No
ArrayList<String> failures = checkAvpFlags(msg.getAvps());
if (failures.size() > 0) {
System.err.println("The following AVPs flags have failed to check against dictionary:");
for (String failure : failures) {
System.err.println(failure);
}
Assert.fail(failures.toString());
}
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class RoMessageFactoryImpl method createRoCreditControlAnswer.
public RoCreditControlAnswer createRoCreditControlAnswer(RoCreditControlRequest request) {
// Create the answer from the request
RoCreditControlRequestImpl ccr = (RoCreditControlRequestImpl) request;
// DiameterAvp sessionIdAvp = null;
// try {
// sessionIdAvp = creditControlAvpFactory.getBaseFactory().createAvp(0,
// DiameterAvpCodes.SESSION_ID, this.session.getSessionId());
// }
// catch (NoSuchAvpException e1) {
// logger.error("Session-Id AVP not found in message", e1);
// }
RoCreditControlAnswerImpl msg = new RoCreditControlAnswerImpl(createMessage(ccr.getHeader(), new DiameterAvp[] {}));
// FIXME: ammendonca: go through proper methods...
Message raw = msg.getGenericData();
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
raw.getAvps().removeAvp(DiameterAvpCodes.DESTINATION_HOST);
raw.getAvps().removeAvp(DiameterAvpCodes.DESTINATION_REALM);
raw.getAvps().removeAvp(DiameterAvpCodes.ORIGIN_HOST);
raw.getAvps().removeAvp(DiameterAvpCodes.ORIGIN_REALM);
msg.setSessionId(request.getSessionId());
// Now copy the needed AVPs
DiameterAvp[] messageAvps = request.getAvps();
if (messageAvps != null) {
for (DiameterAvp a : messageAvps) {
try {
if (ids.contains(a.getCode())) {
msg.addAvp(a);
}
} catch (Exception e) {
logger.error("Failed to add AVP to answer. Code[" + a.getCode() + "]", e);
}
}
}
addOrigin(msg);
return msg;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class RxMessageFactoryImpl 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;
}
Aggregations