Search in sources :

Example 1 with ExtensionDiameterMessageImpl

use of org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl in project jain-slee.diameter by RestComm.

the class CxDxMessageFactoryImpl method createCxDxMessage.

/**
 * Creates a CxDx Message with specified command-code and avps filled. If a header is present an answer will be created, if not
 * it will generate a request.
 *
 * @param diameterHeader
 * @param avps
 * @param _commandCode
 * @param appId
 * @return
 * @throws InternalException
 */
DiameterMessage createCxDxMessage(DiameterHeader diameterHeader, DiameterAvp[] avps, int _commandCode, ApplicationId appId) throws InternalException {
    boolean creatingRequest = diameterHeader == null;
    Message msg = null;
    if (!creatingRequest) {
        Message raw = createMessage(diameterHeader, avps, 0, appId);
        raw.setProxiable(diameterHeader.isProxiable());
        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.setProxiable(true);
        raw.setRequest(true);
        msg = raw;
    }
    int commandCode = creatingRequest ? _commandCode : diameterHeader.getCommandCode();
    DiameterMessage diamMessage = null;
    switch(commandCode) {
        case LocationInfoRequest.COMMAND_CODE:
            diamMessage = creatingRequest ? new LocationInfoRequestImpl(msg) : new LocationInfoAnswerImpl(msg);
            break;
        case MultimediaAuthenticationRequest.COMMAND_CODE:
            diamMessage = creatingRequest ? new MultimediaAuthenticationRequestImpl(msg) : new MultimediaAuthenticationAnswerImpl(msg);
            break;
        case PushProfileRequest.COMMAND_CODE:
            diamMessage = creatingRequest ? new PushProfileRequestImpl(msg) : new PushProfileAnswerImpl(msg);
            break;
        case RegistrationTerminationRequest.COMMAND_CODE:
            diamMessage = creatingRequest ? new RegistrationTerminationRequestImpl(msg) : new RegistrationTerminationAnswerImpl(msg);
            break;
        case ServerAssignmentRequest.COMMAND_CODE:
            diamMessage = creatingRequest ? new ServerAssignmentRequestImpl(msg) : new ServerAssignmentAnswerImpl(msg);
            break;
        case UserAuthorizationRequest.COMMAND_CODE:
            diamMessage = creatingRequest ? new UserAuthorizationRequestImpl(msg) : new UserAuthorizationAnswerImpl(msg);
            break;
        default:
            diamMessage = new ExtensionDiameterMessageImpl(msg);
    }
    if (!diamMessage.hasSessionId() && session != null) {
        diamMessage.setSessionId(session.getSessionId());
    }
    return diamMessage;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ServerAssignmentRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.ServerAssignmentRequestImpl) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) PushProfileRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.PushProfileRequestImpl) RegistrationTerminationRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.RegistrationTerminationRequestImpl) ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) PushProfileAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.PushProfileAnswerImpl) LocationInfoAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.LocationInfoAnswerImpl) MultimediaAuthenticationRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.MultimediaAuthenticationRequestImpl) UserAuthorizationRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.UserAuthorizationRequestImpl) UserAuthorizationAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.UserAuthorizationAnswerImpl) LocationInfoRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.LocationInfoRequestImpl) MultimediaAuthenticationAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.MultimediaAuthenticationAnswerImpl) RegistrationTerminationAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.RegistrationTerminationAnswerImpl) ServerAssignmentAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.ServerAssignmentAnswerImpl)

Example 2 with ExtensionDiameterMessageImpl

use of org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl in project jain-slee.diameter by RestComm.

the class DiameterMessageFactoryImpl 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.setProxiable(true);
        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);
        boolean isPeerManagementMessage = _commandCode == CapabilitiesExchangeRequest.commandCode || _commandCode == DeviceWatchdogRequest.commandCode || _commandCode == DisconnectPeerRequest.commandCode;
        raw.setProxiable(!isPeerManagementMessage);
        raw.setRequest(true);
        msg = raw;
    }
    int commandCode = creatingRequest ? _commandCode : diameterHeader.getCommandCode();
    DiameterMessage diamMessage = null;
    switch(commandCode) {
        case Message.ABORT_SESSION_REQUEST:
            diamMessage = creatingRequest ? new AbortSessionRequestImpl(msg) : new AbortSessionAnswerImpl(msg);
            break;
        case Message.ACCOUNTING_REQUEST:
            diamMessage = creatingRequest ? new AccountingRequestImpl(msg) : new AccountingAnswerImpl(msg);
            break;
        case Message.CAPABILITIES_EXCHANGE_REQUEST:
            diamMessage = creatingRequest ? new CapabilitiesExchangeRequestImpl(msg) : new CapabilitiesExchangeAnswerImpl(msg);
            break;
        case Message.DEVICE_WATCHDOG_REQUEST:
            diamMessage = creatingRequest ? new DeviceWatchdogRequestImpl(msg) : new DeviceWatchdogAnswerImpl(msg);
            break;
        case Message.DISCONNECT_PEER_REQUEST:
            diamMessage = creatingRequest ? new DisconnectPeerRequestImpl(msg) : new DisconnectPeerAnswerImpl(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:
            diamMessage = new ExtensionDiameterMessageImpl(msg);
    }
    // Finally, add Origin-Host and Origin-Realm, if not present.
    addOriginHostAndRealm(diamMessage);
    return diamMessage;
}
Also used : DisconnectPeerRequestImpl(org.mobicents.slee.resource.diameter.base.events.DisconnectPeerRequestImpl) AccountingAnswerImpl(org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl) Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ExtensionDiameterMessage(net.java.slee.resource.diameter.base.events.ExtensionDiameterMessage) AbortSessionAnswerImpl(org.mobicents.slee.resource.diameter.base.events.AbortSessionAnswerImpl) AccountingRequestImpl(org.mobicents.slee.resource.diameter.base.events.AccountingRequestImpl) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ExtensionDiameterMessage(net.java.slee.resource.diameter.base.events.ExtensionDiameterMessage) ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) DisconnectPeerAnswerImpl(org.mobicents.slee.resource.diameter.base.events.DisconnectPeerAnswerImpl) ReAuthRequestImpl(org.mobicents.slee.resource.diameter.base.events.ReAuthRequestImpl) AbortSessionRequestImpl(org.mobicents.slee.resource.diameter.base.events.AbortSessionRequestImpl) DeviceWatchdogRequestImpl(org.mobicents.slee.resource.diameter.base.events.DeviceWatchdogRequestImpl) SessionTerminationAnswerImpl(org.mobicents.slee.resource.diameter.base.events.SessionTerminationAnswerImpl) CapabilitiesExchangeRequestImpl(org.mobicents.slee.resource.diameter.base.events.CapabilitiesExchangeRequestImpl) CapabilitiesExchangeAnswerImpl(org.mobicents.slee.resource.diameter.base.events.CapabilitiesExchangeAnswerImpl) ReAuthAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ReAuthAnswerImpl) SessionTerminationRequestImpl(org.mobicents.slee.resource.diameter.base.events.SessionTerminationRequestImpl) DeviceWatchdogAnswerImpl(org.mobicents.slee.resource.diameter.base.events.DeviceWatchdogAnswerImpl)

Example 3 with ExtensionDiameterMessageImpl

use of org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl in project jain-slee.diameter by RestComm.

the class DiameterCxDxResourceAdaptor 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(Message message) {
    if (message == null) {
        throw new NullPointerException("Message argument cannot be null while creating event.");
    }
    int commandCode = message.getCommandCode();
    if (message.isError()) {
        return new ErrorAnswerImpl(message);
    }
    boolean isRequest = message.isRequest();
    switch(commandCode) {
        case // UAR/UAA
        UserAuthorizationRequest.COMMAND_CODE:
            return isRequest ? new UserAuthorizationRequestImpl(message) : new UserAuthorizationAnswerImpl(message);
        case // SAR/SAA
        ServerAssignmentRequest.COMMAND_CODE:
            return isRequest ? new ServerAssignmentRequestImpl(message) : new ServerAssignmentAnswerImpl(message);
        case // LIR/LIA
        LocationInfoRequest.COMMAND_CODE:
            return isRequest ? new LocationInfoRequestImpl(message) : new LocationInfoAnswerImpl(message);
        case // MAR/MAA
        MultimediaAuthenticationRequest.COMMAND_CODE:
            return isRequest ? new MultimediaAuthenticationRequestImpl(message) : new MultimediaAuthenticationAnswerImpl(message);
        case // RTR/RTA
        RegistrationTerminationRequest.COMMAND_CODE:
            return isRequest ? new RegistrationTerminationRequestImpl(message) : new RegistrationTerminationAnswerImpl(message);
        case // MAR/MAA
        PushProfileRequest.COMMAND_CODE:
            return isRequest ? new PushProfileRequestImpl(message) : new PushProfileAnswerImpl(message);
        default:
            return new ExtensionDiameterMessageImpl(message);
    }
}
Also used : ServerAssignmentRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.ServerAssignmentRequestImpl) RegistrationTerminationRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.RegistrationTerminationRequestImpl) PushProfileRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.PushProfileRequestImpl) ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) SleeEndpoint(javax.slee.resource.SleeEndpoint) PushProfileAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.PushProfileAnswerImpl) LocationInfoAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.LocationInfoAnswerImpl) UserAuthorizationRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.UserAuthorizationRequestImpl) UserAuthorizationAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.UserAuthorizationAnswerImpl) MultimediaAuthenticationRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.MultimediaAuthenticationRequestImpl) LocationInfoRequestImpl(org.mobicents.slee.resource.diameter.cxdx.events.LocationInfoRequestImpl) MultimediaAuthenticationAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.MultimediaAuthenticationAnswerImpl) RegistrationTerminationAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.RegistrationTerminationAnswerImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl) ServerAssignmentAnswerImpl(org.mobicents.slee.resource.diameter.cxdx.events.ServerAssignmentAnswerImpl)

Example 4 with ExtensionDiameterMessageImpl

use of org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl in project jain-slee.diameter by RestComm.

the class DiameterGqResourceAdaptor 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(Message message) {
    if (message == null) {
        throw new NullPointerException("Message argument cannot be null while creating event.");
    }
    int commandCode = message.getCommandCode();
    if (message.isError()) {
        return new ErrorAnswerImpl(message);
    }
    boolean isRequest = message.isRequest();
    switch(commandCode) {
        case // AAR/AAA
        GqAARequest.COMMAND_CODE:
            return isRequest ? new GqAARequestImpl(message) : new GqAAAnswerImpl(message);
        case // ASR/ASA
        GqAbortSessionRequest.COMMAND_CODE:
            return isRequest ? new GqAbortSessionRequestImpl(message) : new GqAbortSessionAnswerImpl(message);
        case // STR/STA
        GqSessionTerminationRequest.COMMAND_CODE:
            return isRequest ? new GqSessionTerminationRequestImpl(message) : new GqSessionTerminationAnswerImpl(message);
        case // RAR/RAA
        GqReAuthRequest.COMMAND_CODE:
            return isRequest ? new GqReAuthRequestImpl(message) : new GqReAuthAnswerImpl(message);
        default:
            return new ExtensionDiameterMessageImpl(message);
    }
}
Also used : GqReAuthRequestImpl(org.mobicents.slee.resource.diameter.gq.events.GqReAuthRequestImpl) GqSessionTerminationAnswerImpl(org.mobicents.slee.resource.diameter.gq.events.GqSessionTerminationAnswerImpl) GqAAAnswerImpl(org.mobicents.slee.resource.diameter.gq.events.GqAAAnswerImpl) ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) SleeEndpoint(javax.slee.resource.SleeEndpoint) GqSessionTerminationRequestImpl(org.mobicents.slee.resource.diameter.gq.events.GqSessionTerminationRequestImpl) GqAbortSessionRequestImpl(org.mobicents.slee.resource.diameter.gq.events.GqAbortSessionRequestImpl) GqReAuthAnswerImpl(org.mobicents.slee.resource.diameter.gq.events.GqReAuthAnswerImpl) GqAARequestImpl(org.mobicents.slee.resource.diameter.gq.events.GqAARequestImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl) GqAbortSessionAnswerImpl(org.mobicents.slee.resource.diameter.gq.events.GqAbortSessionAnswerImpl)

Example 5 with ExtensionDiameterMessageImpl

use of org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl in project jain-slee.diameter by RestComm.

the class DiameterS13ResourceAdaptor 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(Message message) {
    if (message == null) {
        throw new NullPointerException("Message argument cannot be null while creating event.");
    }
    int commandCode = message.getCommandCode();
    if (message.isError()) {
        return new ErrorAnswerImpl(message);
    }
    boolean isRequest = message.isRequest();
    switch(commandCode) {
        case MEIdentityCheckRequest.COMMAND_CODE:
            return isRequest ? new MEIdentityCheckRequestImpl(message) : new MEIdentityCheckAnswerImpl(message);
        default:
            return new ExtensionDiameterMessageImpl(message);
    }
}
Also used : MEIdentityCheckRequestImpl(org.mobicents.slee.resource.diameter.s13.events.MEIdentityCheckRequestImpl) MEIdentityCheckAnswerImpl(org.mobicents.slee.resource.diameter.s13.events.MEIdentityCheckAnswerImpl) ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl) SleeEndpoint(javax.slee.resource.SleeEndpoint)

Aggregations

ExtensionDiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl)15 SleeEndpoint (javax.slee.resource.SleeEndpoint)10 ErrorAnswerImpl (org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)10 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)4 Message (org.jdiameter.api.Message)4 AbortSessionAnswerImpl (org.mobicents.slee.resource.diameter.base.events.AbortSessionAnswerImpl)3 AbortSessionRequestImpl (org.mobicents.slee.resource.diameter.base.events.AbortSessionRequestImpl)3 AccountingAnswerImpl (org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl)3 AccountingRequestImpl (org.mobicents.slee.resource.diameter.base.events.AccountingRequestImpl)3 SessionTerminationAnswerImpl (org.mobicents.slee.resource.diameter.base.events.SessionTerminationAnswerImpl)2 SessionTerminationRequestImpl (org.mobicents.slee.resource.diameter.base.events.SessionTerminationRequestImpl)2 LocationInfoAnswerImpl (org.mobicents.slee.resource.diameter.cxdx.events.LocationInfoAnswerImpl)2 LocationInfoRequestImpl (org.mobicents.slee.resource.diameter.cxdx.events.LocationInfoRequestImpl)2 MultimediaAuthenticationAnswerImpl (org.mobicents.slee.resource.diameter.cxdx.events.MultimediaAuthenticationAnswerImpl)2 MultimediaAuthenticationRequestImpl (org.mobicents.slee.resource.diameter.cxdx.events.MultimediaAuthenticationRequestImpl)2 PushProfileAnswerImpl (org.mobicents.slee.resource.diameter.cxdx.events.PushProfileAnswerImpl)2 PushProfileRequestImpl (org.mobicents.slee.resource.diameter.cxdx.events.PushProfileRequestImpl)2 RegistrationTerminationAnswerImpl (org.mobicents.slee.resource.diameter.cxdx.events.RegistrationTerminationAnswerImpl)2 RegistrationTerminationRequestImpl (org.mobicents.slee.resource.diameter.cxdx.events.RegistrationTerminationRequestImpl)2 ServerAssignmentAnswerImpl (org.mobicents.slee.resource.diameter.cxdx.events.ServerAssignmentAnswerImpl)2