Login to adfs through openam using java application

蓝咒 提交于 2019-12-24 03:19:55

问题


I have configured adfs as identity provider and openam as service provider but how to test whether login is working fine with adfs throght openam.

Can anyone help me to do login to adfs server through openam using java application.

Thanks,


回答1:


Refer OpenAM and ADFS2 configuration.

The article covers all your questions.

Update:

The way I normally do this is to use the OpenSSO / OpenAM Java Fedlet.

Refer Using Fedlets in Java Web Applications (Chapter 8).

The code (as per the fedlet) to display the contents of the token looks like:

Response samlResp = (Response) map.get(SAML2Constants.RESPONSE); 
Assertion assertion = (Assertion) map.get(SAML2Constants.ASSERTION);
Subject subject = (Subject) map.get(SAML2Constants.SUBJECT);
String entityID = (String) map.get(SAML2Constants.IDPENTITYID);
String spEntityID = (String) map.get(SAML2Constants.SPENTITYID);
NameID nameId = (NameID) map.get(SAML2Constants.NAMEID);
String value = nameId.getValue();
String format = nameId.getFormat();
out.println("<br><br><b>Single Sign-On successful with IDP " 
    + entityID + ".</b>");
out.println("<br><br>");
out.println("<table border=0>");
if (format != null) {
    out.println("<tr>");
    out.println("<td valign=top><b>Name ID format: </b></td>");
    out.println("<td>" + format + "</td>");
    out.println("</tr>");
}
if (value != null) {
    out.println("<tr>");
    out.println("<td valign=top><b>Name ID value: </b></td>");
    out.println("<td>" + value + "</td>");
    out.println("</tr>");
}    
String sessionIndex = (String) map.get(SAML2Constants.SESSION_INDEX);
if (sessionIndex != null) {
    out.println("<tr>");
    out.println("<td valign=top><b>SessionIndex: </b></td>");
    out.println("<td>" + sessionIndex + "</td>");
    out.println("</tr>");
}    

Map attrs = (Map) map.get(SAML2Constants.ATTRIBUTE_MAP);
if (attrs != null) {
    out.println("<tr>");
    out.println("<td valign=top><b>Attributes: </b></td>");
    Iterator iter = attrs.keySet().iterator();
    out.println("<td>");
    while (iter.hasNext()) {
        String attrName = (String) iter.next();
        Set attrVals = (HashSet) attrs.get(attrName);
        if ((attrVals != null) && !attrVals.isEmpty()) {
            Iterator it = attrVals.iterator();
            while (it.hasNext()) {
                out.println(attrName + "=" + it.next() + "<br>");
            }
        }
    }
    out.println("</td>");
    out.println("</tr>");
}
out.println("</table>");


来源:https://stackoverflow.com/questions/13025786/login-to-adfs-through-openam-using-java-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!