类 BaseAuthHandler<U extends BaseUser>
java.lang.Object
cool.scx.ext.auth.BaseAuthHandler<U>
Abstract BaseAuthHandler class.
- 版本:
- 1.15.4
- 作者:
- scx567888
-
字段概要
字段修饰符和类型字段说明static final String获取 设备 的标识字段static final String获取 token 的标识字段static final PathSESSION_CACHE 存储路径 默认为 AppRoot 下的 scx-session.cache 文件protected final SessionStore存储所有的登录的客户端protected final Map<String,ThirdPartyLoginHandler<?>> 第三方登录 login handler 映射protected final cool.scx.core.base.BaseModelService<U>用户 -
构造器概要
构造器限定符构造器说明protectedBaseAuthHandler(cool.scx.core.base.BaseModelService<U> userService) Constructor for BaseAuthHandler. -
方法概要
修饰符和类型方法说明final voidaddThirdPartyLoginHandler(String type, ThirdPartyLoginHandler<?> thirdPartyLoginHandler) 添加一个 第三方的 loginHandlervoidbindWebSocketByToken(WSMessage<?> wsParam) 根据 token 绑定 websocketchangePasswordByAdmin(String newPassword, Long id) 通过管理员修改用户密码 (不需要原密码)changePasswordBySelf(String newPassword, String oldPassword) 修改当前登录用户的 密码changeUsernameBySelf(String newUsername, String password) 修改当前登录用户的 用户名根据 id 获取 用户 和 get 的区别是返回值永远不为空且只包含 [id, password, username] 三个字段 如果对应 id 的用户未找到则抛出移除checkNewUsername(String username) 检查新用户名 (验空和是否重复)checkNewUsername(String username, Long id) 检查新用户名 (验空和是否重复)final ThirdPartyLoginHandler<U>根据名称查找第三方的 loginHandleraagetCurrentUser(io.vertx.ext.web.RoutingContext ctx) agetCurrentUserByToken(String token) agetCurrentUserByWebSocket(io.vertx.core.http.ServerWebSocket socket) getLoginUserByWebSocketID.final PermsgetPerms()aabstract Perms根据用户获取 权限串abstract boolean查看当前登录用户是否有对应的权限 此处查看的一般为通用权限final SessionStorealreadyLoginClientMap.aloginByThirdParty(String uniqueID, String accessToken, String accountType, io.vertx.ext.web.RoutingContext ctx) abooleanlogout(io.vertx.ext.web.RoutingContext context) avoid从文件中读取 LoginItemabstract Uaabstract UsignupByThirdParty(String uniqueID, String accessToken, String accountType) a尝试使用 用户名和密码进行登录void写入 LoginItem 到文件中
-
字段详细资料
-
构造器详细资料
-
BaseAuthHandler
Constructor for BaseAuthHandler.
- 参数:
userService- a
-
-
方法详细资料
-
getCurrentUser
a- 返回:
- a
-
getCurrentUser
a- 参数:
ctx- a- 返回:
- a
-
getCurrentUserByToken
a- 参数:
token- a- 返回:
- a
-
login
public Session login(String username, String password, io.vertx.ext.web.RoutingContext ctx) throws UnknownUserException, WrongPasswordException a- 参数:
username- apassword- actx- a- 返回:
- a
- 抛出:
UnknownUserExceptionWrongPasswordException
-
tryLogin
public U tryLogin(String username, String password) throws UnknownUserException, WrongPasswordException 尝试使用 用户名和密码进行登录- 参数:
username- 用户名password- 密码- 返回:
- a
- 抛出:
UnknownUserException- if any.WrongPasswordException- if any.
-
signup
a- 参数:
username- apassword- a- 返回:
- a
-
logout
public boolean logout(io.vertx.ext.web.RoutingContext context) a- 参数:
context- a- 返回:
- a
-
changePasswordByAdmin
通过管理员修改用户密码 (不需要原密码)- 参数:
newPassword- 新密码id- id- 返回:
- user
-
changePasswordBySelf
public U changePasswordBySelf(String newPassword, String oldPassword) throws WrongPasswordException, UnknownUserException 修改当前登录用户的 密码- 参数:
newPassword- 新密码oldPassword- 用来校验的密码- 返回:
- a
- 抛出:
WrongPasswordExceptionUnknownUserException
-
changeUsernameBySelf
public U changeUsernameBySelf(String newUsername, String password) throws cool.scx.mvc.exception.UnauthorizedException, WrongPasswordException 修改当前登录用户的 用户名- 参数:
newUsername- 新用户名password- 用来校验的密码- 返回:
- a
- 抛出:
cool.scx.mvc.exception.UnauthorizedExceptionWrongPasswordException
-
checkNeedChangeUserByID
根据 id 获取 用户 和 get 的区别是返回值永远不为空且只包含 [id, password, username] 三个字段 如果对应 id 的用户未找到则抛出移除- 参数:
id- id- 返回:
- r
-
getPerms
a- 返回:
- a
-
getPerms
根据用户获取 权限串- 参数:
user- 用户 (这里只会使用用户的唯一标识 所以其他的字段可以为空)- 返回:
- 权限字符串集合
-
signupByThirdParty
a- 参数:
uniqueID- aaccessToken- aaccountType- a- 返回:
- a
-
loginByThirdParty
public Session loginByThirdParty(String uniqueID, String accessToken, String accountType, io.vertx.ext.web.RoutingContext ctx) a- 参数:
uniqueID- aaccessToken- aaccountType- actx- a- 返回:
- a
-
findThirdPartyLoginHandler
根据名称查找第三方的 loginHandler- 参数:
type- 类型- 返回:
- handler
-
loggedInClientTable
alreadyLoginClientMap.
- 返回:
- a
-
addThirdPartyLoginHandler
public final void addThirdPartyLoginHandler(String type, ThirdPartyLoginHandler<?> thirdPartyLoginHandler) 添加一个 第三方的 loginHandler- 参数:
type- 名称thirdPartyLoginHandler- handler
-
hasPerm
查看当前登录用户是否有对应的权限 此处查看的一般为通用权限- 参数:
permString- 权限串- 返回:
- 是否拥有这个权限
-
bindWebSocketByToken
根据 token 绑定 websocket- 参数:
wsParam- aObjectobject
-
getCurrentSession
a- 返回:
- a
-
getCurrentUserByWebSocket
getLoginUserByWebSocketID.
- 参数:
socket- aServerWebSocketobject- 返回:
- a T object
-
readSessionFromFile
public void readSessionFromFile()从文件中读取 LoginItem -
writeSessionToFile
public void writeSessionToFile()写入 LoginItem 到文件中 -
checkNewUsername
检查新用户名 (验空和是否重复)- 参数:
username- usernameid- 用户名 (用来校验用户名是否唯一)- 返回:
- 去除首位空格后的 密码
-
checkNewUsername
检查新用户名 (验空和是否重复)- 参数:
username- username- 返回:
- 去除首位空格后的 密码
-