Search in sources :

Example 36 with ApplicationId

use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method testServerSessionApplicationIdChangeCCA.

@Test
public void testServerSessionApplicationIdChangeCCA() 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 ccr = roMessageFactory.createRoCreditControlRequest();
    ((RoServerSessionActivityImpl) roServerSession).fetchCurrentState(ccr);
    RoCreditControlAnswer originalCCA = roServerSession.createRoCreditControlAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalCCA);
    // now we switch..
    originalCCA = null;
    isVendor = !isVendor;
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    RoCreditControlAnswer changedCCA = roServerSession.createRoCreditControlAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedCCA);
    // revert back to default
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : RoServerSessionActivityImpl(org.mobicents.slee.resource.diameter.ro.RoServerSessionActivityImpl) RoCreditControlAnswer(net.java.slee.resource.diameter.ro.events.RoCreditControlAnswer) 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 37 with ApplicationId

use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method testMessageFactoryApplicationIdChangeCCR.

@Test
public void testMessageFactoryApplicationIdChangeCCR() 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 = roMessageFactory.createRoCreditControlRequest();
    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 = roMessageFactory.createRoCreditControlRequest();
    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 38 with ApplicationId

use of org.jdiameter.api.ApplicationId 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 39 with ApplicationId

use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.

the class DiameterS13ResourceAdaptor method sessionCreated.

// S13 Session Creation Listener --------------------------------------
public void sessionCreated(ServerS13Session session) {
    S13MessageFactoryImpl sessionMsgFactory = new S13MessageFactoryImpl(session.getSessions().get(0), stack, new DiameterIdentity[] {});
    // Set the first configured Application-Id as default for message factory
    ApplicationId firstAppId = authApplicationIds.get(0);
    sessionMsgFactory.setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
    S13ServerSessionImpl serverActivity = new S13ServerSessionImpl(sessionMsgFactory, s13AvpFactory, session, this, null, null, stack);
    // session.addStateChangeNotification(serverActivity);
    // addActivity(serverActivity);
    serverActivity.setSessionListener(this);
}
Also used : ApplicationId(org.jdiameter.api.ApplicationId)

Example 40 with ApplicationId

use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.

the class DiameterS6aResourceAdaptor method raActive.

public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter S6a RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter S6a 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;
        }
        // Initialize the protocol stack
        initStack();
        // Initialize activities mgmt
        initActivitiesMgmt();
        // Initialize factories
        this.baseAvpFactory = new DiameterAvpFactoryImpl();
        this.s6aAvpFactory = new S6aAVPFactoryImpl(baseAvpFactory);
        this.s6aMessageFactory = new S6aMessageFactoryImpl(stack);
        // Set the first configured Application-Id as default for message factory
        ApplicationId firstAppId = authApplicationIds.get(0);
        ((S6aMessageFactoryImpl) this.s6aMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
        // Setup session factories
        this.sessionFactory = this.stack.getSessionFactory();
        this.s6aSessionFactory = new S6aSessionFactory(this, messageTimeout, sessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerS6aSession.class, s6aSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientS6aSession.class, s6aSessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter S6a RA Entity", e);
    }
}
Also used : DiameterStackMultiplexerMBean(org.mobicents.diameter.stack.DiameterStackMultiplexerMBean) DiameterAvpFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) S6aSessionFactory(org.mobicents.slee.resource.diameter.s6a.handlers.S6aSessionFactory) AvpDataException(org.jdiameter.api.AvpDataException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException) ObjectName(javax.management.ObjectName)

Aggregations

ApplicationId (org.jdiameter.api.ApplicationId)103 Test (org.junit.Test)76 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)76 CxDxMessageFactoryImpl (org.mobicents.slee.resource.diameter.cxdx.CxDxMessageFactoryImpl)18 S6aMessageFactoryImpl (org.mobicents.slee.resource.diameter.s6a.S6aMessageFactoryImpl)16 RxMessageFactoryImpl (org.mobicents.slee.resource.diameter.rx.RxMessageFactoryImpl)12 ObjectName (javax.management.ObjectName)11 InvalidConfigurationException (javax.slee.resource.InvalidConfigurationException)11 CreateActivityException (net.java.slee.resource.diameter.base.CreateActivityException)11 AvpDataException (org.jdiameter.api.AvpDataException)11 ISessionFactory (org.jdiameter.client.api.ISessionFactory)11 DiameterStackMultiplexerMBean (org.mobicents.diameter.stack.DiameterStackMultiplexerMBean)11 DiameterAvpFactoryImpl (org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl)10 OperationNotSupportedException (javax.naming.OperationNotSupportedException)9 DiameterMessageFactoryImpl (org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl)8 GqMessageFactoryImpl (org.mobicents.slee.resource.diameter.gq.GqMessageFactoryImpl)8 IOException (java.io.IOException)7 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)7 InternalException (org.jdiameter.api.InternalException)7 ShServerMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl)7