Ibm mobilefirst MobileFirst 8:在UserAuthenticationSecurityCheck中获取客户端数据(IP地址、请求数据)

Ibm mobilefirst MobileFirst 8:在UserAuthenticationSecurityCheck中获取客户端数据(IP地址、请求数据),ibm-mobilefirst,mobilefirst-adapters,mobilefirst-server,Ibm Mobilefirst,Mobilefirst Adapters,Mobilefirst Server,我试图在UserAuthenticationSecurityCheck方法中获取一些客户端数据 IP地址对它来说是最重要的 在其他适配器中,我使用的是HttpServletRequest: @Context protected HttpServletRequest request; 但此请求对象在UserAuthenticationSecurityCheck中始终为空 如何获取此类中的客户端数据(IP地址或头?您不能将HttpServletRequest注入到安全检查对象中(根据设计-不是bu

我试图在UserAuthenticationSecurityCheck方法中获取一些客户端数据

IP地址对它来说是最重要的

在其他适配器中,我使用的是HttpServletRequest:

@Context
protected HttpServletRequest request;
但此请求对象在UserAuthenticationSecurityCheck中始终为空


如何获取此类中的客户端数据(IP地址或头?

您不能将HttpServletRequest注入到安全检查对象中(根据设计-不是bug)。一旦用户通过身份验证,就可以进行另一个适配器调用,从中可以获得所需的详细信息。不幸的是,这在任何地方都没有记录(至少据我所知)


如前所述,我对AdapterAPI类也有类似的问题

您可以在安全适配器中获取请求,但不能从@Context获取请求。 只需覆盖授权方法:

@Override
public void authorize(Set<String> scope, Map<String, Object> credentials, HttpServletRequest request, AuthorizationResponse response) {
    //TODO use request object 
    super.authorize(scope, credentials, request, response);

}
@覆盖
public void authorize(设置作用域、映射凭据、HttpServletRequest请求、AuthorizationResponse响应){
//TODO使用请求对象
超级授权(范围、凭证、请求、响应);
}