IAuthStrategy.java 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package org.dromara.auth.service;
  2. import org.dromara.auth.domain.vo.LoginVo;
  3. import org.dromara.common.core.exception.ServiceException;
  4. import org.dromara.common.core.utils.SpringUtils;
  5. import org.dromara.system.api.domain.vo.RemoteClientVo;
  6. /**
  7. * 授权策略
  8. *
  9. * @author Michelle.Chung
  10. */
  11. public interface IAuthStrategy {
  12. String BASE_NAME = "AuthStrategy";
  13. /**
  14. * 登录
  15. *
  16. * @param body 登录对象
  17. * @param client 授权管理视图对象
  18. * @param grantType 授权类型
  19. * @return 登录验证信息
  20. */
  21. static LoginVo login(String body, RemoteClientVo client, String grantType) {
  22. // 授权类型和客户端id
  23. String beanName = grantType + BASE_NAME;
  24. if (!SpringUtils.containsBean(beanName)) {
  25. throw new ServiceException("授权类型不正确!");
  26. }
  27. IAuthStrategy instance = SpringUtils.getBean(beanName);
  28. return instance.login(body, client);
  29. }
  30. /**
  31. * 登录
  32. *
  33. * @param body 登录对象
  34. * @param client 授权管理视图对象
  35. * @return 登录验证信息
  36. */
  37. LoginVo login(String body, RemoteClientVo client);
  38. }