【发布时间】:2015-11-03 01:16:06
【问题描述】:
我们公司正在使用 Oracle 访问系统进行 SAML 单点登录。我使用 Spring Security SAML 库实现了 Spring Security,它运行良好,直到我最近才发现一个问题。 Oracle Access System 使用 OBSSOCookie 作为标识符,但是当 saml 响应回发时,我无法检索此 cookie。 看看这段代码:
@RequestMapping(value = "/callback")
public void callback(HttpServletRequest request, HttpServletResponse response)
throws IOException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
SAMLCredential credential = (SAMLCredential) authentication.getCredentials();
try {
XMLHelper.nodeToString(SAMLUtil.marshallMessage(credential.getAuthenticationAssertion()));
} catch (MessageEncodingException e) {
e.printStackTrace();
}
String nameID = credential.getNameID().getValue();
List<Attribute> attributes = credential.getAttributes();
JSONObject jso = new JSONObject();
String uid;
String employeeType="";
String company_name="";
String FirstName;
String roles_entitled="";
String LastName;
String primary_role="";
jso.put("nameID", nameID);
jso.put("uid", uid);
jso.put("company_name", company_name);
jso.put("roles_entitled", roles_entitled);
jso.put("primary_role", primary_role);
jso.put("employeeType", employeeType);
jso.put("FirstName", FirstName);
jso.put("LastName", LastName);
String frontend_url = sideCarService.getFrontendNodeUrl();
String token = KeyGenerator.createUserToken(jso, 3600 * 24 * 30);
String encoded = new String(Base64.encodeBase64(jso.toString().getBytes()));
response.sendRedirect(frontend_url + "#t/" + token + "/atts/" + encoded);
}
查看这段代码,我可以从 saml 响应中检索所有信息,然后生成一个令牌,返回给前端 cookie 以供使用。
但我真的很想获得 OBSSOCookie,这样我就可以与其他微服务一起使用,从使用相同 saml 登录解决方案的其他应用程序中检索数据。
我尝试使用 request.getHeaders(),但响应为空。根本没有 OBSSOCookie。
知道如何从 spring saml 库中获取 OBSSOCookie 吗?
谢谢
【问题讨论】:
-
您将需要使用 OAM SDK 来执行此操作...
标签: spring spring-security saml-2.0 spring-saml