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());
}
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());
}
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);
}
}
}
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);
}
}
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);
}
}
Aggregations