|
@@ -4,11 +4,11 @@ import java.io.IOException;
|
|
|
import java.util.Base64;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
-import com.ym.mec.auth.api.entity.BasicUser;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -18,6 +18,7 @@ import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.security.authentication.BadCredentialsException;
|
|
|
import org.springframework.security.core.Authentication;
|
|
|
+import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
|
|
|
import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
|
|
import org.springframework.security.oauth2.common.exceptions.UnapprovedClientAuthenticationException;
|
|
|
import org.springframework.security.oauth2.provider.ClientDetails;
|
|
@@ -107,13 +108,13 @@ public class BaseAuthenticationSuccessEventHandler extends SavedRequestAwareAuth
|
|
|
OAuth2Request oAuth2Request = tokenRequest.createOAuth2Request(clientDetails);
|
|
|
|
|
|
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(oAuth2Request, authentication);
|
|
|
- BasicUser oAuth2AccessToken = (BasicUser)defaultAuthorizationServerTokenServices.createAccessToken(oAuth2Authentication);
|
|
|
+ OAuth2AccessToken oAuth2AccessToken = defaultAuthorizationServerTokenServices.createAccessToken(oAuth2Authentication);
|
|
|
logger.info("获取token 成功:{}", oAuth2AccessToken.getValue());
|
|
|
- oAuth2AccessToken.setPassword(sysUser.getPassword());
|
|
|
-
|
|
|
+ Map<String,Object> map = new HashMap<>(3);
|
|
|
+ map.put("password",sysUser.getPassword());
|
|
|
+ map.put("authentication",oAuth2AccessToken);
|
|
|
response.setContentType("application/json; charset=utf-8");
|
|
|
-
|
|
|
- HttpResponseResult result = new HttpResponseResult(true, HttpStatus.OK.value(), oAuth2AccessToken, "");
|
|
|
+ HttpResponseResult result = new HttpResponseResult(true, HttpStatus.OK.value(), map, "");
|
|
|
response.getWriter().write(objectMapper.writeValueAsString(result));
|
|
|
} catch (IOException e) {
|
|
|
throw new BadCredentialsException("Failed to decode basic authentication token");
|