Search in sources :

Example 91 with ApplicationId

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

the class S6aFactoriesTest method testMessageFactoryApplicationIdChangeAIR.

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

Example 92 with ApplicationId

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

the class S6aFactoriesTest method testMessageFactoryApplicationIdChangePUR.

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

Example 93 with ApplicationId

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

the class S6aFactoriesTest method testServerSessionApplicationIdChangeULA.

@Test
public void testServerSessionApplicationIdChangeULA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((S6aMessageFactoryImpl) s6aMessageFactory).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 S6a is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    UpdateLocationRequest ulr = s6aMessageFactory.createUpdateLocationRequest();
    serverSession.fetchSessionData(ulr);
    UpdateLocationAnswer originalULA = serverSession.createUpdateLocationAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalULA);
    // now we switch..
    originalULA = null;
    isVendor = !isVendor;
    ((S6aMessageFactoryImpl) s6aMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    UpdateLocationAnswer changedULA = serverSession.createUpdateLocationAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedULA);
    // revert back to default
    ((S6aMessageFactoryImpl) s6aMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : S6aMessageFactoryImpl(org.mobicents.slee.resource.diameter.s6a.S6aMessageFactoryImpl) UpdateLocationAnswer(net.java.slee.resource.diameter.s6a.events.UpdateLocationAnswer) ApplicationId(org.jdiameter.api.ApplicationId) UpdateLocationRequest(net.java.slee.resource.diameter.s6a.events.UpdateLocationRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 94 with ApplicationId

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

the class S6aFactoriesTest method testClientSessionApplicationIdChangeDSA.

@Test
public void testClientSessionApplicationIdChangeDSA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((S6aMessageFactoryImpl) s6aMessageFactory).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 S6a is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    DeleteSubscriberDataRequest dsr = s6aMessageFactory.createDeleteSubscriberDataRequest();
    clientSession.fetchSessionData(dsr);
    DeleteSubscriberDataAnswer originalDSA = clientSession.createDeleteSubscriberDataAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalDSA);
    // now we switch..
    originalDSA = null;
    isVendor = !isVendor;
    ((S6aMessageFactoryImpl) s6aMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    DeleteSubscriberDataAnswer changedDSA = clientSession.createDeleteSubscriberDataAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedDSA);
    // revert back to default
    ((S6aMessageFactoryImpl) s6aMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : S6aMessageFactoryImpl(org.mobicents.slee.resource.diameter.s6a.S6aMessageFactoryImpl) DeleteSubscriberDataAnswer(net.java.slee.resource.diameter.s6a.events.DeleteSubscriberDataAnswer) DeleteSubscriberDataRequest(net.java.slee.resource.diameter.s6a.events.DeleteSubscriberDataRequest) ApplicationId(org.jdiameter.api.ApplicationId) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 95 with ApplicationId

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

the class DiameterGxResourceAdaptor method raActive.

/**
 * {@inheritDoc}
 */
@Override
public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter Gx RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter Gx 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.baseMessageFactory = new DiameterMessageFactoryImpl(stack);
        this.gxAvpFactory = new GxAvpFactoryImpl(baseAvpFactory);
        this.gxMessageFactory = new GxMessageFactoryImpl(baseMessageFactory, null, stack);
        // Set the first configured Application-Id as default for message factory
        ApplicationId firstAppId = authApplicationIds.get(0);
        ((GxMessageFactoryImpl) this.gxMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
        this.sessionFactory = this.stack.getSessionFactory();
        this.gxSessionFactory = new GxSessionFactory(this, sessionFactory, defaultDirectDebitingFailureHandling, defaultCreditControlFailureHandling, defaultValidityTime, defaultTxTimerValue);
        // Register Gx App Session Factories
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerGxSession.class, this.gxSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientGxSession.class, this.gxSessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter Gx 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) GxSessionFactory(org.mobicents.slee.resource.diameter.gx.handlers.GxSessionFactory) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) AvpDataException(org.jdiameter.api.AvpDataException) IOException(java.io.IOException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) 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