♻️ 重载 AuthState 方法,适配 justauth-spring-boot-starter 直接使用
This commit is contained in:
@@ -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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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内容
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user