31
31
import javax .inject .Inject ;
32
32
33
33
import org .apache .commons .httpclient .HttpClient ;
34
+ import org .apache .logging .log4j .LogManager ;
35
+ import org .apache .logging .log4j .Logger ;
34
36
import org .apache .velocity .app .VelocityEngine ;
37
+ import org .opensaml .saml2 .core .Attribute ;
35
38
import org .opensaml .saml2 .metadata .provider .HTTPMetadataProvider ;
36
39
import org .opensaml .saml2 .metadata .provider .MetadataProvider ;
37
40
import org .opensaml .saml2 .metadata .provider .MetadataProviderException ;
@@ -285,6 +288,8 @@ public SAMLFilterSet samlFilter() throws Exception {
285
288
return new SAMLFilterSet (chains );
286
289
}
287
290
291
+ private final Logger log = LogManager .getLogger (getClass ());
292
+
288
293
@ Bean
289
294
public SAMLAuthenticationProvider samlAuthenticationProvider () {
290
295
SAMLAuthenticationProvider samlAuthenticationProvider = new SAMLAuthenticationProvider ();
@@ -294,8 +299,19 @@ public Object loadUserBySAML(SAMLCredential credential) throws UsernameNotFoundE
294
299
String nameAttribute = environment .getProperty ("proxy.saml.name-attribute" , DEFAULT_NAME_ATTRIBUTE );
295
300
String nameValue = credential .getAttributeAsString (nameAttribute );
296
301
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 <>();
299
315
String rolesAttribute = environment .getProperty ("proxy.saml.roles-attribute" );
300
316
if (rolesAttribute != null && !rolesAttribute .trim ().isEmpty ()) {
301
317
String [] roles = credential .getAttributeAsStringArray (rolesAttribute );
0 commit comments