I am using MobileFirst Platform Foundation 7.1 (7.1.0.00.20150913-2345) and I am using Java adapters and I have a custom login module with a custom authenticator and my code resembles this. In my case I have some non-ascii strings. For example:
In CustomAuthenticator instead of :
public AuthenticationResult processRequest(HttpServletRequest request, HttpServletResponse response, boolean isAccessToProtectedResource) throws IOException, ServletException {
...
response.getWriter()
.print("{\"authStatus\":\"required\", \"errorMessage\":\"Please enter username and password\"}");
...
}
I have:
public AuthenticationResult processRequest(HttpServletRequest request, HttpServletResponse response, boolean isAccessToProtectedResource) throws IOException, ServletException {
...
response.getWriter()
.print("{\"authStatus\":\"required\", \"errorMessage\":\"ユーザー名とパスワードを入力してください\"}");
...
}
In CustomLoginModule in login I have some exceptions with non-ascii strings:
public boolean login(Map<String, Object> authenticationData) {
...
// Invalid credentials
throw new RuntimeException("有効なユーザーIDとパスワードを入力してください");
}
When calling the adapter from an iOS native app: In Mac OSX it works great but the production server is in Windows and the iPad app receives the errorMessage as garbled text (mojibake 文字化け). Is there a way I can solve this?
In addition I have some non-ascii data in userIdentity object and when I try to access it in the Java Adapter it is garbled too:
@POST
@Produces("application/json")
@Path("/enter")
@OAuthSecurity(scope="MyRealm")
public Response enter(){
SecurityAPI security = serverAPI.getSecurityAPI();
String displayName = security.getSecurityContext().getUserIdentity().getDisplayName();
// At this point displayName is garbled text when server is in windows. in OSX is OK.
}
What is weird is that I have another javascript adapter (that shares the same custom authenticator and login module) and getting the info from there is OK:
// Javascript Adapter
function myProcedure(p){
var user = WL.Server.getActiveUser();
// user.displayName is OK in windows and OSX
}
It looks like serialization of user data is buggy? Does anybody know if this is really a bug or a a mistake in some settings?