Class HttpServletAuthService

java.lang.Object
tech.riemann.etp.auth.service.HttpServletAuthService
All Implemented Interfaces:
AuthService
Direct Known Subclasses:
DefaultAuthService

public abstract class HttpServletAuthService extends Object implements AuthService
Author:
Kerbores(kerbores@riemann.tech)
  • Field Details

  • Constructor Details

    • HttpServletAuthService

      public HttpServletAuthService()
  • Method Details

    • getRequest

      public abstract jakarta.servlet.http.HttpServletRequest getRequest()
    • getResponse

      public abstract jakarta.servlet.http.HttpServletResponse getResponse()
    • userDetailService

      public abstract UserDetailService userDetailService()
    • jwtEncoder

      public abstract JWTEncoder jwtEncoder()
    • jwtDecoder

      public abstract JWTDecoder jwtDecoder()
    • cookieSettings

      public CookieSettings cookieSettings()
      cookie 设置
      Returns:
    • subject

      public String subject(String token)
      Description copied from interface: AuthService
      根据token获取subject信息
      Specified by:
      subject in interface AuthService
      Parameters:
      token -
      Returns:
    • token

      public String token(String subject)
      Description copied from interface: AuthService
      生成token
      Specified by:
      token in interface AuthService
      Parameters:
      subject -
      Returns:
    • refreshToken

      public String refreshToken(String subject)
      Description copied from interface: AuthService
      生成refreshToken
      Specified by:
      refreshToken in interface AuthService
      Parameters:
      subject -
      Returns:
    • login

      public AuthUser login(AuthUser user)
      用户登录
      Specified by:
      login in interface AuthService
      Parameters:
      user -
    • logout

      public void logout()
      登出
      Specified by:
      logout in interface AuthService
    • user

      public AuthUser user()
      获取当前登录用户
      Specified by:
      user in interface AuthService
      Returns:
    • userName

      public String userName()
      Description copied from interface: AuthService
      获取用户名
      Specified by:
      userName in interface AuthService
      Returns:
    • tryRefreshToken

      public AuthUser tryRefreshToken(String refreshToken)
      Parameters:
      refreshToken -
      Returns:
    • addCookie

      public void addCookie(String name, String value, int age)
      添加cookie
      Parameters:
      name - 名称
      value - 值
      age - 有效期(分钟)
    • authentication

      public boolean authentication(List<String> withoutAuthenticationUrlRegulars)
      认证检查
      Specified by:
      authentication in interface AuthService
      Parameters:
      withoutAuthenticationUrlRegulars - 不需要检查的url正则表达式
      Returns:
      认证检查通过状态
    • pass

      public boolean pass(String uri, List<String> withoutAuthenticationUrlRegulars)
      Parameters:
      uri - 请求地址
      withoutAuthenticationUrlRegulars - 放行url正则
      Returns:
      是否放行
    • skip

      public boolean skip()
      是否跳过检查
      Returns:
    • authorizationHeaderKey

      public String authorizationHeaderKey()
      认证头key
      Returns:
    • tokenKey

      public String tokenKey()
      token key ,可以接受从header/cookie和请求参数传入
      Returns:
    • refreshTokenKey

      public String refreshTokenKey()
      refresh token key ,可以接受从header/cookie和请求参数传入
      Returns:
    • token

      public String token()
      获取token
      Specified by:
      token in interface AuthService
      Returns:
    • refreshToken

      public String refreshToken()
      获取 refresh token
      Specified by:
      refreshToken in interface AuthService
      Returns:
    • optionalUser

      public Optional<AuthUser> optionalUser()
      Description copied from interface: AuthService
      尝试获取当前用户
      Specified by:
      optionalUser in interface AuthService
      Returns:
      See Also:
      • invalid reference
        club.zhcs.lina.auth.service.AuthService#optionalUser()