提交 094c2979 编写于 作者: 智布道's avatar 智布道 👁
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>${lombok-version}</version> <version>${lombok-version}</version>
<optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
......
...@@ -51,6 +51,17 @@ public class AuthState { ...@@ -51,6 +51,17 @@ public class AuthState {
return create(source, RandomUtil.randomString(4)); return create(source, RandomUtil.randomString(4));
} }
/**
* 创建state
*
* @param source oauth平台
* @param body 希望加密到state的消息体
* @return state
*/
public static String create(AuthSource source, Object body) {
return create(source, JSON.toJSONString(body));
}
/** /**
* 创建state * 创建state
* *
...@@ -62,6 +73,17 @@ public class AuthState { ...@@ -62,6 +73,17 @@ public class AuthState {
return create(source, JSON.toJSONString(body)); return create(source, JSON.toJSONString(body));
} }
/**
* 创建state
*
* @param source oauth平台
* @param body 希望加密到state的消息体
* @return state
*/
public static String create(AuthSource source, String body) {
return create(source.name(), body);
}
/** /**
* 创建state * 创建state
* *
...@@ -87,6 +109,16 @@ public class AuthState { ...@@ -87,6 +109,16 @@ public class AuthState {
return state; return state;
} }
/**
* 获取state
*
* @param source oauth平台
* @return state
*/
public static String get(AuthSource source) {
return get(source.name());
}
/** /**
* 获取state * 获取state
* *
...@@ -101,6 +133,19 @@ public class AuthState { ...@@ -101,6 +133,19 @@ public class AuthState {
return stateBucket.get(key); return stateBucket.get(key);
} }
/**
* 获取state中保存的body内容
*
* @param source oauth平台
* @param state 加密后的state
* @param clazz body的实际类型
* @param <T> 需要转换的具体的class类型
* @return state
*/
public static <T> T getBody(AuthSource source, String state, Class<T> clazz) {
return getBody(source.name(), state, clazz);
}
/** /**
* 获取state中保存的body内容 * 获取state中保存的body内容
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册