use of org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl in project jain-slee.diameter by RestComm.
the class GxSessionActivityImpl method sendSyncMessage.
@Override
public DiameterMessage sendSyncMessage(DiameterMessage message) {
DiameterMessage answer = null;
Message receivedMessage = doSendMessage(message);
if (receivedMessage != null) {
if (!receivedMessage.isRequest()) {
if (receivedMessage.isError()) {
answer = new ErrorAnswerImpl(receivedMessage);
} else {
switch(receivedMessage.getCommandCode()) {
case GxCreditControlRequest.commandCode:
answer = new GxCreditControlRequestImpl(receivedMessage);
break;
case GxReAuthRequest.commandCode:
answer = new GxReAuthRequestImpl(receivedMessage);
break;
default:
logger.error("Received an unknown type of Message for Gx Activity: " + receivedMessage);
break;
}
}
} else {
logger.error("Received a REQUEST message when expecting an ANSWER.");
}
} else {
logger.debug("No answer received. Returning null.");
}
return answer;
}
use of org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl in project jain-slee.diameter by RestComm.
the class DiameterGxResourceAdaptor 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 // CCR/CCA
GxCreditControlRequest.commandCode:
return isRequest ? new GxCreditControlRequestImpl(message) : new GxCreditControlAnswerImpl(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
GxReAuthAnswer.commandCode:
return isRequest ? new GxReAuthRequestImpl(message) : new GxReAuthAnswerImpl(message);
case // ACR/ACA
AccountingAnswer.commandCode:
return isRequest ? new AccountingRequestImpl(message) : new AccountingAnswerImpl(message);
default:
return new ExtensionDiameterMessageImpl(message);
}
}
use of org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl in project jain-slee.diameter by RestComm.
the class GxMessageFactoryImpl method createGxReAuthRequest.
private GxReAuthMessage createGxReAuthRequest(final DiameterHeader diameterHeader, final DiameterAvp[] avps) throws IllegalArgumentException {
boolean isRequest = false;
if (diameterHeader == null) {
isRequest = true;
}
GxReAuthMessage msg = null;
if (!isRequest) {
final Message raw = createGxMessage(diameterHeader, avps, GxReAuthAnswer.commandCode);
raw.setProxiable(true);
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
msg = new GxReAuthAnswerImpl(raw);
} else {
final Message raw = createGxMessage(null, avps, GxReAuthRequest.commandCode);
raw.setProxiable(true);
raw.setRequest(true);
msg = new GxReAuthRequestImpl(raw);
}
return msg;
}
use of org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl in project jain-slee.diameter by RestComm.
the class GxMessageFactoryImpl method createGxReAuthAnswer.
public GxReAuthAnswer createGxReAuthAnswer(final GxReAuthRequest request) {
// Create the answer from the request
final GxReAuthRequestImpl rar = (GxReAuthRequestImpl) request;
// final GxReAuthAnswerImpl msg = new GxReAuthAnswerImpl(createMessage(rar.getHeader(), new DiameterAvp[]{}));
final Message raw = this.createGxMessage(rar.getHeader(), new DiameterAvp[] {}, GxReAuthAnswer.commandCode);
raw.setProxiable(rar.getHeader().isProxiable());
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
final GxReAuthAnswerImpl msg = new GxReAuthAnswerImpl(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;
}
Aggregations