Search in sources :

Example 61 with ApplicationId

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

the class RxFactoriesTest method testMessageFactoryApplicationIdChangeSTR.

// @Test
// public void testClientSessionApplicationIdChangeRAA() throws Exception {
// long vendor = 10415L;
// ApplicationId originalAppId = ((RxMessageFactoryImpl)rxMessageFactory).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 Rx is " + originalAppId.getVendorId());
// // let's create a message and see how it comes...
// ReAuthRequest rar = rxMessageFactory.createReAuthRequest();
// rxClientSession.fetchCurrentState(rar);
// ReAuthAnswer originalRAA = rxClientSession.createReAuthAnswer();
// BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalRAA);
// 
// // now we switch..
// originalRAA = null;
// isVendor = !isVendor;
// ((RxMessageFactoryImpl)rxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ?
// originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// 
// // create a new message and see how it comes...
// ReAuthAnswer changedRAA = rxClientSession.createReAuthAnswer();
// BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedRAA);
// 
// // revert back to default
// ((RxMessageFactoryImpl)rxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ?
// originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// }
@Test
public void testMessageFactoryApplicationIdChangeSTR() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RxMessageFactoryImpl) rxMessageFactory).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 Rx is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    SessionTerminationRequest originalSTR = rxMessageFactory.createSessionTerminationRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalSTR);
    // now we switch..
    originalSTR = null;
    isVendor = !isVendor;
    ((RxMessageFactoryImpl) rxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    SessionTerminationRequest changedSTR = rxMessageFactory.createSessionTerminationRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedSTR);
    // revert back to default
    ((RxMessageFactoryImpl) rxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : RxMessageFactoryImpl(org.mobicents.slee.resource.diameter.rx.RxMessageFactoryImpl) ApplicationId(org.jdiameter.api.ApplicationId) SessionTerminationRequest(net.java.slee.resource.diameter.rx.events.SessionTerminationRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 62 with ApplicationId

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

the class RxFactoriesTest method testMessageFactoryApplicationIdChangeAAR.

@Test
public void testMessageFactoryApplicationIdChangeAAR() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RxMessageFactoryImpl) rxMessageFactory).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 Rx is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    AARequest originalAAR = rxMessageFactory.createAARequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalAAR);
    // now we switch..
    originalAAR = null;
    isVendor = !isVendor;
    ((RxMessageFactoryImpl) rxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    AARequest changedAAR = rxMessageFactory.createAARequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedAAR);
    // revert back to default
    ((RxMessageFactoryImpl) rxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : RxMessageFactoryImpl(org.mobicents.slee.resource.diameter.rx.RxMessageFactoryImpl) AARequest(net.java.slee.resource.diameter.rx.events.AARequest) ApplicationId(org.jdiameter.api.ApplicationId) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 63 with ApplicationId

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

the class RxFactoriesTest method testClientSessionApplicationIdChangeSTR.

@Test
public void testClientSessionApplicationIdChangeSTR() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RxMessageFactoryImpl) rxMessageFactory).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 Rx is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    SessionTerminationRequest originalSTR = rxClientSession.createSessionTermRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalSTR);
    // now we switch..
    originalSTR = null;
    isVendor = !isVendor;
    ((RxMessageFactoryImpl) rxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    SessionTerminationRequest changedSTR = rxClientSession.createSessionTermRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedSTR);
    // revert back to default
    ((RxMessageFactoryImpl) rxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : RxMessageFactoryImpl(org.mobicents.slee.resource.diameter.rx.RxMessageFactoryImpl) ApplicationId(org.jdiameter.api.ApplicationId) SessionTerminationRequest(net.java.slee.resource.diameter.rx.events.SessionTerminationRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 64 with ApplicationId

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

the class DiameterCxDxResourceAdaptor method sessionCreated.

// CxDx Session Creation Listener --------------------------------------
/*
   * (non-Javadoc)
   * @see org.mobicents.slee.resource.diameter.cxdx.handlers.CxDxSessionCreationListener#sessionCreated(org.jdiameter.api.cxdx.ServerCxDxSession)
   */
public void sessionCreated(ServerCxDxSession session) {
    DiameterMessageFactoryImpl baseMsgFactory = new DiameterMessageFactoryImpl(session.getSessions().get(0), stack);
    CxDxMessageFactoryImpl sessionMsgFactory = new CxDxMessageFactoryImpl(baseMsgFactory, 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());
    CxDxServerSessionImpl serverActivity = new CxDxServerSessionImpl(sessionMsgFactory, cxdxAvpFactory, session, this, null, null, stack);
    // session.addStateChangeNotification(serverActivity);
    // addActivity(serverActivity);
    serverActivity.setSessionListener(this);
}
Also used : DiameterMessageFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl) ApplicationId(org.jdiameter.api.ApplicationId)

Example 65 with ApplicationId

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

the class DiameterCxDxResourceAdaptor method raActive.

public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter Cx/Dx RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter Cx/Dx 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 the protocol stack
        initStack();
        // Initialize activities mgmt
        initActivitiesMgmt();
        // Initialize factories
        this.baseAvpFactory = new DiameterAvpFactoryImpl();
        this.baseMessageFactory = new DiameterMessageFactoryImpl(stack);
        this.cxdxAvpFactory = new CxDxAVPFactoryImpl(baseAvpFactory);
        this.cxdxMessageFactory = new CxDxMessageFactoryImpl(baseMessageFactory, stack);
        // Set the first configured Application-Id as default for message factory
        ApplicationId firstAppId = authApplicationIds.get(0);
        ((CxDxMessageFactoryImpl) this.cxdxMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
        // Setup session factories
        this.sessionFactory = this.stack.getSessionFactory();
        this.cxdxSessionFactory = new CxDxSessionFactory(this, messageTimeout, sessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerCxDxSession.class, cxdxSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientCxDxSession.class, cxdxSessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter Cx/Dx RA Entity", e);
    }
}
Also used : DiameterStackMultiplexerMBean(org.mobicents.diameter.stack.DiameterStackMultiplexerMBean) DiameterMessageFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl) DiameterAvpFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl) CxDxSessionFactory(org.mobicents.slee.resource.diameter.cxdx.handlers.CxDxSessionFactory) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) 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