Search in sources :

Example 16 with SubscribeNotificationsRequest

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

the class ShServerSubscriptionActivityImpl method createSubscribeNotificationsAnswer.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.sh.server.ShServerSubscriptionActivity#createSubscribeNotificationsAnswer(long, boolean)
   */
public SubscribeNotificationsAnswer createSubscribeNotificationsAnswer(long resultCode, boolean isExperimentalResult) {
    SubscribeNotificationsAnswer answer = null;
    for (int index = 0; index < stateMessages.size(); index++) {
        if (stateMessages.get(index).getCommand().getCode() == SubscribeNotificationsRequest.commandCode) {
            SubscribeNotificationsRequest msg = (SubscribeNotificationsRequest) stateMessages.get(index);
            answer = this.messageFactory.createSubscribeNotificationsAnswer(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 : SubscribeNotificationsRequest(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest) SubscribeNotificationsAnswer(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer) DiameterShMessageImpl(org.mobicents.slee.resource.diameter.sh.events.DiameterShMessageImpl)

Example 17 with SubscribeNotificationsRequest

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

the class ShServerSubscriptionActivityImpl method createSubscribeNotificationsAnswer.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.sh.server.ShServerSubscriptionActivity#createSubscribeNotificationsAnswer()
   */
public SubscribeNotificationsAnswer createSubscribeNotificationsAnswer() {
    SubscribeNotificationsAnswer answer = null;
    for (int index = 0; index < stateMessages.size(); index++) {
        if (stateMessages.get(index).getCommand().getCode() == SubscribeNotificationsRequest.commandCode) {
            SubscribeNotificationsRequest msg = (SubscribeNotificationsRequest) stateMessages.get(index);
            answer = this.messageFactory.createSubscribeNotificationsAnswer(msg);
            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 : SubscribeNotificationsRequest(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest) SubscribeNotificationsAnswer(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer) DiameterShMessageImpl(org.mobicents.slee.resource.diameter.sh.events.DiameterShMessageImpl)

Example 18 with SubscribeNotificationsRequest

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

the class ShServerFactoriesTest method hasTFlagSetSNA.

@Test
public void hasTFlagSetSNA() throws Exception {
    SubscribeNotificationsRequest snr = shClientFactory.createSubscribeNotificationsRequest();
    ((DiameterMessageImpl) snr).getGenericData().setReTransmitted(true);
    assertTrue("The 'T' flag should be set in Subscribe-Notifications-Request", snr.getHeader().isPotentiallyRetransmitted());
    SubscribeNotificationsAnswer sna = shServerFactory.createSubscribeNotificationsAnswer(snr);
    assertFalse("The 'T' flag should not be set in Subscribe-Notifications-Answer", sna.getHeader().isPotentiallyRetransmitted());
}
Also used : SubscribeNotificationsRequest(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest) SubscribeNotificationsAnswer(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 19 with SubscribeNotificationsRequest

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

the class ShServerFactoriesTest method testServerSessionApplicationIdChangeSNA.

@Test
public void testServerSessionApplicationIdChangeSNA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((ShServerMessageFactoryImpl) shServerFactory).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...
    SubscribeNotificationsRequest snr = shClientFactory.createSubscribeNotificationsRequest();
    UserIdentityAvp uiAvp = shAvpFactory.createUserIdentity();
    uiAvp.setPublicIdentity("alexandre@mobicents.org");
    snr.setUserIdentity(uiAvp);
    snr.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
    serverSession.fetchSessionData(snr, true);
    SubscribeNotificationsAnswer originalSNA = serverSession.createSubscribeNotificationsAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalSNA);
    // now we switch..
    originalSNA = null;
    isVendor = !isVendor;
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    SubscribeNotificationsAnswer changedSNA = serverSession.createSubscribeNotificationsAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedSNA);
    // revert back to default
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : SubscribeNotificationsRequest(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest) SubscribeNotificationsAnswer(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer) UserIdentityAvp(net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp) ApplicationId(org.jdiameter.api.ApplicationId) ShServerMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 20 with SubscribeNotificationsRequest

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

the class ShClientSubscriptionActivityImpl method sendSubscribeNotificationsRequest.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.sh.ShClientSubscriptionActivity#sendSubscribeNotificationsRequest(net.java.slee.resource.diameter.sh.server.events.SubscribeNotificationsRequest)
   */
public void sendSubscribeNotificationsRequest(SubscribeNotificationsRequest request) throws IOException {
    try {
        DiameterMessageImpl msg = (DiameterMessageImpl) request;
        this.clientSession.sendSubscribeNotificationsRequest(new SubscribeNotificationsRequestImpl((Request) msg.getGenericData()));
        fetchSessionData(msg, false);
    } 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.getLocalizedMessage());
    }
}
Also used : SubscribeNotificationsRequest(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest) Request(org.jdiameter.api.Request) PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) SubscribeNotificationsRequestImpl(org.jdiameter.common.impl.app.sh.SubscribeNotificationsRequestImpl) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException)

Aggregations

SubscribeNotificationsRequest (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest)23 Test (org.junit.Test)8 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)8 SubscribeNotificationsAnswer (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer)7 UserIdentityAvp (net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)7 DiameterIdentity (net.java.slee.resource.diameter.base.events.avp.DiameterIdentity)5 ShClientActivity (net.java.slee.resource.diameter.sh.client.ShClientActivity)5 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)4 IOException (java.io.IOException)3 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)3 PushNotificationRequest (net.java.slee.resource.diameter.sh.events.PushNotificationRequest)3 Request (org.jdiameter.api.Request)3 SubscribeNotificationsRequestImpl (org.jdiameter.common.impl.app.sh.SubscribeNotificationsRequestImpl)3 ProfileUpdateRequest (net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest)2 UserDataRequest (net.java.slee.resource.diameter.sh.events.UserDataRequest)2 ApplicationId (org.jdiameter.api.ApplicationId)2 DiameterShMessageImpl (org.mobicents.slee.resource.diameter.sh.events.DiameterShMessageImpl)2 UserIdentityAvpImpl (org.mobicents.slee.resource.diameter.sh.events.avp.UserIdentityAvpImpl)2 AvpRepresentation (org.mobicents.diameter.dictionary.AvpRepresentation)1 ShClientMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl)1