private OAuth2Authentication createRefreshedAuthentication ( OAuth2Authentication authentication , TokenRequest request ) { OAuth2Authentication narrowed = authentication ; Set < String > scope = request . getScope ( ) ; OAuth2Request clientAuth = authentication . getOAuth2Request ( ) . refresh ( request ) ; if ( scope != null && ! scope . isEmpty ( ) ) { Set < String > originalScope = clientAuth . getScope ( ) ; if ( originalScope == null || ! originalScope . containsAll ( scope ) ) { throw new InvalidScopeException ( "Unable to narrow the scope of the client authentication to " + scope + "." , originalScope ) ; } else { clientAuth = clientAuth . narrowScope ( scope ) ; } } narrowed = new OAuth2Authentication ( clientAuth , authentication . getUserAuthentication ( ) ) ; return narrowed ; }
Create a refreshed authentication .