mirror of
https://gitee.com/fujieid/jap.git
synced 2024-11-30 02:27:34 +08:00
✨ remove guava dependency.
This commit is contained in:
parent
dbcf2b5cf5
commit
4b16e5b1d9
@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.fujieid.jap.core;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* JAP constant
|
||||
*
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package com.fujieid.jap.core.context;
|
||||
|
||||
import com.fujieid.jap.core.config.JapConfig;
|
||||
import com.fujieid.jap.core.cache.JapCache;
|
||||
import com.fujieid.jap.core.config.JapConfig;
|
||||
import com.fujieid.jap.core.store.JapUserStore;
|
||||
|
||||
/**
|
||||
|
@ -18,8 +18,6 @@ package com.fujieid.jap.core.cache;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* unit test
|
||||
*
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.fujieid.jap.sso;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
@ -30,13 +30,12 @@ import com.fujieid.jap.core.strategy.AbstractJapStrategy;
|
||||
import com.fujieid.jap.oauth2.pkce.PkceHelper;
|
||||
import com.fujieid.jap.oauth2.token.AccessToken;
|
||||
import com.fujieid.jap.oauth2.token.AccessTokenHelper;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xkcoding.json.util.Kv;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -139,12 +138,14 @@ public class Oauth2Strategy extends AbstractJapStrategy {
|
||||
}
|
||||
|
||||
private JapUser getUserInfo(OAuthConfig oAuthConfig, AccessToken accessToken) throws JapOauth2Exception {
|
||||
Kv userinfo = Oauth2Util.request(oAuthConfig.getUserInfoEndpointMethodType(), oAuthConfig.getUserinfoUrl(),
|
||||
ImmutableMap.of("access_token", accessToken.getAccessToken()));
|
||||
Map<String, String> params = new HashMap<>(6);
|
||||
params.put("access_token", accessToken.getAccessToken());
|
||||
|
||||
Oauth2Util.checkOauthResponse(userinfo, "Oauth2Strategy failed to get userinfo with accessToken.");
|
||||
Kv userInfo = Oauth2Util.request(oAuthConfig.getUserInfoEndpointMethodType(), oAuthConfig.getUserinfoUrl(), params);
|
||||
|
||||
JapUser japUser = this.japUserService.createAndGetOauth2User(oAuthConfig.getPlatform(), userinfo, accessToken);
|
||||
Oauth2Util.checkOauthResponse(userInfo, "Oauth2Strategy failed to get userInfo with accessToken.");
|
||||
|
||||
JapUser japUser = this.japUserService.createAndGetOauth2User(oAuthConfig.getPlatform(), userInfo, accessToken);
|
||||
if (ObjectUtil.isNull(japUser)) {
|
||||
return null;
|
||||
}
|
||||
@ -173,7 +174,7 @@ public class Oauth2Strategy extends AbstractJapStrategy {
|
||||
* @see <a href="https://tools.ietf.org/html/rfc6749#section-4.2" target="_blank">4.2. Implicit Grant</a>
|
||||
*/
|
||||
private String generateAuthorizationCodeGrantUrl(OAuthConfig oAuthConfig) {
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
Map<String, Object> params = new HashMap<>(6);
|
||||
params.put("response_type", oAuthConfig.getResponseType());
|
||||
params.put("client_id", oAuthConfig.getClientId());
|
||||
if (StrUtil.isNotBlank(oAuthConfig.getCallbackUrl())) {
|
||||
|
@ -18,8 +18,8 @@ package com.fujieid.jap.oauth2.pkce;
|
||||
import com.fujieid.jap.core.context.JapAuthentication;
|
||||
import com.fujieid.jap.oauth2.OAuthConfig;
|
||||
import com.fujieid.jap.oauth2.Oauth2Util;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -54,7 +54,7 @@ public class PkceHelper {
|
||||
PkceCodeChallengeMethod pkceCodeChallengeMethod = Optional.ofNullable(oAuthConfig.getCodeChallengeMethod())
|
||||
.orElse(PkceCodeChallengeMethod.S256);
|
||||
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
String codeVerifier = Oauth2Util.generateCodeVerifier();
|
||||
String codeChallenge = Oauth2Util.generateCodeChallenge(pkceCodeChallengeMethod, codeVerifier);
|
||||
params.put(PkceParams.CODE_CHALLENGE, codeChallenge);
|
||||
|
@ -22,10 +22,10 @@ import com.fujieid.jap.core.util.JapUtil;
|
||||
import com.fujieid.jap.oauth2.*;
|
||||
import com.fujieid.jap.oauth2.pkce.PkceHelper;
|
||||
import com.fujieid.jap.oauth2.pkce.PkceParams;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xkcoding.json.util.Kv;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -81,7 +81,7 @@ public class AccessTokenHelper {
|
||||
Oauth2Util.checkState(state, oAuthConfig.getClientId(), oAuthConfig.isVerifyState());
|
||||
|
||||
String code = request.getParameter("code");
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
Map<String, String> params = new HashMap<>(6);
|
||||
params.put("grant_type", Oauth2GrantType.authorization_code.name());
|
||||
params.put("code", code);
|
||||
params.put("client_id", oAuthConfig.getClientId());
|
||||
@ -136,7 +136,7 @@ public class AccessTokenHelper {
|
||||
* @see <a href="https://tools.ietf.org/html/rfc6749#section-4.3" target="_blank">4.3. Resource Owner Password Credentials Grant</a>
|
||||
*/
|
||||
private static AccessToken getAccessTokenOfPasswordMode(OAuthConfig oAuthConfig) throws JapOauth2Exception {
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
Map<String, String> params = new HashMap<>(6);
|
||||
params.put("grant_type", Oauth2GrantType.password.name());
|
||||
params.put("username", oAuthConfig.getUsername());
|
||||
params.put("password", oAuthConfig.getPassword());
|
||||
|
@ -15,12 +15,11 @@
|
||||
*/
|
||||
package com.fujieid.jap.oauth2;
|
||||
|
||||
import com.fujieid.jap.core.config.AuthenticateConfig;
|
||||
import com.fujieid.jap.core.config.JapConfig;
|
||||
import com.fujieid.jap.core.JapUser;
|
||||
import com.fujieid.jap.core.JapUserService;
|
||||
import com.fujieid.jap.core.cache.JapCache;
|
||||
import com.fujieid.jap.core.exception.JapException;
|
||||
import com.fujieid.jap.core.config.AuthenticateConfig;
|
||||
import com.fujieid.jap.core.config.JapConfig;
|
||||
import com.fujieid.jap.core.result.JapResponse;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -19,12 +19,12 @@ import cn.hutool.core.util.*;
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.fujieid.jap.core.exception.JapSocialException;
|
||||
import com.google.common.collect.Maps;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.request.AuthRequest;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -47,7 +47,7 @@ public class JustAuthRequestContext {
|
||||
/**
|
||||
* Save registered AuthRequest implementation classes
|
||||
*/
|
||||
private static final Map<String, Class<?>> AUTH_REQUEST_HOLDER = Maps.newHashMap();
|
||||
private static final Map<String, Class<?>> AUTH_REQUEST_HOLDER = new HashMap<>(8);
|
||||
|
||||
/**
|
||||
* Extract the rules for third-party platform names, only for implementation classes named according to
|
||||
@ -126,7 +126,7 @@ public class JustAuthRequestContext {
|
||||
private static void scanPackage(String scanPackage, String[] exclusionClassNames) {
|
||||
log.debug("Start scanning package path {}...", scanPackage);
|
||||
Set<Class<?>> classes = ClassUtil.scanPackage(scanPackage);
|
||||
Map<String, Class<?>> item = Maps.newConcurrentMap();
|
||||
Map<String, Class<?>> item = new HashMap<>(16);
|
||||
for (Class<?> clazz : classes) {
|
||||
String className = ClassUtil.getClassName(clazz, true);
|
||||
if (Arrays.asList(exclusionClassNames).contains(className)) {
|
||||
|
8
pom.xml
8
pom.xml
@ -67,7 +67,6 @@
|
||||
<junit.version>4.13.1</junit.version>
|
||||
<mockito.version>2.23.4</mockito.version>
|
||||
<hutool.version>5.5.7</hutool.version>
|
||||
<guava.version>RELEASE</guava.version>
|
||||
<javax.servlet.version>4.0.1</javax.servlet.version>
|
||||
<justauth.version>1.15.9</justauth.version>
|
||||
<jose4j.version>0.7.1</jose4j.version>
|
||||
@ -121,12 +120,6 @@
|
||||
<version>${simple-json.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
@ -162,6 +155,7 @@
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>${javax.servlet.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user