我正在使用MobileFirst Platform Foundation 7.1(7.1.0.00.20150913-2345),并且我正在使用Java适配器,并且我有一个定制登录模块和一个自定义身份验证器,我的代码类似于this 。在我的情况下,我有一些非ASCII字符串。例如:CustomAuthenticator和/或CustomLoginModule中的非ASCII字符
在CustomAuthenticator代替:
public AuthenticationResult processRequest(HttpServletRequest request, HttpServletResponse response, boolean isAccessToProtectedResource) throws IOException, ServletException {
...
response.getWriter()
.print("{\"authStatus\":\"required\", \"errorMessage\":\"Please enter username and password\"}");
...
}
我:
public AuthenticationResult processRequest(HttpServletRequest request, HttpServletResponse response, boolean isAccessToProtectedResource) throws IOException, ServletException {
...
response.getWriter()
.print("{\"authStatus\":\"required\", \"errorMessage\":\"ユーザー名とパスワードを入力してください\"}");
...
}
在CustomLoginModule在login
我有一些例外与非ASCII字符串:
public boolean login(Map<String, Object> authenticationData) {
...
// Invalid credentials
throw new RuntimeException("有効なユーザーIDとパスワードを入力してください");
}
从iOS本地应用程序调用适配器时:在Mac OSX中,它的效果很好但生产服务器在Windows中,并且iPad应用程序收到errorMessage
为乱码文本(mojibake文字化け)。有没有办法解决这个问题?
另外我有过的UserIdentity对象一些非ASCII数据,当我尝试访问它在Java适配器是乱码太:
@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.
}
是什么奇怪的是,我有另一JavaScript的适配器(共享相同的自定义认证和登录模块)和获取信息从那里是OK:
// Javascript Adapter
function myProcedure(p){
var user = WL.Server.getActiveUser();
// user.displayName is OK in windows and OSX
}
它看起来像用户数据的序列化是越野车?有人知道这在某些环境中是真的是错误还是错误?
感谢!让我来试试这些后来将报告:) – nacho4d