Search in sources :

Example 1 with UserIdentityAvp

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

the class ShClientFactoriesTest method testAvpFactoryCreateUserIdentity.

@Test
public void testAvpFactoryCreateUserIdentity() throws Exception {
    String avpName = "User-Identity";
    // Create AVP with mandatory values
    UserIdentityAvp uiAvp1 = shAvpFactory.createUserIdentity();
    // Make sure it's not null
    Assert.assertNotNull("Created " + avpName + " AVP from objects should not be null.", uiAvp1);
    // Create AVP with default constructor
    UserIdentityAvp uiAvp2 = shAvpFactory.createUserIdentity();
    // Should not contain mandatory values
    // Set mandatory values
    // Make sure it's equal to the one created with mandatory values constructor
    Assert.assertEquals("Created " + avpName + " AVP from default constructor + set<Mandatory-AVPs> should be equal to original.", uiAvp1, uiAvp2);
    // Make new copy
    uiAvp2 = shAvpFactory.createUserIdentity();
    // And set all values using setters
    ShClientAvpAssistant.INSTANCE.testSetters(uiAvp2);
    // Create empty...
    UserIdentityAvp uiAvp3 = shAvpFactory.createUserIdentity();
    // Verify that no values have been set
    ShClientAvpAssistant.INSTANCE.testHassers(uiAvp3, false);
    // Set all previous values
    uiAvp3.setExtensionAvps(uiAvp2.getExtensionAvps());
    // Verify if values have been set
    ShClientAvpAssistant.INSTANCE.testHassers(uiAvp3, true);
    // Verify if values have been correctly set
    ShClientAvpAssistant.INSTANCE.testGetters(uiAvp3);
    // Make sure they match!
    Assert.assertEquals("Created " + avpName + " AVP from default constructor + setExtensionAvps should be equal to original.", uiAvp2, uiAvp3);
}
Also used : UserIdentityAvp(net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 2 with UserIdentityAvp

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

the class ShClientFactoriesTest method testClientSessionApplicationIdChangePNA.

@Test
public void testClientSessionApplicationIdChangePNA() 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...
    PushNotificationRequest pnr = createPushNotificationRequest();
    UserIdentityAvp uiAvp = shAvpFactory.createUserIdentity();
    uiAvp.setPublicIdentity("alexandre@mobicents.org");
    pnr.setUserIdentity(uiAvp);
    pnr.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
    clientSubsSession.fetchSessionData(pnr, true);
    PushNotificationAnswer originalPNA = clientSubsSession.createPushNotificationAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalPNA);
    // now we switch..
    originalPNA = null;
    isVendor = !isVendor;
    ((ShClientMessageFactoryImpl) shClientFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    PushNotificationAnswer changedPNA = clientSubsSession.createPushNotificationAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedPNA);
    // 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) PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) UserIdentityAvp(net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp) ApplicationId(org.jdiameter.api.ApplicationId) PushNotificationAnswer(net.java.slee.resource.diameter.sh.events.PushNotificationAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 3 with UserIdentityAvp

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

the class ShServerFactoriesTest method testServerSessionApplicationIdChangeUDA.

@Test
public void testServerSessionApplicationIdChangeUDA() 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...
    UserDataRequest udr = shClientFactory.createUserDataRequest();
    UserIdentityAvp uiAvp = shAvpFactory.createUserIdentity();
    uiAvp.setPublicIdentity("alexandre@mobicents.org");
    udr.setUserIdentity(uiAvp);
    udr.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
    serverSession.fetchSessionData(udr, true);
    UserDataAnswer originalUDA = serverSession.createUserDataAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalUDA);
    // now we switch..
    originalUDA = null;
    isVendor = !isVendor;
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    UserDataAnswer changedUDA = serverSession.createUserDataAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedUDA);
    // revert back to default
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : UserDataRequest(net.java.slee.resource.diameter.sh.events.UserDataRequest) UserDataAnswer(net.java.slee.resource.diameter.sh.events.UserDataAnswer) 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 4 with UserIdentityAvp

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

the class HSSClientChildSbb method getChargingInformation.

public String getChargingInformation(String publicIdentity, byte[] msisdn, String destinationRealm, String destinationHost) throws IOException {
    UserIdentityAvp publicIdentityAvp = createUserIdentityAvp(publicIdentity, msisdn);
    UserDataRequest udr = diameterShClientMessageFactory.createUserDataRequest(publicIdentityAvp, DataReferenceType.CHARGING_INFORMATION);
    udr.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
    // Set destination -- Realm is mandatory, host is optional
    udr.setDestinationRealm(new DiameterIdentity(destinationRealm));
    if (destinationHost != null) {
        udr.setDestinationHost(new DiameterIdentity(destinationHost));
    }
    ShClientActivity activity = getShClientActivity();
    activity.sendUserDataRequest(udr);
    // Store request for future matching
    storeRequestInACI(activity, udr);
    // Return Session-Id, may be used as identifier
    return activity.getSessionId();
}
Also used : ShClientActivity(net.java.slee.resource.diameter.sh.client.ShClientActivity) UserDataRequest(net.java.slee.resource.diameter.sh.events.UserDataRequest) DiameterIdentity(net.java.slee.resource.diameter.base.events.avp.DiameterIdentity) UserIdentityAvp(net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)

Example 5 with UserIdentityAvp

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

the class HSSClientChildSbb method subscribeIMSUserState.

public String subscribeIMSUserState(String publicIdentity, int subscriptionRequestType, String destinationRealm, String destinationHost) throws IOException {
    UserIdentityAvp publicIdentityAvp = createUserIdentityAvp(publicIdentity, null);
    SubscribeNotificationsRequest snr = diameterShClientMessageFactory.createSubscribeNotificationsRequest(publicIdentityAvp, DataReferenceType.IMS_USER_STATE, SubsReqType.fromInt(subscriptionRequestType));
    snr.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
    // Set destination -- Realm is mandatory, host is optional
    snr.setDestinationRealm(new DiameterIdentity(destinationRealm));
    if (destinationHost != null) {
        snr.setDestinationHost(new DiameterIdentity(destinationHost));
    }
    ShClientActivity activity = getShClientActivity();
    activity.sendSubscribeNotificationsRequest(snr);
    // Store request for future matching
    storeRequestInACI(activity, snr);
    // Return Session-Id, may be used as identifier
    return activity.getSessionId();
}
Also used : ShClientActivity(net.java.slee.resource.diameter.sh.client.ShClientActivity) SubscribeNotificationsRequest(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest) DiameterIdentity(net.java.slee.resource.diameter.base.events.avp.DiameterIdentity) UserIdentityAvp(net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)

Aggregations

UserIdentityAvp (net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)23 DiameterIdentity (net.java.slee.resource.diameter.base.events.avp.DiameterIdentity)17 ShClientActivity (net.java.slee.resource.diameter.sh.client.ShClientActivity)17 UserDataRequest (net.java.slee.resource.diameter.sh.events.UserDataRequest)12 SubscribeNotificationsRequest (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest)7 Test (org.junit.Test)5 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)5 ProfileUpdateRequest (net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest)4 ApplicationId (org.jdiameter.api.ApplicationId)4 ShServerMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl)3 PushNotificationRequest (net.java.slee.resource.diameter.sh.events.PushNotificationRequest)2 ProfileUpdateAnswer (net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer)1 PushNotificationAnswer (net.java.slee.resource.diameter.sh.events.PushNotificationAnswer)1 SubscribeNotificationsAnswer (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer)1 UserDataAnswer (net.java.slee.resource.diameter.sh.events.UserDataAnswer)1 IdentitySetType (net.java.slee.resource.diameter.sh.events.avp.IdentitySetType)1 ShClientMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl)1