@ Override protected String extractPrincipalId ( final Credential credentials , final Optional < Principal > currentPrincipal ) { val wsFedCredentials = ( WsFederationCredential ) credentials ; val attributes = wsFedCredentials . getAttributes ( ) ; LOGGER . debug ( "Credential attributes provided are: [{}]" , attributes ) ; val idAttribute = this . configuration . getIdentityAttribute ( ) ; if ( attributes . containsKey ( idAttribute ) ) { LOGGER . debug ( "Extracting principal id from attribute [{}]" , this . configuration . getIdentityAttribute ( ) ) ; val idAttributeAsList = CollectionUtils . toCollection ( attributes . get ( this . configuration . getIdentityAttribute ( ) ) ) ; if ( idAttributeAsList . size ( ) > 1 ) { LOGGER . warn ( "Found multiple values for id attribute [{}]." , idAttribute ) ; } else { LOGGER . debug ( "Found principal id attribute as [{}]" , idAttributeAsList ) ; } val result = CollectionUtils . firstElement ( idAttributeAsList ) ; if ( result . isPresent ( ) ) { val principalId = result . get ( ) . toString ( ) ; LOGGER . debug ( "Principal Id extracted from credentials: [{}]" , principalId ) ; return principalId ; } } LOGGER . warn ( "Credential attributes do not include an attribute for [{}]. " + "This will prohibit CAS to construct a meaningful authenticated principal. " + "Examine the released claims and ensure [{}] is allowed" , idAttribute , idAttribute ) ; return null ; }
Extracts the principalId .