如何在SAML请求中将用户名密码作为属性传递,如下面的代码所示。我使用lastpass-saml-sdk.jar与GLUU IDP服务器通信。
SAMLInit.initialize();
String dir = Constants.METADATA_LOCATION;
if (dir == null)
throw new SAMLException("Unable to locate SAML metadata");
IdPConfig idpConfig = new IdPConfig(new File(dir + "\\gluu-idp-metadata.xml"));
SPConfig spConfig = new SPConfig(new File(dir + "\\sp-meta.xml"));
SAMLClient client= new SAMLClient(spConfig, idpConfig);
// when a login link is clicked, create auth request and
// redirect to the IdP
String requestId = SAMLUtils.generateRequestId();
String authrequest = client.generateAuthnRequest(requestId);
String url = client.getIdPConfig().getLoginUrl() +
"?SAMLRequest=" + URLEncoder.encode(authrequest, "UTF-8");
// redirect to url...
response.sendRedirect(url);
答案 0 :(得分:1)
您不会直接将用户名和密码传递给身份提供商。重定向用户后,用户自己将在IDP输入用户名和密码。
Here is one of my blog posts描述了SAML Web rowser配置文件中的流程。