|  | @@ -0,0 +1,28 @@
 | 
											
												
													
														|  | 
 |  | +package com.yonge.cooleshow.website.config;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +import org.springframework.security.authentication.AnonymousAuthenticationToken;
 | 
											
												
													
														|  | 
 |  | +import org.springframework.security.core.Authentication;
 | 
											
												
													
														|  | 
 |  | +import org.springframework.security.core.AuthenticationException;
 | 
											
												
													
														|  | 
 |  | +import org.springframework.security.core.authority.AuthorityUtils;
 | 
											
												
													
														|  | 
 |  | +import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
 | 
											
												
													
														|  | 
 |  | +import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationManager;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +import java.util.UUID;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +/**
 | 
											
												
													
														|  | 
 |  | + * Description
 | 
											
												
													
														|  | 
 |  | + *
 | 
											
												
													
														|  | 
 |  | + * @author liujunchi
 | 
											
												
													
														|  | 
 |  | + * @date 2022-06-30
 | 
											
												
													
														|  | 
 |  | + */
 | 
											
												
													
														|  | 
 |  | +public class MyOAuth2AuthenticationManager extends OAuth2AuthenticationManager {
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @Override
 | 
											
												
													
														|  | 
 |  | +    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
 | 
											
												
													
														|  | 
 |  | +        try {
 | 
											
												
													
														|  | 
 |  | +            return super.authenticate(authentication);
 | 
											
												
													
														|  | 
 |  | +        } catch (AuthenticationException | InvalidTokenException e) {
 | 
											
												
													
														|  | 
 |  | +            return new AnonymousAuthenticationToken(UUID.randomUUID().toString(), "anonymousUser", AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +}
 |