use of org.mobicents.slee.resource.diameter.rx.events.AAAnswerImpl in project jain-slee.diameter by RestComm.
the class RxMessageFactoryImpl method createAAAnswer.
public AAAnswer createAAAnswer(final AARequest request) {
// Create the answer from the request
final AAAnswerImpl msg = (AAAnswerImpl) createDiameterMessage(request.getHeader(), EMPTY_AVP_ARRAY, 0, rxAppId);
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);
}
}
}
return msg;
}
use of org.mobicents.slee.resource.diameter.rx.events.AAAnswerImpl in project jain-slee.diameter by RestComm.
the class RxMessageFactoryImpl method createDiameterMessage.
protected DiameterMessage createDiameterMessage(DiameterHeader diameterHeader, DiameterAvp[] avps, int _commandCode, ApplicationId appId) throws IllegalArgumentException {
boolean creatingRequest = diameterHeader == null;
Message msg = null;
if (!creatingRequest) {
Message raw = createMessage(diameterHeader, avps, 0, appId);
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
msg = raw;
} else {
Message raw = createMessage(diameterHeader, avps, _commandCode, appId);
raw.setRequest(true);
msg = raw;
}
int commandCode = creatingRequest ? _commandCode : diameterHeader.getCommandCode();
DiameterMessage diamMessage = null;
switch(commandCode) {
case AARequest.commandCode:
diamMessage = creatingRequest ? new AARequestImpl(msg) : new AAAnswerImpl(msg);
break;
case Message.ABORT_SESSION_REQUEST:
diamMessage = creatingRequest ? new AbortSessionRequestImpl(msg) : new AbortSessionAnswerImpl(msg);
break;
case Message.RE_AUTH_REQUEST:
diamMessage = creatingRequest ? new ReAuthRequestImpl(msg) : new ReAuthAnswerImpl(msg);
break;
case Message.SESSION_TERMINATION_REQUEST:
diamMessage = creatingRequest ? new SessionTerminationRequestImpl(msg) : new SessionTerminationAnswerImpl(msg);
break;
default:
throw new IllegalArgumentException();
}
// Finally, add Origin-Host and Origin-Realm, if not present.
addOriginHostAndRealm(diamMessage);
return diamMessage;
}
use of org.mobicents.slee.resource.diameter.rx.events.AAAnswerImpl in project jain-slee.diameter by RestComm.
the class DiameterRxResourceAdaptor method createEvent.
/**
* Create Event object from a JDiameter message (request or answer).
*
* @return a DiameterMessage object wrapping the request/answer
* @throws OperationNotSupportedException
*/
private DiameterMessage createEvent(final Message message) {
if (message == null) {
throw new NullPointerException("Message argument cannot be null while creating event.");
}
final int commandCode = message.getCommandCode();
if (message.isError()) {
return new ErrorAnswerImpl(message);
}
final boolean isRequest = message.isRequest();
switch(commandCode) {
case // AAR/AAA
AARequest.commandCode:
return isRequest ? new AARequestImpl(message) : new AAAnswerImpl(message);
case // ASR/ASA
AbortSessionAnswer.commandCode:
return isRequest ? new AbortSessionRequestImpl(message) : new AbortSessionAnswerImpl(message);
case // STR/STA
SessionTerminationAnswer.commandCode:
return isRequest ? new SessionTerminationRequestImpl(message) : new SessionTerminationAnswerImpl(message);
case // RAR/RAA
ReAuthAnswer.commandCode:
return isRequest ? new ReAuthRequestImpl(message) : new ReAuthAnswerImpl(message);
default:
return new ExtensionDiameterMessageImpl(message);
}
}
Aggregations