mirror of
https://gitee.com/fujieid/jap.git
synced 2024-12-02 11:18:53 +08:00
✨ Code optimization for easy initialization as a Spring bean.
This commit is contained in:
parent
041be7963f
commit
8b44c8ff7a
@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.fujieid.jap.ids.endpoint;
|
||||
|
||||
import com.fujieid.jap.ids.JapIds;
|
||||
import com.fujieid.jap.ids.config.IdsConfig;
|
||||
import com.fujieid.jap.ids.service.Oauth2Service;
|
||||
import com.fujieid.jap.ids.service.Oauth2ServiceImpl;
|
||||
|
||||
@ -29,10 +27,9 @@ import com.fujieid.jap.ids.service.Oauth2ServiceImpl;
|
||||
*/
|
||||
public abstract class AbstractEndpoint {
|
||||
protected final Oauth2Service oauth2Service;
|
||||
protected IdsConfig idsConfig;
|
||||
|
||||
public AbstractEndpoint() {
|
||||
this.idsConfig = JapIds.getIdsConfig();
|
||||
this.oauth2Service = new Oauth2ServiceImpl();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,17 +16,14 @@
|
||||
package com.fujieid.jap.ids.endpoint;
|
||||
|
||||
import com.fujieid.jap.ids.JapIds;
|
||||
import com.fujieid.jap.ids.exception.InvalidClientException;
|
||||
import com.fujieid.jap.ids.model.ClientDetail;
|
||||
import com.fujieid.jap.ids.model.IdsRequestParam;
|
||||
import com.fujieid.jap.ids.model.IdsResponse;
|
||||
import com.fujieid.jap.ids.model.IdsScope;
|
||||
import com.fujieid.jap.ids.model.enums.ErrorResponse;
|
||||
import com.fujieid.jap.ids.provider.IdsRequestParamProvider;
|
||||
import com.fujieid.jap.ids.provider.IdsScopeProvider;
|
||||
import com.fujieid.jap.ids.util.OauthUtil;
|
||||
import com.fujieid.jap.ids.util.ObjectUtils;
|
||||
import com.xkcoding.json.util.StringUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -75,7 +75,7 @@ public class AuthorizationEndpoint extends AbstractEndpoint {
|
||||
}
|
||||
|
||||
return new IdsResponse<String, Object>()
|
||||
.data(OauthUtil.createAuthorizeUrl(idsConfig.getLoginUrl(), param));
|
||||
.data(OauthUtil.createAuthorizeUrl(JapIds.getIdsConfig().getLoginUrl(), param));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@ package com.fujieid.jap.ids.endpoint;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fujieid.jap.ids.JapIds;
|
||||
import com.fujieid.jap.ids.config.IdsConfig;
|
||||
import com.fujieid.jap.ids.exception.IdsException;
|
||||
import com.fujieid.jap.ids.model.IdsResponse;
|
||||
import com.fujieid.jap.ids.model.UserInfo;
|
||||
@ -93,6 +94,7 @@ public class LoginEndpoint extends AbstractEndpoint {
|
||||
* @return Confirm authorization page
|
||||
*/
|
||||
public IdsResponse<String, Object> signin(HttpServletRequest request) {
|
||||
IdsConfig idsConfig = JapIds.getIdsConfig();
|
||||
String username = request.getParameter(idsConfig.getUsernameField());
|
||||
String password = request.getParameter(idsConfig.getPasswordField());
|
||||
if (ObjectUtil.hasEmpty(username, password)) {
|
||||
|
@ -17,7 +17,6 @@ package com.fujieid.jap.ids.endpoint;
|
||||
|
||||
import com.fujieid.jap.ids.JapIds;
|
||||
import com.fujieid.jap.ids.model.IdsResponse;
|
||||
import com.fujieid.jap.ids.util.TokenUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@ -34,6 +33,6 @@ public class LogoutEndpoint extends AbstractEndpoint {
|
||||
JapIds.removeUserInfo(request);
|
||||
request.getSession().invalidate();
|
||||
return new IdsResponse<String, Object>()
|
||||
.data(idsConfig.getLogoutRedirectUrl());
|
||||
.data(JapIds.getIdsConfig().getLogoutRedirectUrl());
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.fujieid.jap.ids.endpoint;
|
||||
|
||||
import com.fujieid.jap.ids.JapIds;
|
||||
import com.fujieid.jap.ids.exception.UnsupportedGrantTypeException;
|
||||
import com.fujieid.jap.ids.model.IdsRequestParam;
|
||||
import com.fujieid.jap.ids.model.IdsResponse;
|
||||
@ -23,7 +22,6 @@ import com.fujieid.jap.ids.model.enums.ErrorResponse;
|
||||
import com.fujieid.jap.ids.model.enums.GrantType;
|
||||
import com.fujieid.jap.ids.provider.IdsRequestParamProvider;
|
||||
import com.fujieid.jap.ids.provider.IdsTokenProvider;
|
||||
import com.fujieid.jap.ids.util.JwtUtil;
|
||||
import com.fujieid.jap.ids.util.TokenUtil;
|
||||
import com.xkcoding.json.util.StringUtil;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user