package org.onetwo.boot.module.oauth2.result;

import lombok.extern.slf4j.Slf4j;

import org.springframework.http.ResponseEntity;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint;

/**
 * @author wayshall
 * <br/>
 */
@Slf4j
public class OAuth2CustomAuthenticationEntryPoint extends OAuth2AuthenticationEntryPoint {

	@Override
	protected ResponseEntity<OAuth2Exception> enhanceResponse(ResponseEntity<OAuth2Exception> response, Exception exception) {
		if(log.isInfoEnabled()){
			log.error("oauth2 error", exception);
		}
		return super.enhanceResponse(response, exception);
	}
}

@@ -75,16 +75,62 @@
 Slf4j;%0A%0A
+import org.onetwo.common.web.utils.WebHolder;%0A
 import o
@@ -209,48 +209,277 @@
 ity.
-oauth2.common.exceptions.OAuth2Exception
+core.Authentication;%0Aimport org.springframework.security.oauth2.common.exceptions.OAuth2Exception;%0Aimport org.springframework.security.oauth2.provider.authentication.BearerTokenExtractor;%0Aimport org.springframework.security.oauth2.provider.authentication.TokenExtractor
 ;%0Aim
@@ -567,16 +567,17 @@
 Point;%0A%0A
+%0A
 /**%0A * @
@@ -704,16 +704,87 @@
 oint %7B%0A%0A
+%09private TokenExtractor tokenExtractor = new BearerTokenExtractor();%0A%09%0A
 %09@Overri
@@ -925,12 +925,13 @@
 g.is
-Info
+Error
 Enab
@@ -938,16 +938,211 @@
 led())%7B%0A
+%09%09%09WebHolder.getRequest().ifPresent(request-%3E%7B%0A%09%09%09%09Authentication auth = tokenExtractor.extract(request);%0A%09%09%09%09log.error(%22token:%7B%7D, auth: %7B%7D%22, auth==null?%22null%22:auth.getPrincipal(), auth);%0A%09%09%09%7D);%0A
 %09%09%09log.e

fix config