use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class CreditControlMessageFactoryImpl method createRawMessage.
protected Message createRawMessage(DiameterHeader header) {
int commandCode = 0;
long endToEndId = 0;
long hopByHopId = 0;
ApplicationId aid = ApplicationId.createByAuthAppId(_CCA_VENDOR, _CCA_AUTH_APP_ID);
if (header != null) {
// Answer
commandCode = header.getCommandCode();
endToEndId = header.getEndToEndId();
hopByHopId = header.getHopByHopId();
// aid = ApplicationId.createByAuthAppId(header.getApplicationId());
} else {
commandCode = CreditControlRequest.commandCode;
// endToEndId = (long) (Math.random()*1000000);
// hopByHopId = (long) (Math.random()*1000000)+1;
}
try {
if (header != null) {
return stack.getSessionFactory().getNewRawSession().createMessage(commandCode, aid, hopByHopId, endToEndId);
} else {
return stack.getSessionFactory().getNewRawSession().createMessage(commandCode, aid);
}
} catch (IllegalDiameterStateException e) {
logger.error("Failed to get session factory for message creation.", e);
} catch (InternalException e) {
logger.error("Failed to create new raw session for message creation.", e);
}
return null;
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class CxDxFactoriesTest method testMessageFactoryApplicationIdChangePPR.
@Test
public void testMessageFactoryApplicationIdChangePPR() throws Exception {
long vendor = 10415L;
ApplicationId originalAppId = ((CxDxMessageFactoryImpl) cxdxMessageFactory).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 CxDx is " + originalAppId.getVendorId());
// let's create a message and see how it comes...
PushProfileRequest originalPPR = cxdxMessageFactory.createPushProfileRequest();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalPPR);
// now we switch..
originalPPR = null;
isVendor = !isVendor;
((CxDxMessageFactoryImpl) cxdxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
PushProfileRequest changedPPR = cxdxMessageFactory.createPushProfileRequest();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedPPR);
// revert back to default
((CxDxMessageFactoryImpl) cxdxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class DiameterMessageFactoryImpl method createAbortSessionRequest.
public AbortSessionRequest createAbortSessionRequest(DiameterAvp[] avps) throws AvpNotAllowedException {
ApplicationId appId = getApplicationId(avps);
AbortSessionRequest msg = (AbortSessionRequest) this.createDiameterMessage(null, avps, Message.ABORT_SESSION_REQUEST, appId != null ? appId : BASE_AUTH_APP_ID);
// Add Session-Id AVP if not present
addSessionIdAvp(msg);
return msg;
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class DiameterMessageFactoryImpl method createMessage.
public ExtensionDiameterMessage createMessage(DiameterCommand command, DiameterAvp[] avps) throws AvpNotAllowedException {
ApplicationId aid = command.getCode() == AccountingRequest.commandCode ? ApplicationId.createByAccAppId(0, command.getApplicationId()) : ApplicationId.createByAuthAppId(0, command.getApplicationId());
ExtensionDiameterMessageImpl msg = (ExtensionDiameterMessageImpl) this.createDiameterMessage(null, avps, command.getCode(), aid);
msg.getGenericData().setRequest(command.isRequest());
((MessageImpl) msg.getGenericData()).setProxiable(command.isProxiable());
if (!command.isRequest()) {
// just in case. answers never have T flag set
((MessageImpl) msg.getGenericData()).setReTransmitted(false);
}
return msg;
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class DiameterShServerResourceAdaptor method raActive.
// More life cycle methods ----------------------------------------------
public void raActive() {
if (tracer.isFineEnabled()) {
tracer.fine("Diameter ShServer RA :: raActive.");
}
try {
if (tracer.isInfoEnabled()) {
tracer.info("Activating Diameter ShServer RA Entity");
}
this.diameterMultiplexerObjectName = new ObjectName("diameter.mobicents:service=DiameterStackMultiplexer");
Object object = null;
if (ManagementFactory.getPlatformMBeanServer().isRegistered(this.diameterMultiplexerObjectName)) {
// trying to get via MBeanServer
object = ManagementFactory.getPlatformMBeanServer().invoke(this.diameterMultiplexerObjectName, "getMultiplexerMBean", new Object[] {}, new String[] {});
if (tracer.isInfoEnabled()) {
tracer.info("Trying to get via Platform MBeanServer: " + this.diameterMultiplexerObjectName + ", object: " + object);
}
} else {
// trying to get via locateJBoss
object = MBeanServerLocator.locateJBoss().invoke(this.diameterMultiplexerObjectName, "getMultiplexerMBean", new Object[] {}, new String[] {});
if (tracer.isInfoEnabled()) {
tracer.info("Trying to get via JBoss MBeanServer: " + this.diameterMultiplexerObjectName + ", object: " + object);
}
}
if (object != null && object instanceof DiameterStackMultiplexerMBean) {
this.diameterMux = (DiameterStackMultiplexerMBean) object;
}
// this.activities = new ConcurrentHashMap<ActivityHandle, DiameterActivity>();
// Initialize stack
initStack();
// Initialize activities mgmt
initActivitiesMgmt();
// Initialize factories
this.baseAvpFactory = new DiameterAvpFactoryImpl();
this.shAvpFactory = new DiameterShAvpFactoryImpl(baseAvpFactory);
this.shServerMessageFactory = new ShServerMessageFactoryImpl(stack);
// Set the first configured Application-Id as default for message factory
ApplicationId firstAppId = authApplicationIds.get(0);
((ShServerMessageFactoryImpl) this.shServerMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
// Setup session factories
this.sessionFactory = this.stack.getSessionFactory();
((ISessionFactory) sessionFactory).registerAppFacory(ServerShSession.class, new ShServerSessionFactory(sessionFactory, this));
} catch (Exception e) {
tracer.severe("Error Activating Diameter ShServer RA Entity", e);
}
}
Aggregations