Search in sources :

Example 31 with ApplicationId

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

the class DiameterRxResourceAdaptor method raActive.

/**
 * {@inheritDoc}
 */
@Override
public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter Rx RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter Rx 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.rxAvpFactory = new RxAvpFactoryImpl(baseAvpFactory);
        this.rxMessageFactory = new RxMessageFactoryImpl(baseMessageFactory, null, stack);
        // Set the first configured Application-Id as default for message factory
        ApplicationId firstAppId = authApplicationIds.get(0);
        ((RxMessageFactoryImpl) this.rxMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
        this.sessionFactory = this.stack.getSessionFactory();
        this.rxSessionFactory = new RxSessionFactory(this, sessionFactory);
        // Register Rx App Session Factories
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerRxSession.class, this.rxSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientRxSession.class, this.rxSessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter Rx 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) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) RxSessionFactory(org.mobicents.slee.resource.diameter.rx.handlers.RxSessionFactory) AvpDataException(org.jdiameter.api.AvpDataException) IOException(java.io.IOException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException) ObjectName(javax.management.ObjectName)

Example 32 with ApplicationId

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

the class RxMessageFactoryImpl method getApplicationId.

private ApplicationId getApplicationId(DiameterAvp[] avps) {
    ApplicationId applicationId = null;
    long vendorId = 0L;
    // Try to get Application-Id from Message AVPs
    if (avps != null) {
        for (DiameterAvp avp : avps) {
            if (avp.getCode() == DiameterAvpCodes.VENDOR_ID) {
                vendorId = avp.intValue();
            }
            if (avp.getCode() == DiameterAvpCodes.VENDOR_SPECIFIC_APPLICATION_ID) {
                applicationId = getApplicationId(((GroupedAvp) avp).getExtensionAvps());
                break;
            }
            if (avp.getCode() == DiameterAvpCodes.ACCT_APPLICATION_ID) {
                applicationId = ApplicationId.createByAccAppId(vendorId, avp.intValue());
                break;
            } else if (avp.getCode() == DiameterAvpCodes.AUTH_APPLICATION_ID) {
                applicationId = ApplicationId.createByAuthAppId(vendorId, avp.intValue());
                break;
            }
        }
    }
    return applicationId;
}
Also used : GroupedAvp(net.java.slee.resource.diameter.base.events.avp.GroupedAvp) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ApplicationId(org.jdiameter.api.ApplicationId)

Example 33 with ApplicationId

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

the class DiameterRfResourceAdaptor method raActive.

public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter Rf RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter Rf 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();
        // Init activities mgmt
        initActivitiesMgmt();
        // Initialize factories
        this.baseAvpFactory = new DiameterAvpFactoryImpl();
        this.baseMessageFactory = new DiameterMessageFactoryImpl(stack);
        this.rfAvpFactory = new RfAvpFactoryImpl();
        this.rfMessageFactory = new RfMessageFactoryImpl(baseMessageFactory, null, stack);
        // Set the first configured Application-Id as default for message factory
        ApplicationId firstAppId = acctApplicationIds.get(0);
        ((RfMessageFactoryImpl) this.rfMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAcctAppId());
        // Register Accounting App Session Factories
        this.sessionFactory = this.stack.getSessionFactory();
        this.rfSessionFactory = new RfSessionFactory(this, sessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerRfSession.class, rfSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientRfSession.class, rfSessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter Rf RA Entity", e);
    }
}
Also used : RfSessionFactory(org.mobicents.slee.resource.diameter.rf.handlers.RfSessionFactory) IRfSessionFactory(org.jdiameter.common.api.app.rf.IRfSessionFactory) DiameterStackMultiplexerMBean(org.mobicents.diameter.stack.DiameterStackMultiplexerMBean) DiameterMessageFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl) DiameterAvpFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl) 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)

Example 34 with ApplicationId

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

the class RfFactoriesTest method testMessageFactoryApplicationIdChangeACR.

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

Example 35 with ApplicationId

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

the class RfFactoriesTest method testServerSessionApplicationIdChangeACA.

@Test
public void testServerSessionApplicationIdChangeACA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RfMessageFactoryImpl) rfMessageFactory).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 Rf is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    RfAccountingRequest acr = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
    ((RfServerSessionActivityImpl) rfServerSession).fetchSessionData(acr, true);
    RfAccountingAnswer originalACA = rfServerSession.createRfAccountingAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalACA);
    // now we switch..
    originalACA = null;
    isVendor = !isVendor;
    ((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    RfAccountingAnswer changedACA = rfServerSession.createRfAccountingAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedACA);
    changedACA = rfServerSession.createRfAccountingAnswer(acr);
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedACA);
    // revert back to default
    ((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : RfServerSessionActivityImpl(org.mobicents.slee.resource.diameter.rf.RfServerSessionActivityImpl) RfMessageFactoryImpl(org.mobicents.slee.resource.diameter.rf.RfMessageFactoryImpl) RfAccountingAnswer(net.java.slee.resource.diameter.rf.events.RfAccountingAnswer) RfAccountingRequest(net.java.slee.resource.diameter.rf.events.RfAccountingRequest) ApplicationId(org.jdiameter.api.ApplicationId) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

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