Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ibm mobilefirst 安全检查后的IBM MFP8响应_Ibm Mobilefirst - Fatal编程技术网

Ibm mobilefirst 安全检查后的IBM MFP8响应

Ibm mobilefirst 安全检查后的IBM MFP8响应,ibm-mobilefirst,Ibm Mobilefirst,我正在我的应用程序中使用MFP8。我正在使用安全检查框架来验证用户。为了验证用户,我使用一些后端层来验证用户。一旦用户验证,我的后端服务将返回巨大的JSON。现在我需要将此响应发送给客户端 PFB我在UserLogin适配器中尝试过的代码。来自后端层的任何响应都是JSON格式的巨大响应(75-80KB)。请帮助如何将此响应从安全检查发送到客户端 附言: public class UserLoginResource extends UserAuthenticationSecurityCheck {

我正在我的应用程序中使用MFP8。我正在使用安全检查框架来验证用户。为了验证用户,我使用一些后端层来验证用户。一旦用户验证,我的后端服务将返回巨大的JSON。现在我需要将此响应发送给客户端

PFB我在UserLogin适配器中尝试过的代码。来自后端层的任何响应都是JSON格式的巨大响应(75-80KB)。请帮助如何将此响应从安全检查发送到客户端

附言:

public class UserLoginResource extends UserAuthenticationSecurityCheck {
    private String userId, displayName,errorMsg, cdata, hdata, rid, urlParams, serviceName, queryParameters;   
    private boolean rememberMe = false;
    private boolean authFlag=true;  
    public static JSONObject queryResponse;
    private Map<String, Object> attributes = new HashMap<String, Object>();

    @Context
    AdapterSecurityContext adapterSecurityContext;

    @Override
    protected AuthenticatedUser createUser() {       
        System.out.println("User Authenticated Result "+ userId);        
        return new AuthenticatedUser(userId, displayName, this.getName(), attributes);
    }

    @Override
    protected boolean validateCredentials(Map<String, Object> credentials) {

        try{            
            String username=credentials.get("username").toString();     
            String password = credentials.get("password").toString();    ;

            if (username != null && password != null) {

                queryResponse = <my backend layer>(username, password);

                if(queryResponse.errorExist){                       
                    System.out.println("User Authentication Failed");
                    errorMsg="User Authentication Failed";
                    return false;
                }
                else{
                    System.out.println("User Authentication Sucessful");
                    userId=queryResponse.userid;
                    displayName=queryResponse.fullname;

                    attributes.put("queryParams", queryResponse.toString());                        
                    authFlag=false;
                    errorMsg = null;
                    return true;
                }
            }           
        }
        catch(Exception e){
            e.printStackTrace();
            authFlag =true;
            return false;
        }
        return false;

    }
}
公共类UserLoginResource扩展了UserAuthenticationSecurityCheck{
私有字符串userId、displayName、errorMsg、cdata、hdata、rid、urlParams、serviceName、queryParameters;
private boolean rememberMe=false;
私有布尔authFlag=true;
公共静态JSONObject查询响应;
私有映射属性=新HashMap();
@上下文
适配器安全上下文适配器安全上下文;
@凌驾
受保护的AuthenticatedUser createUser(){
System.out.println(“用户身份验证结果”+userId);
返回新的AuthenticatedUser(userId,displayName,this.getName(),attributes);
}
@凌驾
受保护的布尔validateCredentials(映射凭据){
试试{
字符串username=credentials.get(“username”).toString();
字符串密码=凭据。获取(“密码”).toString();
如果(用户名!=null和密码!=null){
queryResponse=(用户名、密码);
如果(queryResponse.errorExist){
System.out.println(“用户身份验证失败”);
errorMsg=“用户身份验证失败”;
返回false;
}
否则{
System.out.println(“用户身份验证成功”);
userId=queryResponse.userId;
displayName=queryResponse.fullname;
attributes.put(“queryParams”,queryResponse.toString());
authFlag=false;
errorMsg=null;
返回true;
}
}           
}
捕获(例外e){
e、 printStackTrace();
authFlag=true;
返回false;
}
返回false;
}
}

我建议您重新设计身份验证流程

SecurityCheck适配器的设计完全符合其名称的要求—安全检查。理想情况下,
validateCredentials
方法应该验证您的凭据(针对后端/LDAP/服务或其他方式),安全检查的响应应该是关于您可能需要的经过身份验证的身份和自定义属性的信息

注意,安全检查是有状态的,并保留其交互状态。对于每个授权或内省请求,安全框架从外部存储器检索相关安全检查的状态,并在请求处理结束时将安全检查状态存储回外部存储器。使用您所要求的方法,响应也会成为状态的一部分,并且会因序列化和反序列化而导致性能损失。这不适用于重载系统

参考

理想情况下,您应该将JSON请求和响应延迟到将请求它的资源适配器,然后使用安全检查进行身份验证

如果确实希望保留现有模型,则应将自定义JSON响应标记为“瞬态”(transient),以防止其序列化(并成为SecurityCheck状态的一部分),并将数据发送回已使用的AuthenticatedUser构造函数的自定义映射中:

AuthenticatedUser(字符串id、字符串显示名称、字符串 securityCheckName、映射属性)


我建议您重新设计身份验证流

SecurityCheck适配器的设计完全符合其名称的要求—安全检查。理想情况下,
validateCredentials
方法应该验证您的凭据(针对后端/LDAP/服务或其他方式),安全检查的响应应该是关于您可能需要的经过身份验证的身份和自定义属性的信息

注意,安全检查是有状态的,并保留其交互状态。对于每个授权或内省请求,安全框架从外部存储器检索相关安全检查的状态,并在请求处理结束时将安全检查状态存储回外部存储器。使用您所要求的方法,响应也会成为状态的一部分,并且会因序列化和反序列化而导致性能损失。这不适用于重载系统

参考

理想情况下,您应该将JSON请求和响应延迟到将请求它的资源适配器,然后使用安全检查进行身份验证

如果确实希望保留现有模型,则应将自定义JSON响应标记为“瞬态”(transient),以防止其序列化(并成为SecurityCheck状态的一部分),并将数据发送回已使用的AuthenticatedUser构造函数的自定义映射中:

AuthenticatedUser(字符串id、字符串显示名称、字符串 securityCheckName、映射属性)

return new AuthenticatedUser(userId, displayName, this.getName(), attributes);