Chaitanya Kumar Ch
Chaitanya Kumar Ch

Reputation: 309

get user attributes in spring sp from ldap + shibboleth idp

I am able to integrate basic spring app https://github.com/UniconLabs/shibboleth-sample-java-sp with shibboleth idp and ldap. Login and logout functionalities are working fine. But I didn't find any documentation related to retrieving user attributes like first name, last name, common name etc in my sp(spring app)

Please help me out.

Upvotes: 1

Views: 484

Answers (1)

Chaitanya Kumar Ch
Chaitanya Kumar Ch

Reputation: 309

        Authentication authentication = SecurityContextHolder.getContext()
                .getAuthentication();
        SAMLCredential credential = (SAMLCredential) authentication
                .getCredentials();

        for(Attribute attribute: credential.getAttributes()){
            List<XMLObject> values= attribute.getAttributeValues();
            for(XMLObject value: values){
                System.out.println(value.getDOM().getTextContent());

            }
        }

Upvotes: 1

Related Questions