Search in sources :

Example 11 with RoCreditControlRequest

use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method isProxiableCCR.

@Test
public void isProxiableCCR() throws Exception {
    RoCreditControlRequest acr = roMessageFactory.createRoCreditControlRequest();
    assertTrue("The 'P' bit is not set by default in Ro Credit-Control-Request, it should.", acr.getHeader().isProxiable());
}
Also used : RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 12 with RoCreditControlRequest

use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method testClientSessionApplicationIdChangeCCR.

@Test
public void testClientSessionApplicationIdChangeCCR() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RoMessageFactoryImpl) roMessageFactory).getApplicationId();
    boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isVendor = originalAppId.getVendorId() != 0L;
    assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
    System.out.println("Default VENDOR-ID for Ro is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    RoCreditControlRequest originalCCR = roClientSession.createRoCreditControlRequest(CcRequestType.EVENT_REQUEST);
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalCCR);
    // now we switch..
    originalCCR = null;
    isVendor = !isVendor;
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    RoCreditControlRequest changedCCR = roClientSession.createRoCreditControlRequest(CcRequestType.EVENT_REQUEST);
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedCCR);
    // revert back to default
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : ApplicationId(org.jdiameter.api.ApplicationId) RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) RoMessageFactoryImpl(org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 13 with RoCreditControlRequest

use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project charging-server by RestComm.

the class DiameterChargingServerSbb method resumeOnCreditControlRequest.

// private String storedEndUserId;
// private long storedRequestedUnits;
// private long[] storedServiceIds;
// private ArrayList<UnitReservation> storedReservations = new ArrayList<UnitReservation>();
@Override
public void resumeOnCreditControlRequest(CreditControlInfo ccInfo) {
    UserSessionInfo sessionInfo = getSessionInfo();
    RoCreditControlRequest storedCCR = sessionInfo.getCcr();
    if (tracer.isInfoEnabled()) {
        tracer.info("[<<] " + sidString + " Resuming Handling of Credit-Control-Request [" + storedCCR.getCcRequestType().toString() + "]");
    }
    if (tracer.isFineEnabled()) {
        tracer.fine("[<<] \" + sidString + \" " + ccInfo);
    }
    sessionInfo.getReservations().add(ccInfo);
    setSessionInfo(sessionInfo);
    long resultCode = DiameterResultCode.DIAMETER_SUCCESS;
    if (ccInfo.isSuccessful()) {
        if (tracer.isInfoEnabled()) {
            tracer.info("[>>] " + sidString + " '" + sessionInfo.getEndUserId() + "' GRANTED for '" + Arrays.toString(sessionInfo.getServiceIds()) + "'.");
        }
    } else {
        if (tracer.isInfoEnabled()) {
            tracer.info("[>>] " + sidString + " '" + sessionInfo.getEndUserId() + "' DENIED for '" + Arrays.toString(sessionInfo.getServiceIds()) + "'.");
        }
        // If we can't determine error, say UNABLE_TO_COMPLY
        resultCode = ccInfo.getErrorCodeType() != null ? getResultCode(ccInfo.getErrorCodeType()) : DiameterResultCode.DIAMETER_UNABLE_TO_COMPLY;
    }
    try {
        ActivityContextInterface[] acis = this.sbbContextExt.getActivities();
        ActivityContextInterface aci = null;
        RoServerSessionActivity activity = null;
        for (ActivityContextInterface curAci : acis) {
            if (curAci.getActivity() instanceof RoServerSessionActivity) {
                aci = curAci;
                activity = (RoServerSessionActivity) curAci.getActivity();
                break;
            }
        }
        RoCreditControlAnswer cca = sessionInfo.getReservations().size() > 0 ? createCCA(activity, storedCCR, sessionInfo.getReservations(), resultCode) : createCCA(activity, storedCCR, null, DiameterResultCode.DIAMETER_MISSING_AVP);
        sendCCA(cca, aci, storedCCR.getCcRequestType() == CcRequestType.TERMINATION_REQUEST || storedCCR.getCcRequestType() == CcRequestType.EVENT_REQUEST);
        // Output the user session details.
        if (tracer.isInfoEnabled()) {
            tracer.info("[--] " + sidString + " CCA successfully sent.");
        }
        if (tracer.isFineEnabled()) {
            tracer.fine("[--] " + sidString + "Dumping session info...\n" + sessionInfo);
        }
    } catch (Exception e) {
        tracer.severe("[xx] " + sidString + " Unable to send Credit-Control-Answer.", e);
    }
    if (generateCDR && cdrGenerator != null && storedCCR.getCcRequestType() == CcRequestType.TERMINATION_REQUEST) {
        if (tracer.isInfoEnabled()) {
            tracer.info("[><] " + sidString + " Generating CDR.");
        }
        try {
            cdrGenerator.writeCDR(sessionInfo);
        } catch (Exception e) {
            tracer.severe("[xx] " + sidString + " Unable to generate CDR", e);
        }
    }
}
Also used : RoServerSessionActivity(net.java.slee.resource.diameter.ro.RoServerSessionActivity) ActivityContextInterface(javax.slee.ActivityContextInterface) RoCreditControlAnswer(net.java.slee.resource.diameter.ro.events.RoCreditControlAnswer) RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) CreateException(javax.slee.CreateException) IOException(java.io.IOException) SLEEException(javax.slee.SLEEException) UserSessionInfo(org.mobicents.charging.server.data.UserSessionInfo)

Example 14 with RoCreditControlRequest

use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.

the class RoClientSessionActivityImpl method sendUpdateRoCreditControlRequest.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.ro.RoClientSessionActivity#sendUpdateRoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest)
   */
public void sendUpdateRoCreditControlRequest(RoCreditControlRequest ccr) throws IOException {
    validateState(ccr);
    DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
    try {
        session.sendCreditControlRequest(new RoCreditControlRequestImpl((Request) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : RoCreditControlRequestImpl(org.jdiameter.common.impl.app.ro.RoCreditControlRequestImpl) RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) Request(org.jdiameter.api.Request) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException) DiameterException(net.java.slee.resource.diameter.base.DiameterException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 15 with RoCreditControlRequest

use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.

the class RoClientSessionActivityImpl method sendInitialRoCreditControlRequest.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.ro.RoClientSessionActivity#sendInitialRoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest)
   */
public void sendInitialRoCreditControlRequest(RoCreditControlRequest ccr) throws IOException {
    // FIXME: should this affect FSM ?
    validateState(ccr);
    DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
    try {
        session.sendCreditControlRequest(new RoCreditControlRequestImpl((Request) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : RoCreditControlRequestImpl(org.jdiameter.common.impl.app.ro.RoCreditControlRequestImpl) RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) Request(org.jdiameter.api.Request) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException) DiameterException(net.java.slee.resource.diameter.base.DiameterException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Aggregations

RoCreditControlRequest (net.java.slee.resource.diameter.ro.events.RoCreditControlRequest)18 Test (org.junit.Test)9 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)9 IOException (java.io.IOException)5 DiameterException (net.java.slee.resource.diameter.base.DiameterException)4 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)4 RoCreditControlAnswer (net.java.slee.resource.diameter.ro.events.RoCreditControlAnswer)4 Request (org.jdiameter.api.Request)4 RoCreditControlRequestImpl (org.jdiameter.common.impl.app.ro.RoCreditControlRequestImpl)4 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)4 ApplicationId (org.jdiameter.api.ApplicationId)3 RoMessageFactoryImpl (org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl)3 RoServerSessionActivityImpl (org.mobicents.slee.resource.diameter.ro.RoServerSessionActivityImpl)3 ActivityContextInterface (javax.slee.ActivityContextInterface)2 CreateException (javax.slee.CreateException)2 ArrayList (java.util.ArrayList)1 SLEEException (javax.slee.SLEEException)1 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 DiameterIdentity (net.java.slee.resource.diameter.base.events.avp.DiameterIdentity)1 MultipleServicesCreditControlAvp (net.java.slee.resource.diameter.cca.events.avp.MultipleServicesCreditControlAvp)1