use of edu.uiuc.ncsa.myproxy.oa4mp.oauth2.servlet.ClaimsProcessor in project OA4MP by ncsa.
the class FunctorTests method testCIL2.
@Test
public void testCIL2() throws Exception {
HashMap<String, Object> claims2 = new HashMap<>();
claims2.put("sub", "http://cilogon.org/serverT/users/173048");
claims2.put("idp_name", "National Center for Supercomputing Applications");
claims2.put("idp", "https://idp.ncsa.illinois.edu/idp/shibboleth");
claims2.put("mail", "gaynor@illinois.edu");
claims2.put("affiliation", "staff@ncsa.illinois.edu;employee@ncsa.illinois.edu;member@ncsa.illinois.edu");
claims2.put("eppn", "jgaynor@ncsa.illinois.edu");
claims2.put("cert_subject_dn", "/DC=org/DC=cilogon/C=US/O=National Center for Supercomputing Applications/CN=Jeffrey Gaynor T173053 email=gaynor@illinois.edu");
claims2.put("name", "Jeffrey Gaynor");
claims2.put("isMemberOf", "[\"cn=jira-users,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=org_all_groups,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=all_ncsa_employe,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=grp_jira_users,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=all_users,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=grp_bldg_ncsa,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=grp_bldg_both,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=org_cisr,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=org_ici,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=org_csd,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=prj_cerb_users,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=iam_sec_testing,ou=Groups,dc=ncsa,dc=illinois,dc=edu\",\"cn=all_building,ou=Groups,dc=ncsa,dc=illinois,dc=edu\"]");
claims2.put("given_name", "Jeffrey");
claims2.put("family_name", "Gaynor");
claims2.put("email", "gaynor@illinois.edu}");
String rawConfig = "{\"config\":\"testforurgeclient\",\"id_token\":{\"$if\":{\"$match\":[\"${idp}\",\"https://idp.ncsa.illinois.edu/idp/shibboleth\"]},\"$then\":{\"$set\":[\"sub\",\"${eppn}\"]}}}";
OA2Client client = new OA2Client(BasicIdentifier.newID("test:client:42"));
client.setConfig(JSONObject.fromObject(rawConfig));
ClaimsProcessor ch = new ClaimsProcessor(client.getClaimsConfig());
DebugUtil.setIsEnabled(true);
Map<String, Object> claims3 = ch.process(claims2);
System.out.println("\n*** CIL2 claims handler test");
System.out.println(claims3);
System.out.println("\n*** done. Returned claims:");
assert claims3.get("sub").equals(claims2.get("eppn"));
}
Aggregations