Search in sources :

Example 1 with DiameterAvp

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

the class BaseFactoriesTest method getApplicationIdAvpsHash.

// Util methods for several applications
public static int getApplicationIdAvpsHash(DiameterMessage msg) {
    int result = NO_APP_ID_AVPS;
    int vsaiResult = 1;
    for (DiameterAvp avp : msg.getAvps()) {
        if (avp.getCode() == Avp.AUTH_APPLICATION_ID) {
            result += AUTH_APP_ID;
        } else if (avp.getCode() == Avp.ACCT_APPLICATION_ID) {
            result += ACCT_APP_ID;
        }
        if (avp.getCode() == Avp.VENDOR_SPECIFIC_APPLICATION_ID) {
            result += VENDOR_SPECIFIC_APP_ID;
            GroupedAvp vsai = (GroupedAvp) avp;
            for (DiameterAvp subAvp : vsai.getExtensionAvps()) {
                if (subAvp.getCode() == Avp.AUTH_APPLICATION_ID) {
                    vsaiResult *= AUTH_APP_ID;
                } else if (subAvp.getCode() == Avp.ACCT_APPLICATION_ID) {
                    vsaiResult *= ACCT_APP_ID;
                }
            }
        }
    }
    if (result == VENDOR_SPECIFIC_APP_ID) {
        result *= vsaiResult;
    }
    return result;
}
Also used : GroupedAvp(net.java.slee.resource.diameter.base.events.avp.GroupedAvp) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp)

Example 2 with DiameterAvp

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

the class CxDxClientSessionImpl method createPushProfileAnswer.

/* (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxClientSession#createPushProfileAnswer()
   */
public PushProfileAnswer createPushProfileAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof PushProfileRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        PushProfileAnswer ppa = (PushProfileAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, PushProfileAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(ppa);
        return ppa;
    } catch (InternalException e) {
        logger.error("Failed to create Push-Profile-Answer.", e);
    }
    return null;
}
Also used : PushProfileAnswer(net.java.slee.resource.diameter.cxdx.events.PushProfileAnswer) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) PushProfileRequest(net.java.slee.resource.diameter.cxdx.events.PushProfileRequest) InternalException(org.jdiameter.api.InternalException)

Example 3 with DiameterAvp

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

the class DiameterMessageFactoryImpl method getApplicationId.

private ApplicationId getApplicationId(DiameterAvp[] avps) {
    ApplicationId applicationId = null;
    long vendorId = 0L;
    // Try to get Application-Id from Message AVPs
    if (avps != null) {
        for (DiameterAvp avp : avps) {
            if (avp.getCode() == DiameterAvpCodes.VENDOR_ID) {
                vendorId = avp.intValue();
            }
            if (avp.getCode() == DiameterAvpCodes.VENDOR_SPECIFIC_APPLICATION_ID) {
                applicationId = getApplicationId(((GroupedAvp) avp).getExtensionAvps());
                break;
            }
            if (avp.getCode() == DiameterAvpCodes.ACCT_APPLICATION_ID) {
                applicationId = ApplicationId.createByAccAppId(vendorId, avp.intValue());
                break;
            } else if (avp.getCode() == DiameterAvpCodes.AUTH_APPLICATION_ID) {
                applicationId = ApplicationId.createByAuthAppId(vendorId, avp.intValue());
                break;
            }
        }
    }
    return applicationId;
}
Also used : GroupedAvp(net.java.slee.resource.diameter.base.events.avp.GroupedAvp) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ApplicationId(org.jdiameter.api.ApplicationId)

Example 4 with DiameterAvp

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

the class CreditControlMessageFactoryImpl method createMessage.

public Message createMessage(DiameterHeader header, DiameterAvp[] avps) throws AvpNotAllowedException {
    Message msg = createRawMessage(header);
    AvpSet set = msg.getAvps();
    for (DiameterAvp avp : avps) {
        addAvp(avp, set);
    }
    return msg;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) CreditControlMessage(net.java.slee.resource.diameter.cca.events.CreditControlMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) AvpSet(org.jdiameter.api.AvpSet)

Example 5 with DiameterAvp

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

the class CxDxServerSessionImpl method createMultimediaAuthenticationAnswer.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxServerSession#createMultimediaAuthenticationAnswer()
   */
public MultimediaAuthenticationAnswer createMultimediaAuthenticationAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof MultimediaAuthenticationRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        MultimediaAuthenticationAnswer maa = (MultimediaAuthenticationAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, MultimediaAuthenticationAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(maa);
        return maa;
    } catch (InternalException e) {
        logger.error("Failed to create Multimedia-Authentication-Answer.", e);
    }
    return null;
}
Also used : MultimediaAuthenticationRequest(net.java.slee.resource.diameter.cxdx.events.MultimediaAuthenticationRequest) MultimediaAuthenticationAnswer(net.java.slee.resource.diameter.cxdx.events.MultimediaAuthenticationAnswer) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) 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