Search in sources :

Example 76 with ApplicationId

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;
}
Also used : IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) ApplicationId(org.jdiameter.api.ApplicationId) InternalException(org.jdiameter.api.InternalException)

Example 77 with ApplicationId

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());
}
Also used : CxDxMessageFactoryImpl(org.mobicents.slee.resource.diameter.cxdx.CxDxMessageFactoryImpl) ApplicationId(org.jdiameter.api.ApplicationId) PushProfileRequest(net.java.slee.resource.diameter.cxdx.events.PushProfileRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 78 with ApplicationId

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;
}
Also used : AbortSessionRequest(net.java.slee.resource.diameter.base.events.AbortSessionRequest) ApplicationId(org.jdiameter.api.ApplicationId)

Example 79 with ApplicationId

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;
}
Also used : ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) ApplicationId(org.jdiameter.api.ApplicationId) ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) MessageImpl(org.jdiameter.client.impl.parser.MessageImpl)

Example 80 with ApplicationId

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);
    }
}
Also used : DiameterStackMultiplexerMBean(org.mobicents.diameter.stack.DiameterStackMultiplexerMBean) ShServerSessionFactory(org.mobicents.slee.resource.diameter.sh.server.handlers.ShServerSessionFactory) DiameterAvpFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) AvpDataException(org.jdiameter.api.AvpDataException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) 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) DiameterShAvpFactoryImpl(org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl)

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