Class SecurityOauthAuthenticateService

java.lang.Object
com.codeupsoft.component.security.service.SecurityOauthAuthenticateService
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

public class SecurityOauthAuthenticateService extends Object implements org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware
OAuth认证服务类.

该服务负责处理OAuth类型的认证请求,支持多种grant type的认证方式. 通过注册不同的SecurityOauthAuthenticateHandler来支持不同的OAuth认证流程.

Author:
Liu,Dongdong
  • Constructor Details

    • SecurityOauthAuthenticateService

      public SecurityOauthAuthenticateService()
  • Method Details

    • authenticate

      public LoginUser authenticate(String grantType, jakarta.servlet.http.HttpServletRequest request)
      执行OAuth用户认证流程.

      根据指定的grant type选择相应的认证处理器执行认证, 并在认证成功后执行认证后处理器.

      Parameters:
      grantType - OAuth授权类型,如"password"、"authorization_code"等
      request - HTTP请求对象,包含认证所需的参数
      Returns:
      认证成功的用户信息
      Throws:
      org.springframework.security.authentication.AuthenticationServiceException - 当不支持指定的grant type时抛出
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      初始化Bean属性完成后执行.

      从Spring应用上下文中获取所有SecurityOauthAuthenticateHandler类型的Bean, 并根据它们的grant type注册到处理器映射表中.

      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception - 初始化过程中可能抛出的异常
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      设置Spring应用上下文.

      由ApplicationContextAware接口回调方法设置应用上下文实例.

      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Parameters:
      applicationContext - Spring应用上下文
      Throws:
      org.springframework.beans.BeansException - 设置过程中可能抛出的异常