Java ACS请求url中的SAMLResponse null:使用onelogin工具包

Java ACS请求url中的SAMLResponse null:使用onelogin工具包,java,web-services,saml-2.0,onelogin,Java,Web Services,Saml 2.0,Onelogin,我正在使用。我没有将Login和ACS作为jsp文件,而是将它们添加为rest服务。我的IdP重定向到ACS服务Url时出现此错误 未找到SAML响应,仅支持HTTP\U POST绑定 在对ACS服务的请求中,SAMLResponse参数为null。我怎样才能解决这个问题 @Path("/saml") public class SAMLAuthService { @Context HttpServletRequest request; @Context Http

我正在使用。我没有将Login和ACS作为jsp文件,而是将它们添加为rest服务。我的IdP重定向到ACS服务Url时出现此错误

未找到SAML响应,仅支持HTTP\U POST绑定

在对ACS服务的请求中,SAMLResponse参数为null。我怎样才能解决这个问题

@Path("/saml")
public class SAMLAuthService {
    @Context
    HttpServletRequest request;

    @Context
    HttpServletResponse response;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/dologin")
    public void SAMLLogin(){
        try {
            Auth auth = new Auth(CommonUtils.samlPropertyFileName,request, response);
            System.out.println("Calling SAML Login::");
            auth.login();
        } catch (Exception e) {
            e.printStackTrace();

        }
    }

    @POST
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/acs")
    public Response SAMLACS()
            throws ExecException {
        Response samlResponse = null;
        try {
            System.out.println("Calling SAML ACS::");
            Auth auth = new Auth(CommonUtils.samlPropertyFileName,request, response);
            auth.processResponse();
            if (!auth.isAuthenticated()) {
                System.out.println("Not Authenticated");
            }

            List<String> errors = auth.getErrors();
            if (!errors.isEmpty()) {
                if (auth.isDebugActive()) {
                    String errorReason = auth.getLastErrorReason();
                    if (errorReason != null && !errorReason.isEmpty()) {
                        System.out.println(errorReason);
                    }
                }
            } else {
                Map<String, List<String>> attributes = auth.getAttributes();
                String nameId = auth.getNameId();
                System.out.println("NameId::"+nameId);
                if (attributes.isEmpty()) {
                    System.out.println("No Attributes");
                }
                else {
                    Collection<String> keys = attributes.keySet();
                    for(String name :keys){
                        List<String> values = attributes.get(name);
                        System.out.println(name+"::");
                        for(String value :values) {
                            System.out.print(value);
                        }

                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return samlResponse;
    }

}
@Path(“/saml”)
公共类SAMLAuthService{
@上下文
HttpServletRequest请求;
@上下文
HttpServletResponse;
@得到
@产生(MediaType.APPLICATION_JSON)
@路径(“/dologin”)
公共无效SAMLLogin(){
试一试{
Auth Auth=new Auth(CommonUtils.samlPropertyFileName、请求、响应);
System.out.println(“调用SAML登录::”;
auth.login();
}捕获(例外e){
e、 printStackTrace();
}
}
@职位
@产生(MediaType.APPLICATION_JSON)
@路径(“/acs”)
公众回应
抛出异常{
响应samlResponse=null;
试一试{
System.out.println(“调用SAML ACS:”;
Auth Auth=new Auth(CommonUtils.samlPropertyFileName、请求、响应);
auth.processResponse();
如果(!auth.isAuthenticated()){
System.out.println(“未认证”);
}
List errors=auth.getErrors();
如果(!errors.isEmpty()){
if(auth.isdebugative()){
字符串errorReason=auth.getLastErrorReason();
if(errorReason!=null&&!errorReason.isEmpty()){
系统输出打印项次(错误原因);
}
}
}否则{
Map attributes=auth.getAttributes();
字符串nameId=auth.getNameId();
System.out.println(“NameId::”+NameId);
if(attributes.isEmpty()){
System.out.println(“无属性”);
}
否则{
集合键=attributes.keySet();
用于(字符串名称:键){
列表值=attributes.get(name);
System.out.println(name+“:”);
for(字符串值:值){
系统输出打印(值);
}
}
}
}
}捕获(例外e){
e、 printStackTrace();
}
返回相同的响应;
}
}
您正在使用的构造函数需要一个带有SAMLResponse POST参数的HttpServletRequest对象

如果没有HttpServletRequest对象,可以使用

您可以使用分析IdP和SP之间的SAML流。您可以确保IdP正在发送SAML响应。我不熟悉您正在使用的“Rest方法”,但您可能会看到获取SAMLResponse并构建HttpServletRequest对象的方法,该对象将注入该参数。

您正在使用的构造函数需要一个带有SAMLResponse POST参数的HttpServletRequest对象

如果没有HttpServletRequest对象,可以使用


您可以使用分析IdP和SP之间的SAML流。您可以确保IdP正在发送SAML响应。我不熟悉您正在使用的“Rest方法”,但您可能会看到获得SAMLResponse并构建HttpServletRequest对象的方法,该对象注入了该参数。

SAML Tracer说204没有内容错误。我检查了jsp请求和rest请求的请求头。执行SAML流时,头大小和url本身不同。。您看到java saml发送给IdP的AuthNRequest了吗?为什么您需要遵循“Rest方法”,而不是克隆所提供的示例上的工作内容?我不熟悉jsp:|。AuthNRequest已成功发送。无论如何,现在我用jsp本身来做。SAML Tracer说204没有内容错误。我检查了jsp请求和rest请求的请求头。执行SAML流时,头大小和url本身不同。。您看到java saml发送给IdP的AuthNRequest了吗?为什么您需要遵循“Rest方法”,而不是克隆所提供的示例上的工作内容?我不熟悉jsp:|。AuthNRequest已成功发送。无论如何,现在我用jsp本身来做。