getRoleList(Object loginId, String loginType) {
+ UserInfo userInfo = userInfoCache.getUserInfo(loginId.toString());
+ return userInfo.getRoles();
+ }
+
+}
\ No newline at end of file
diff --git a/oauth2-server/src/main/java/cc/iotkit/oauth/service/TokenRequestHandler.java b/oauth2-server/src/main/java/cc/iotkit/oauth/service/TokenRequestHandler.java
new file mode 100755
index 00000000..3d747281
--- /dev/null
+++ b/oauth2-server/src/main/java/cc/iotkit/oauth/service/TokenRequestHandler.java
@@ -0,0 +1,62 @@
+package cc.iotkit.oauth.service;
+
+import cn.dev33.satoken.context.SaHolder;
+import cn.dev33.satoken.context.model.SaRequest;
+import cn.dev33.satoken.context.model.SaResponse;
+import cn.dev33.satoken.oauth2.SaOAuth2Manager;
+import cn.dev33.satoken.oauth2.config.SaOAuth2Config;
+import cn.dev33.satoken.oauth2.exception.SaOAuth2Exception;
+import cn.dev33.satoken.oauth2.logic.SaOAuth2Consts;
+import cn.dev33.satoken.oauth2.logic.SaOAuth2Handle;
+import cn.dev33.satoken.oauth2.model.SaClientModel;
+
+public class TokenRequestHandler {
+
+ public static Object serverRequest() {
+ SaRequest req = SaHolder.getRequest();
+ SaResponse res = SaHolder.getResponse();
+ SaOAuth2Config cfg = SaOAuth2Manager.getConfig();
+ SaClientModel cm;
+ if (req.isPath(SaOAuth2Consts.Api.authorize) && req.isParam(SaOAuth2Consts.Param.response_type, SaOAuth2Consts.ResponseType.code)) {
+ cm = SaOAuth2Handle.currClientModel();
+ if (!cfg.getIsCode() || !cm.isCode && !cm.isAutoMode) {
+ throw new SaOAuth2Exception("暂未开放的授权模式");
+ } else {
+ return SaOAuth2Handle.authorize(req, res, cfg);
+ }
+ } else if (req.isPath(SaOAuth2Consts.Api.token) && req.isParam(SaOAuth2Consts.Param.grant_type, SaOAuth2Consts.GrantType.authorization_code)) {
+ return SaOAuth2Handle.token(req, res, cfg);
+ } else if (req.isPath(SaOAuth2Consts.Api.token) && req.isParam(SaOAuth2Consts.Param.grant_type, SaOAuth2Consts.GrantType.refresh_token)) {
+ return SaOAuth2Handle.refreshToken(req);
+ } else if (req.isPath(SaOAuth2Consts.Api.revoke)) {
+ return SaOAuth2Handle.revokeToken(req);
+ } else if (req.isPath(SaOAuth2Consts.Api.doLogin)) {
+ return SaOAuth2Handle.doLogin(req, res, cfg);
+ } else if (req.isPath(SaOAuth2Consts.Api.doConfirm)) {
+ return SaOAuth2Handle.doConfirm(req);
+ } else if (req.isPath(SaOAuth2Consts.Api.authorize) && req.isParam(SaOAuth2Consts.Param.response_type, SaOAuth2Consts.ResponseType.token)) {
+ cm = SaOAuth2Handle.currClientModel();
+ if (!cfg.getIsImplicit() || !cm.isImplicit && !cm.isAutoMode) {
+ throw new SaOAuth2Exception("暂未开放的授权模式");
+ } else {
+ return SaOAuth2Handle.authorize(req, res, cfg);
+ }
+ } else if (req.isPath(SaOAuth2Consts.Api.token) && req.isParam(SaOAuth2Consts.Param.grant_type, SaOAuth2Consts.GrantType.password)) {
+ cm = SaOAuth2Handle.currClientModel();
+ if (!cfg.getIsPassword() || !cm.isPassword && !cm.isAutoMode) {
+ throw new SaOAuth2Exception("暂未开放的授权模式");
+ } else {
+ return SaOAuth2Handle.password(req, res, cfg);
+ }
+ } else if (req.isPath(SaOAuth2Consts.Api.token) && req.isParam(SaOAuth2Consts.Param.grant_type, SaOAuth2Consts.GrantType.client_credentials)) {
+ cm = SaOAuth2Handle.currClientModel();
+ if (!cfg.getIsClient() || !cm.isClient && !cm.isAutoMode) {
+ throw new SaOAuth2Exception("暂未开放的授权模式");
+ } else {
+ return SaOAuth2Handle.clientToken(req, res, cfg);
+ }
+ } else {
+ return "{\"msg\": \"not handle\"}";
+ }
+ }
+}
diff --git a/oauth2-server/src/main/java/cc/iotkit/utils/SoMap.java b/oauth2-server/src/main/java/cc/iotkit/utils/SoMap.java
new file mode 100755
index 00000000..06ed14bd
--- /dev/null
+++ b/oauth2-server/src/main/java/cc/iotkit/utils/SoMap.java
@@ -0,0 +1,737 @@
+package cc.iotkit.utils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * Map< String, Object> 是最常用的一种Map类型,但是它写着麻烦
+ * 所以特封装此类,继承Map,进行一些扩展,可以让Map更灵活使用
+ *
最新:2020-12-10 新增部分构造方法
+ * @author kong
+ */
+public class SoMap extends LinkedHashMap {
+
+ private static final long serialVersionUID = 1L;
+
+ public SoMap() {
+ }
+
+ /** 以下元素会在isNull函数中被判定为Null, */
+ public static final Object[] NULL_ELEMENT_ARRAY = {null, ""};
+ public static final List