protected String getOrigin ( Principal principal ) { if ( principal instanceof Authentication ) { Authentication caller = ( Authentication ) principal ; StringBuilder builder = new StringBuilder ( ) ; if ( caller instanceof OAuth2Authentication ) { OAuth2Authentication oAuth2Authentication = ( OAuth2Authentication ) caller ; builder . append ( "client=" ) . append ( oAuth2Authentication . getOAuth2Request ( ) . getClientId ( ) ) ; if ( ! oAuth2Authentication . isClientOnly ( ) ) { builder . append ( ", " ) . append ( "user=" ) . append ( oAuth2Authentication . getName ( ) ) ; } } else { builder . append ( "caller=" ) . append ( caller . getName ( ) ) ; } if ( caller . getDetails ( ) != null ) { builder . append ( ", details=(" ) ; try { @ SuppressWarnings ( "unchecked" ) Map < String , Object > map = JsonUtils . readValue ( ( String ) caller . getDetails ( ) , new TypeReference < Map < String , Object > > ( ) { } ) ; if ( map . containsKey ( "remoteAddress" ) ) { builder . append ( "remoteAddress=" ) . append ( map . get ( "remoteAddress" ) ) . append ( ", " ) ; } builder . append ( "type=" ) . append ( caller . getDetails ( ) . getClass ( ) . getSimpleName ( ) ) ; } catch ( Exception e ) { // ignore builder . append ( caller . getDetails ( ) ) ; } appendTokenDetails ( caller , builder ) ; builder . append ( ")" ) ; } return builder . toString ( ) ; } return principal == null ? null : principal . getName ( ) ; }
due to some OAuth authentication scenarios which don t set it .