Home > Back-end >  AnonymousAuthenticationToken always be cast to OAuth2Authentication
AnonymousAuthenticationToken always be cast to OAuth2Authentication

Time:10-06

The Authentication auth=SecurityContextHolder. GetContext (). GetAuthentication ();
OAuth2Authentication authentication=(OAuth2Authentication auth);
System. The out. Println (" 1234 "+ authentication. GetDetails ());
OAuth2AuthenticationDetails oauthDetails=(OAuth2AuthenticationDetails) authentication. GetDetails ();
Map The map=(Map) OauthDetails. GetDecodedDetails ();
Return (Map) The map. The get (" userExtraMessage ");

Detailed error message:
Under Caused by: Java. Lang. ClassCastException: org. Springframework. Security. Authentication. AnonymousAuthenticationToken always be cast to org. Springframework. Security. Oauth2. Provider. OAuth2Authentication
At com. Eastsoft. Substation. Gateway. Util. TokenExtraInfo. GetUserExtraMessage (TokenExtraInfo. Java: 34) ~ (classes/: na)
At com. Eastsoft. Substation. Gateway. Config. LicenseZuulFilter. Run (LicenseZuulFilter. Java: 54) ~ (classes/: na)
At com.net flix. Zuul. ZuulFilter. RunFilter (ZuulFilter. Java: 117) ~ [zuul - core - 1.3.1. The jar: 1.3.1]
At com.net flix. Zuul. FilterProcessor. ProcessZuulFilter (FilterProcessor. Java: 193) ~ [zuul - core - 1.3.1. The jar: 1.3.1]
. 108 common frames omitted

Watch should be under the type conversion error, excuse me, why SecurityContextHolder. GetContext () getAuthentication AnonymousAuthenticationToken is () to get out of? How can I get the OAuth2Authentication?

CodePudding user response:

Error message is positioned to red statement submitted to the fault

CodePudding user response:

What's the relationship between OAuth2Authentication and Authentication.

CodePudding user response:

OAuth2Authentication is want to by Authentication. GetDetails (), and then turn strong, is the red that sentence

CodePudding user response:

refer to the second floor response: friendship dream
OAuth2Authentication and Authentication is what relation?

OAuth2Authentication is want to by Authentication. GetDetails (), and then turn strong, is the red that sentence
  • Related