🎉 2.0.3.RELEASE 兼容jdk11

This commit is contained in:
smallchill 2019-02-18 23:51:39 +08:00
parent 367dbc103b
commit 2feebfdead
10 changed files with 16 additions and 18 deletions

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-tool</artifactId> <artifactId>blade-tool</artifactId>
<version>2.0.2</version> <version>2.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>blade-tool</artifactId> <artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<version>2.0.2</version> <version>2.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>blade-tool</artifactId> <artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<version>2.0.2</version> <version>2.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>blade-tool</artifactId> <artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<version>2.0.2</version> <version>2.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>blade-tool</artifactId> <artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<version>2.0.2</version> <version>2.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>blade-tool</artifactId> <artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<version>2.0.2</version> <version>2.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -20,17 +20,15 @@ import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts; import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm; import io.jsonwebtoken.SignatureAlgorithm;
import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.utils.Charsets;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringPool; import org.springblade.core.tool.utils.StringPool;
import org.springblade.core.tool.utils.WebUtil; import org.springblade.core.tool.utils.WebUtil;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.DatatypeConverter;
import java.security.Key; import java.security.Key;
import java.util.Calendar; import java.util.*;
import java.util.Date;
import java.util.Map;
/** /**
* Secure工具类 * Secure工具类
@ -48,7 +46,7 @@ public class SecureUtil {
public final static String USER_NAME = "userName"; public final static String USER_NAME = "userName";
public final static String ROLE_NAME = "roleName"; public final static String ROLE_NAME = "roleName";
public final static Integer AUTH_LENGTH = 7; public final static Integer AUTH_LENGTH = 7;
private static String BASE64_SECURITY = DatatypeConverter.printBase64Binary("SpringBlade".getBytes()); private static String BASE64_SECURITY = Base64.getEncoder().encodeToString("SpringBlade".getBytes(Charsets.UTF_8));
/** /**
* 获取用户信息 * 获取用户信息
@ -159,7 +157,7 @@ public class SecureUtil {
* @return header * @return header
*/ */
public static String getHeader() { public static String getHeader() {
return getHeader(WebUtil.getRequest()); return getHeader(Objects.requireNonNull(WebUtil.getRequest()));
} }
/** /**
@ -181,7 +179,7 @@ public class SecureUtil {
public static Claims parseJWT(String jsonWebToken) { public static Claims parseJWT(String jsonWebToken) {
try { try {
Claims claims = Jwts.parser() Claims claims = Jwts.parser()
.setSigningKey(DatatypeConverter.parseBase64Binary(BASE64_SECURITY)) .setSigningKey(Base64.getDecoder().decode(BASE64_SECURITY))
.parseClaimsJws(jsonWebToken).getBody(); .parseClaimsJws(jsonWebToken).getBody();
return claims; return claims;
} catch (Exception ex) { } catch (Exception ex) {
@ -205,7 +203,7 @@ public class SecureUtil {
Date now = new Date(nowMillis); Date now = new Date(nowMillis);
//生成签名密钥 //生成签名密钥
byte[] apiKeySecretBytes = DatatypeConverter.parseBase64Binary(BASE64_SECURITY); byte[] apiKeySecretBytes = Base64.getDecoder().decode(BASE64_SECURITY);
Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName()); Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
//添加构成JWT的类 //添加构成JWT的类

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>blade-tool</artifactId> <artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<version>2.0.2</version> <version>2.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-tool</artifactId> <artifactId>blade-tool</artifactId>
<version>2.0.2</version> <version>2.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-tool</artifactId> <artifactId>blade-tool</artifactId>
<version>2.0.2</version> <version>2.0.3</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>blade-tool</name> <name>blade-tool</name>
<description> <description>
@ -36,7 +36,7 @@
</scm> </scm>
<properties> <properties>
<blade.tool.version>2.0.2</blade.tool.version> <blade.tool.version>2.0.3</blade.tool.version>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<maven.plugin.version>3.8.0</maven.plugin.version> <maven.plugin.version>3.8.0</maven.plugin.version>