Merge pull request #29 from xkcoding/refactor-AuthState

♻️ 重载 AuthState 方法,适配 justauth-spring-boot-starter 直接使用
This commit is contained in:
yadong.zhang 2019-07-23 22:20:52 +08:00 committed by GitHub
commit 7f725b579b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,6 +51,17 @@ public class AuthState {
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
*
@ -62,6 +73,17 @@ public class AuthState {
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
*
@ -87,6 +109,16 @@ public class AuthState {
return state;
}
/**
* 获取state
*
* @param source oauth平台
* @return state
*/
public static String get(AuthSource source) {
return get(source.name());
}
/**
* 获取state
*
@ -101,6 +133,19 @@ public class AuthState {
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内容
*