Search in sources :

Example 6 with PushNotificationRequest

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

the class ShServerFactoriesTest method isProxiableRAR.

@Test
public void isProxiableRAR() throws Exception {
    PushNotificationRequest pnr = shServerFactory.createPushNotificationRequest();
    assertTrue("The 'P' bit is not set by default in Push-Notification-Request, it should.", pnr.getHeader().isProxiable());
}
Also used : PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 7 with PushNotificationRequest

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

the class ShServerFactoriesTest method testMessageFactoryApplicationIdChangePNR.

@Test
public void testMessageFactoryApplicationIdChangePNR() 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...
    PushNotificationRequest originalPNR = shServerFactory.createPushNotificationRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalPNR);
    // now we switch..
    originalPNR = null;
    isVendor = !isVendor;
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    PushNotificationRequest changedPNR = shServerFactory.createPushNotificationRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedPNR);
    // revert back to default
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) 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 8 with PushNotificationRequest

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

the class HSSClientChildSbb method getUserIdentityValues.

private String[] getUserIdentityValues(DiameterShMessage shMessage) {
    UserIdentityAvp uIdAvp = null;
    if (shMessage instanceof UserDataRequest) {
        uIdAvp = ((UserDataRequest) shMessage).getUserIdentity();
    } else if (shMessage instanceof ProfileUpdateRequest) {
        uIdAvp = ((ProfileUpdateRequest) shMessage).getUserIdentity();
    } else if (shMessage instanceof SubscribeNotificationsRequest) {
        uIdAvp = ((SubscribeNotificationsRequest) shMessage).getUserIdentity();
    } else if (shMessage instanceof PushNotificationRequest) {
        uIdAvp = ((PushNotificationRequest) shMessage).getUserIdentity();
    }
    String publicIdentity = null;
    String msisdn = null;
    if (uIdAvp != null) {
        publicIdentity = uIdAvp.getPublicIdentity();
        msisdn = uIdAvp.getMsisdn();
        if (publicIdentity == null && msisdn == null) {
            tracer.warning("Unable to retrieve Public User/Service Identity OR MSISDN. At least one of them should be present.");
        }
    } else {
        tracer.warning("User-Identity AVP missing in Diameter Sh Message.");
    }
    return new String[] { publicIdentity, msisdn };
}
Also used : UserDataRequest(net.java.slee.resource.diameter.sh.events.UserDataRequest) SubscribeNotificationsRequest(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest) PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) ProfileUpdateRequest(net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest) UserIdentityAvp(net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)

Example 9 with PushNotificationRequest

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

the class ShServerSubscriptionActivityImpl method sendPushNotificationRequest.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.sh.server.ShServerSubscriptionActivity#sendPushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest)
   */
public void sendPushNotificationRequest(PushNotificationRequest message) throws IOException {
    try {
        DiameterShMessageImpl msg = (DiameterShMessageImpl) message;
        fetchSessionData(msg, false);
        this.serverSession.sendPushNotificationRequest(new PushNotificationRequestImpl((Request) msg.getGenericData()));
        clean(msg);
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Failed to send message.", e);
        }
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : PushNotificationRequestImpl(org.jdiameter.common.impl.app.sh.PushNotificationRequestImpl) DiameterShMessageImpl(org.mobicents.slee.resource.diameter.sh.events.DiameterShMessageImpl) ProfileUpdateRequest(net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest) SubscribeNotificationsRequest(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest) Request(org.jdiameter.api.Request) PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) UserDataRequest(net.java.slee.resource.diameter.sh.events.UserDataRequest) IOException(java.io.IOException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException)

Example 10 with PushNotificationRequest

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

the class ShServerFactoriesTest method isRequestPNR.

@Test
public void isRequestPNR() throws Exception {
    PushNotificationRequest pnr = shServerFactory.createPushNotificationRequest();
    assertTrue("Request Flag in Push-Notification-Request is not set.", pnr.getHeader().isRequest());
}
Also used : PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

PushNotificationRequest (net.java.slee.resource.diameter.sh.events.PushNotificationRequest)14 Test (org.junit.Test)10 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)10 PushNotificationAnswer (net.java.slee.resource.diameter.sh.events.PushNotificationAnswer)5 ApplicationId (org.jdiameter.api.ApplicationId)3 ShClientMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl)3 ProfileUpdateRequest (net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest)2 SubscribeNotificationsRequest (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest)2 UserDataRequest (net.java.slee.resource.diameter.sh.events.UserDataRequest)2 UserIdentityAvp (net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)2 DiameterShMessageImpl (org.mobicents.slee.resource.diameter.sh.events.DiameterShMessageImpl)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 Request (org.jdiameter.api.Request)1 ClientShSession (org.jdiameter.api.sh.ClientShSession)1 ShClientSessionDataLocalImpl (org.jdiameter.client.impl.app.sh.ShClientSessionDataLocalImpl)1 ShClientSessionImpl (org.jdiameter.client.impl.app.sh.ShClientSessionImpl)1 PushNotificationRequestImpl (org.jdiameter.common.impl.app.sh.PushNotificationRequestImpl)1