Search in sources :

Example 26 with UserDataRequest

use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.

the class ShServerSubscriptionActivityImpl method createUserDataAnswer.

public UserDataAnswer createUserDataAnswer(long resultCode, boolean isExperimentalResult) {
    UserDataAnswer answer = null;
    for (int index = 0; index < stateMessages.size(); index++) {
        if (stateMessages.get(index).getCommand().getCode() == UserDataRequest.commandCode) {
            UserDataRequest msg = (UserDataRequest) stateMessages.get(index);
            answer = this.messageFactory.createUserDataAnswer(msg, resultCode, isExperimentalResult);
            if (answer.getAuthSessionState() == null && this.authSessionState != null) {
                answer.setAuthSessionState(this.authSessionState);
            }
            ((DiameterShMessageImpl) answer).setData(msg);
            break;
        }
    }
    // answer.setSessionId(super.session.getSessionId());
    return answer;
}
Also used : UserDataAnswer(net.java.slee.resource.diameter.sh.events.UserDataAnswer) UserDataRequest(net.java.slee.resource.diameter.sh.events.UserDataRequest) DiameterShMessageImpl(org.mobicents.slee.resource.diameter.sh.events.DiameterShMessageImpl)

Example 27 with UserDataRequest

use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.

the class ShClientActivityImpl method sendUserDataRequest.

public void sendUserDataRequest(UserDataRequest message) throws IOException {
    try {
        DiameterMessageImpl msg = (DiameterMessageImpl) message;
        this.clientSession.sendUserDataRequest(new UserDataRequestImpl((Request) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : Request(org.jdiameter.api.Request) ProfileUpdateRequest(net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest) SubscribeNotificationsRequest(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest) UserDataRequest(net.java.slee.resource.diameter.sh.events.UserDataRequest) IOException(java.io.IOException) UserDataRequestImpl(org.jdiameter.common.impl.app.sh.UserDataRequestImpl) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 28 with UserDataRequest

use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.

the class ShServerActivityAnswerCreationTest method testShServerSubscriptionActivityAnswerCreation.

@Test
public void testShServerSubscriptionActivityAnswerCreation() throws Exception {
    ServerShSession session = new ShServerSessionImpl(new ShServerSessionDataLocalImpl(), new IShMessageFactoryImpl(), (ISessionFactory) stack.getSessionFactory(), new ServerShSessionListenerImpl());
    DiameterMessageFactoryImpl msgFactory = new DiameterMessageFactoryImpl(session.getSessions().get(0), stack, null, null);
    ShClientMessageFactoryImpl factory = new ShClientMessageFactoryImpl(session.getSessions().get(0), stack);
    UserDataRequest udr = factory.createUserDataRequest();
    net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest pur = factory.createProfileUpdateRequest();
    net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest snr = factory.createSubscribeNotificationsRequest();
    ArrayList<DiameterMessage> list = new ArrayList<DiameterMessage>();
    list.add(udr);
    list.add(pur);
    list.add(snr);
    ShServerSubscriptionActivityImpl activity = new ShServerSubscriptionActivityImpl(new ShServerMessageFactoryImpl(msgFactory, session.getSessions().get(0), stack, diameterShAvpFactory), diameterShAvpFactory, session, null, null);
    DiameterActivityAnswerCreationHelper.testAnswerCreation(activity, "stateMessages", list);
}
Also used : ShServerSubscriptionActivityImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerSubscriptionActivityImpl) UserDataRequest(net.java.slee.resource.diameter.sh.events.UserDataRequest) ArrayList(java.util.ArrayList) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ShClientMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl) ShServerSessionImpl(org.jdiameter.server.impl.app.sh.ShServerSessionImpl) DiameterMessageFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl) ShServerMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl) ServerShSession(org.jdiameter.api.sh.ServerShSession) ShServerSessionDataLocalImpl(org.jdiameter.server.impl.app.sh.ShServerSessionDataLocalImpl) Test(org.junit.Test) ShClientActivityAnswerCreationTest(org.mobicents.slee.resource.diameter.sh.client.tests.activities.ShClientActivityAnswerCreationTest)

Example 29 with UserDataRequest

use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.

the class ShClientFactoriesTest method testMessageFactoryApplicationIdChangeUDR.

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

Aggregations

UserDataRequest (net.java.slee.resource.diameter.sh.events.UserDataRequest)29 UserIdentityAvp (net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)12 DiameterIdentity (net.java.slee.resource.diameter.base.events.avp.DiameterIdentity)10 ShClientActivity (net.java.slee.resource.diameter.sh.client.ShClientActivity)10 Test (org.junit.Test)10 UserDataAnswer (net.java.slee.resource.diameter.sh.events.UserDataAnswer)9 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)8 ShClientMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl)3 DiameterShMessageImpl (org.mobicents.slee.resource.diameter.sh.events.DiameterShMessageImpl)3 ShServerMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl)3 ArrayList (java.util.ArrayList)2 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)2 ProfileUpdateRequest (net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest)2 SubscribeNotificationsRequest (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest)2 ApplicationId (org.jdiameter.api.ApplicationId)2 ServerShSession (org.jdiameter.api.sh.ServerShSession)2 ShServerSessionDataLocalImpl (org.jdiameter.server.impl.app.sh.ShServerSessionDataLocalImpl)2 ShServerSessionImpl (org.jdiameter.server.impl.app.sh.ShServerSessionImpl)2 DiameterMessageFactoryImpl (org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl)2 ShClientActivityAnswerCreationTest (org.mobicents.slee.resource.diameter.sh.client.tests.activities.ShClientActivityAnswerCreationTest)2