0

当我按照 WSO2 SCIM 2.0 REST 端点(https://docs.wso2.com/display/IS560/apidocs/SCIM2-endpoints/index.html#!/operations#UsersEndpoint#getUser)通过用户列表获取多个用户时名称,wso2 身份服务器(版本:5.7.0)返回“或不受支持”。过滤器字符串如下所示:filter=(userName eq "user01") 或 (userName eq "user02")

@Override
public List<UserInfo> getUsersByNames(List<String> userNames) {
    if(userNames==null||userNames.isEmpty()) return null;

    List<UserInfo> users=null;
    StringBuffer queryStr=new StringBuffer();
    for(String userName:userNames) {
        userName=userName.trim();
        if(userName.contains(" ")) throw new IllegalArgumentException("invalid user name in getUsersByNames:("+userName+")");
        if(queryStr.length()==0) {
            queryStr.append("(userName eq \"").append(userName).append("\")");
        }
        else {
            queryStr.append(" or (userName eq \"").append(userName).append("\")");
        }
    }
    users=getUserRequest(queryStr.toString(),0,100);

    return users;
}
private List<UserInfo> getUserRequest(String filter, int startIndex, int maxCount) {
    UserInfo userInfo=null;
    try {
        SCIMClientTool client=new SCIMClientTool();
        //use Scimv2UsersApi to get user with filter
        ScimApiResponse<String> result=client.getSCIMUserApi(null).getUser(null, null, filter, startIndex, maxCount, null, null);
        if(result==null||result.getStatusCode()==404) {
            throw new ObjectNotFoundException("cannot get user by filter:"+filter);
        }
        if(result.getData()==null||result.getData().length()==0) return null;

        //convert the json string to UserInfo object
        System.out.println("raw json result from getSCIMUserApi.getUser:"+result.getData());
        List<UserInfo> userInfos=SCIMUserConverter.convertMultiple(result.getData());
        return userInfos;
    } catch (ScimApiException e) {
        logger.error("fail to get user from SCIM REST Endpoint", e);
        throw new ApiException("fail to get user from SCIM REST Endpoint",e);
    }
}
4

1 回答 1

1

目前支持的逻辑运算符是“and”运算符,此外还支持“Eq”、“Ew”、“Co”、“Sw”过滤器。您可以参考此文档了解更多信息。

于 2019-03-25T15:13:35.003 回答