gpt4 book ai didi

java - ACS 请求 URL :using onelogin toolkit 中的 SAMLResponse 为空

转载 作者:行者123 更新时间:2023-12-02 03:16:50 31 4
gpt4 key购买 nike

我正在使用Onelogin 2.0 toolkit 。我没有将登录和 ACS 作为 jsp 文件添加,而是将它们添加为休息服务。当我的 IdP 重定向到 ACS 服务 URL 时,我收到此错误。

SAML Response not found, Only supported HTTP_POST Binding

在对 ACS 服务的请求中,SAMLResponse 参数为空。我该如何解决这个问题?

@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;
}

}

最佳答案

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

如果您没有该 HttpServletRequest 对象,您可以使用 makeHttpRequest 来构建它

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

关于java - ACS 请求 URL :using onelogin toolkit 中的 SAMLResponse 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40175122/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com