3131import javax .inject .Inject ;
3232
3333import org .apache .commons .httpclient .HttpClient ;
34+ import org .apache .logging .log4j .LogManager ;
35+ import org .apache .logging .log4j .Logger ;
3436import org .apache .velocity .app .VelocityEngine ;
37+ import org .opensaml .saml2 .core .Attribute ;
3538import org .opensaml .saml2 .metadata .provider .HTTPMetadataProvider ;
3639import org .opensaml .saml2 .metadata .provider .MetadataProvider ;
3740import org .opensaml .saml2 .metadata .provider .MetadataProviderException ;
@@ -285,6 +288,8 @@ public SAMLFilterSet samlFilter() throws Exception {
285288 return new SAMLFilterSet (chains );
286289 }
287290
291+ private final Logger log = LogManager .getLogger (getClass ());
292+
288293 @ Bean
289294 public SAMLAuthenticationProvider samlAuthenticationProvider () {
290295 SAMLAuthenticationProvider samlAuthenticationProvider = new SAMLAuthenticationProvider ();
@@ -294,8 +299,19 @@ public Object loadUserBySAML(SAMLCredential credential) throws UsernameNotFoundE
294299 String nameAttribute = environment .getProperty ("proxy.saml.name-attribute" , DEFAULT_NAME_ATTRIBUTE );
295300 String nameValue = credential .getAttributeAsString (nameAttribute );
296301 if (nameValue == null ) throw new UsernameNotFoundException ("Name attribute missing from SAML assertion: " + nameAttribute );
297-
298- List <GrantedAuthority > auth = new ArrayList <>();
302+
303+ List <Attribute > attributes = credential .getAttributes ();
304+
305+ attributes .forEach ((attribute ) -> {
306+ log .info (String .format ("[SAML] User: %s => found Attribute with name : %s (%s) and value %s - %s" ,
307+ nameValue ,
308+ attribute .getName (),
309+ attribute .getFriendlyName (),
310+ credential .getAttributeAsString (attribute .getName ()),
311+ String .join (", " , credential .getAttributeAsStringArray (attribute .getName ()))));
312+ });
313+
314+ List <GrantedAuthority > auth = new ArrayList <>();
299315 String rolesAttribute = environment .getProperty ("proxy.saml.roles-attribute" );
300316 if (rolesAttribute != null && !rolesAttribute .trim ().isEmpty ()) {
301317 String [] roles = credential .getAttributeAsStringArray (rolesAttribute );
0 commit comments