Search in sources :

Example 21 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class ShClientMessageFactoryImpl method createPushNotificationAnswer.

public PushNotificationAnswer createPushNotificationAnswer(PushNotificationRequest request) {
    DiameterAvp[] avps = new DiameterAvp[0];
    try {
        DiameterAvp sessionIdAvp = null;
        sessionIdAvp = baseAvpFactory.createAvp(0, DiameterAvpCodes.SESSION_ID, request.getSessionId());
        avps = new DiameterAvp[] { sessionIdAvp };
    } catch (NoSuchAvpException e) {
        logger.error("Unexpected failure trying to create Session-Id AVP.", e);
    }
    Message msg = createShMessage(request.getHeader(), avps, PushNotificationAnswer.commandCode);
    PushNotificationAnswerImpl pna = new PushNotificationAnswerImpl(msg);
    addOrigin(pna);
    return pna;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException) PushNotificationAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.PushNotificationAnswerImpl)

Example 22 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class ShClientMessageFactoryImpl method createProfileUpdateRequest.

public ProfileUpdateRequest createProfileUpdateRequest() {
    DiameterAvp[] avps = new DiameterAvp[0];
    if (session != null) {
        try {
            DiameterAvp sessionIdAvp = null;
            sessionIdAvp = baseAvpFactory.createAvp(0, DiameterAvpCodes.SESSION_ID, session.getSessionId());
            avps = new DiameterAvp[] { sessionIdAvp };
        } catch (NoSuchAvpException e) {
            logger.error("Unexpected failure trying to create Session-Id AVP.", e);
        }
    }
    Message msg = createShMessage(null, avps, ProfileUpdateRequest.commandCode);
    ProfileUpdateRequestImpl pur = new ProfileUpdateRequestImpl(msg);
    addOrigin(pur);
    return pur;
}
Also used : ProfileUpdateRequestImpl(org.mobicents.slee.resource.diameter.sh.events.ProfileUpdateRequestImpl) Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException)

Example 23 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class ShClientMessageFactoryImpl method addAvp.

protected void addAvp(DiameterAvp avp, AvpSet set) {
    if (avp instanceof GroupedAvp) {
        AvpSet avpSet = set.addGroupedAvp(avp.getCode(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
        DiameterAvp[] groupedAVPs = ((GroupedAvp) avp).getExtensionAvps();
        for (DiameterAvp avpFromGroup : groupedAVPs) {
            addAvp(avpFromGroup, avpSet);
        }
    } else if (avp != null)
        set.addAvp(avp.getCode(), avp.byteArrayValue(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
}
Also used : GroupedAvp(net.java.slee.resource.diameter.base.events.avp.GroupedAvp) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) AvpSet(org.jdiameter.api.AvpSet)

Example 24 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class ShClientMessageFactoryImpl method createMessage.

protected Message createMessage(DiameterHeader header, DiameterAvp[] avps, int commandCode) throws AvpNotAllowedException {
    try {
        Message msg = createRawMessage(header, commandCode);
        AvpSet set = msg.getAvps();
        for (DiameterAvp avp : avps) {
            addAvp(avp, set);
        }
        return msg;
    } catch (Exception e) {
        logger.error("Unexpected failure trying to create Sh Message.", e);
    }
    return null;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) AvpSet(org.jdiameter.api.AvpSet) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException)

Example 25 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class S13ServerSessionImpl method createMEIdentityCheckAnswer.

public MEIdentityCheckAnswer createMEIdentityCheckAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof MEIdentityCheckRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        MEIdentityCheckAnswer eca = (MEIdentityCheckAnswer) this.s13MessageFactory.createS13Message(lastRequest.getHeader(), new DiameterAvp[] {}, MEIdentityCheckAnswer.COMMAND_CODE, s13MessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(eca);
        return eca;
    } catch (InternalException e) {
        logger.error("Failed to create Authentication-Information-Answer.", e);
    }
    return null;
}
Also used : DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) MEIdentityCheckRequest(net.java.slee.resource.diameter.s13.events.MEIdentityCheckRequest) MEIdentityCheckAnswer(net.java.slee.resource.diameter.s13.events.MEIdentityCheckAnswer) InternalException(org.jdiameter.api.InternalException)

Aggregations

DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)65 Message (org.jdiameter.api.Message)22 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)21 InternalException (org.jdiameter.api.InternalException)21 AvpSet (org.jdiameter.api.AvpSet)18 ArrayList (java.util.ArrayList)15 GroupedAvp (net.java.slee.resource.diameter.base.events.avp.GroupedAvp)15 NoSuchAvpException (net.java.slee.resource.diameter.base.NoSuchAvpException)12 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)9 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)6 AccountingRequest (net.java.slee.resource.diameter.base.events.AccountingRequest)3 VendorSpecificApplicationIdAvp (net.java.slee.resource.diameter.base.events.avp.VendorSpecificApplicationIdAvp)3 GxCreditControlMessage (net.java.slee.resource.diameter.gx.events.GxCreditControlMessage)3 GxReAuthMessage (net.java.slee.resource.diameter.gx.events.GxReAuthMessage)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 DiameterIdentity (net.java.slee.resource.diameter.base.events.avp.DiameterIdentity)2 CreditControlRequest (net.java.slee.resource.diameter.cca.events.CreditControlRequest)2 RoCreditControlMessage (net.java.slee.resource.diameter.ro.events.RoCreditControlMessage)2 ApplicationId (org.jdiameter.api.ApplicationId)2