use of net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest in project jain-slee.diameter by RestComm.
the class ShClientSubscriptionActivityImpl method fetchSessionData.
/**
* @param request
*/
public void fetchSessionData(DiameterMessage msg, boolean incoming) {
if (msg.getHeader().isRequest()) {
// Well it should always be getting this on request and only once ?
if (incoming) {
if (this.userIdentity == null) {
// FIXME: make this diff.
AvpRepresentation rep = AvpDictionary.INSTANCE.getAvp(DiameterShAvpCodes.USER_IDENTITY, DiameterShAvpCodes.SH_VENDOR_ID);
this.userIdentity = new UserIdentityAvpImpl(DiameterShAvpCodes.USER_IDENTITY, DiameterShAvpCodes.SH_VENDOR_ID, rep.getRuleMandatoryAsInt(), rep.getRuleProtectedAsInt(), AvpUtilities.getAvpAsGrouped(DiameterShAvpCodes.USER_IDENTITY, DiameterShAvpCodes.SH_VENDOR_ID, ((DiameterMessageImpl) msg).getGenericData().getAvps()));
}
if (this.authSessionState == null) {
this.authSessionState = AuthSessionStateType.fromInt(AvpUtilities.getAvpAsInteger32(277, ((DiameterMessageImpl) msg).getGenericData().getAvps()));
}
stateMessages.add((DiameterMessageImpl) msg);
} else {
// FIXME: this should be up there... in incoming?
if (destinationRealm == null) {
this.remoteRealm = msg.getDestinationRealm();
}
if (msg instanceof SubscribeNotificationsRequest) {
SubscribeNotificationsRequest snr = (SubscribeNotificationsRequest) msg;
if (dataReferenceType == null || dataReferenceType.length == 0) {
dataReferenceType = snr.getDataReferences();
}
if (authSessionState == null && snr.hasAuthSessionState()) {
authSessionState = snr.getAuthSessionState();
}
if (userIdentity == null && snr.hasUserIdentity()) {
userIdentity = snr.getUserIdentity();
}
}
}
}
}
use of net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest in project jain-slee.diameter by RestComm.
the class ShClientFactoriesTest method isRequestSNR.
@Test
public void isRequestSNR() throws Exception {
SubscribeNotificationsRequest snr = shClientFactory.createSubscribeNotificationsRequest();
assertTrue("Request Flag in Subscribe-Notifications-Request is not set.", snr.getHeader().isRequest());
}
use of net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest in project jain-slee.diameter by RestComm.
the class ShClientFactoriesTest method testMessageFactoryApplicationIdChangeSNR.
@Test
public void testMessageFactoryApplicationIdChangeSNR() 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...
SubscribeNotificationsRequest originalSNR = shClientFactory.createSubscribeNotificationsRequest();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalSNR);
// now we switch..
originalSNR = null;
isVendor = !isVendor;
((ShClientMessageFactoryImpl) shClientFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
SubscribeNotificationsRequest changedSNR = shClientFactory.createSubscribeNotificationsRequest();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedSNR);
// revert back to default
((ShClientMessageFactoryImpl) shClientFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Aggregations