use of net.java.slee.resource.diameter.sh.events.UserDataAnswer in project jain-slee.diameter by RestComm.
the class ShServerFactoriesTest method isProxiableCopiedUDA.
@Test
public void isProxiableCopiedUDA() throws Exception {
UserDataRequest udr = shClientFactory.createUserDataRequest();
UserDataAnswer uda = shServerFactory.createUserDataAnswer(udr);
assertEquals("The 'P' bit is not copied from request in User-Data-Answer, it should. [RFC3588/6.2]", udr.getHeader().isProxiable(), uda.getHeader().isProxiable());
// Reverse 'P' bit ...
((DiameterMessageImpl) udr).getGenericData().setProxiable(!udr.getHeader().isProxiable());
assertTrue("The 'P' bit was not modified in User-Data-Request, it should.", udr.getHeader().isProxiable() != uda.getHeader().isProxiable());
uda = shServerFactory.createUserDataAnswer(udr);
assertEquals("The 'P' bit is not copied from request in User-Data-Answer, it should. [RFC3588/6.2]", udr.getHeader().isProxiable(), uda.getHeader().isProxiable());
}
use of net.java.slee.resource.diameter.sh.events.UserDataAnswer 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());
}
use of net.java.slee.resource.diameter.sh.events.UserDataAnswer in project jain-slee.diameter by RestComm.
the class ShServerActivityImpl method sendUserDataAnswer.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.sh.server.ShServerActivity#sendUserDataAnswer(net.java.slee.resource.diameter.sh.events.UserDataAnswer)
*/
public void sendUserDataAnswer(UserDataAnswer message) throws IOException {
try {
DiameterShMessageImpl msg = (DiameterShMessageImpl) message;
fetchSessionData(msg, false);
this.serverSession.sendUserDataAnswer(new UserDataAnswerImpl((Answer) 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);
}
}
use of net.java.slee.resource.diameter.sh.events.UserDataAnswer in project jain-slee.diameter by RestComm.
the class ShServerMessageFactoryImpl method createUserDataAnswer.
public UserDataAnswer createUserDataAnswer(UserDataRequest request, byte[] userData) {
UserDataAnswer uda = this.createUserDataAnswer(request);
uda.setUserData(userData);
return uda;
}
use of net.java.slee.resource.diameter.sh.events.UserDataAnswer 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;
}
Aggregations