Accesss request attribute in ScriptedAttribute definition

ofaklintrafo ofa at klintra.fo
Mon Jun 10 16:26:03 EDT 2019


Hmmm... seems that nabble has removed my code examples. I will try again

-----

This is what I did to get it to work. After successful external 
authentication and before calling finishExternalAuthentication I prepare the 
following subject attribute: 


	IdPAttribute attr = new IdPAttribute("specialattr");
	attr.setValues(Collections.singletonList(new
StringAttributeValue(attrValue)));
	IdPAttributePrincipal attrPrinc = new IdPAttributePrincipal(attr);
	UsernamePrincipal up = new UsernamePrincipal(username);
	
	Subject sub = new Subject();
	sub.getPrincipals().add(attrPrinc);
	sub.getPrincipals().add(up);
	request.setAttribute(ExternalAuthentication.SUBJECT_KEY, sub);

        ExternalAuthentication.finishExternalAuthentication(key, request,
response); 

To resolve the value of "specialattr" as an attribute I have added the 
following attribute definition to the attribute-resolver.xml file 

    <AttributeDefinition xsi:type="SubjectDerivedAttribute" id="specialattr"
principalAttributeName="specialattr">
        <AttributeEncoder xsi:type="SAML2String" name="urn:....."
friendlyName="specialattr" encodeType="false" />
    </AttributeDefinition>

Any comments are welcome. 




--
Sent from: http://shibboleth.1660669.n2.nabble.com/Shibboleth-Users-f1660767.html


More information about the users mailing list