Search in sources :

Example 1 with GxReAuthAnswerImpl

use of org.mobicents.slee.resource.diameter.gx.events.GxReAuthAnswerImpl 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);
    }
}
Also used : AccountingAnswerImpl(org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl) AbortSessionAnswerImpl(org.mobicents.slee.resource.diameter.base.events.AbortSessionAnswerImpl) GxReAuthRequestImpl(org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl) AccountingRequestImpl(org.mobicents.slee.resource.diameter.base.events.AccountingRequestImpl) ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) SleeEndpoint(javax.slee.resource.SleeEndpoint) AbortSessionRequestImpl(org.mobicents.slee.resource.diameter.base.events.AbortSessionRequestImpl) SessionTerminationAnswerImpl(org.mobicents.slee.resource.diameter.base.events.SessionTerminationAnswerImpl) GxCreditControlAnswerImpl(org.mobicents.slee.resource.diameter.gx.events.GxCreditControlAnswerImpl) GxCreditControlRequestImpl(org.mobicents.slee.resource.diameter.gx.events.GxCreditControlRequestImpl) GxReAuthAnswerImpl(org.mobicents.slee.resource.diameter.gx.events.GxReAuthAnswerImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl) SessionTerminationRequestImpl(org.mobicents.slee.resource.diameter.base.events.SessionTerminationRequestImpl)

Example 2 with GxReAuthAnswerImpl

use of org.mobicents.slee.resource.diameter.gx.events.GxReAuthAnswerImpl 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;
}
Also used : Message(org.jdiameter.api.Message) GxCreditControlMessage(net.java.slee.resource.diameter.gx.events.GxCreditControlMessage) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) GxReAuthMessage(net.java.slee.resource.diameter.gx.events.GxReAuthMessage) GxReAuthRequestImpl(org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl) GxReAuthMessage(net.java.slee.resource.diameter.gx.events.GxReAuthMessage) GxReAuthAnswerImpl(org.mobicents.slee.resource.diameter.gx.events.GxReAuthAnswerImpl)

Example 3 with GxReAuthAnswerImpl

use of org.mobicents.slee.resource.diameter.gx.events.GxReAuthAnswerImpl 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;
}
Also used : GxReAuthRequestImpl(org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl) Message(org.jdiameter.api.Message) GxCreditControlMessage(net.java.slee.resource.diameter.gx.events.GxCreditControlMessage) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) GxReAuthMessage(net.java.slee.resource.diameter.gx.events.GxReAuthMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) GxReAuthAnswerImpl(org.mobicents.slee.resource.diameter.gx.events.GxReAuthAnswerImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException)

Aggregations

GxReAuthAnswerImpl (org.mobicents.slee.resource.diameter.gx.events.GxReAuthAnswerImpl)3 GxReAuthRequestImpl (org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl)3 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)2 GxCreditControlMessage (net.java.slee.resource.diameter.gx.events.GxCreditControlMessage)2 GxReAuthMessage (net.java.slee.resource.diameter.gx.events.GxReAuthMessage)2 Message (org.jdiameter.api.Message)2 SleeEndpoint (javax.slee.resource.SleeEndpoint)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)1 InternalException (org.jdiameter.api.InternalException)1 AbortSessionAnswerImpl (org.mobicents.slee.resource.diameter.base.events.AbortSessionAnswerImpl)1 AbortSessionRequestImpl (org.mobicents.slee.resource.diameter.base.events.AbortSessionRequestImpl)1 AccountingAnswerImpl (org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl)1 AccountingRequestImpl (org.mobicents.slee.resource.diameter.base.events.AccountingRequestImpl)1 ErrorAnswerImpl (org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)1 ExtensionDiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl)1 SessionTerminationAnswerImpl (org.mobicents.slee.resource.diameter.base.events.SessionTerminationAnswerImpl)1 SessionTerminationRequestImpl (org.mobicents.slee.resource.diameter.base.events.SessionTerminationRequestImpl)1 GxCreditControlAnswerImpl (org.mobicents.slee.resource.diameter.gx.events.GxCreditControlAnswerImpl)1