master
邱飞云 4 years ago
parent 7f743e7dfb
commit 0494bd9234
  1. 8
      dq-financial-api/pom.xml
  2. 13
      dq-financial-api/src/main/java/com/daqing/financial/DqFinancialApiApplication.java
  3. 2
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java
  4. 15
      dq-framework-common/pom.xml
  5. 12
      dq-framework-common/src/main/java/com/daqing/framework/util/JwtUtils.java
  6. 9
      dq-framework-common/src/main/java/com/daqing/framework/util/Md5Util.java

@ -29,17 +29,17 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>-->
<!--<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.8.RELEASE</version>
</dependency>-->
</dependency>
<dependency>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.1.8.RELEASE</version>
<scope>test</scope>
</dependency>
</dependency>-->
</dependencies>
</project>

@ -0,0 +1,13 @@
package com.daqing.financial;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
@EnableSwagger2
public class DqFinancialApiApplication {
public static void main(String[] args) {
SpringApplication.run(DqFinancialApiApplication.class, args);
}
}

@ -138,7 +138,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
if(loginRequest.getTenDayEffective() == 1){
times = 846000;
}
String token = JwtUtils.createJWT(userEntity.getId(),"token", times);
String token = JwtUtils.createJWT(userEntity.getId()+"","token", times);
Token userToken = tokenService.getOne(new QueryWrapper<Token>().eq("user_id", userEntity.getId()));
if(userToken != null){
//删除redis里面的token

@ -57,7 +57,11 @@
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.7</version>
</dependency>
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
@ -70,11 +74,6 @@
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
@ -111,11 +110,11 @@
</dependency>
<!--jwt-->
<dependency>
<!--<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.3.0</version>
</dependency>
</dependency>-->
<!--fastJson-->
<dependency>

@ -6,7 +6,7 @@ import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.bouncycastle.util.encoders.Base64;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
@ -23,7 +23,7 @@ public class JwtUtils {
* @return String
*
*/
public static String createJWT(Long id, String subject, long ttlMillis) {
public static String createJWT(String id, String subject, long ttlMillis) {
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
long nowMillis = System.currentTimeMillis();
Date now = new Date(nowMillis);
@ -41,9 +41,9 @@ public class JwtUtils {
}
public static void main(String[] args) {
//System.out.printf(createJWT("1","111", 10000000));
boolean isTrue = validateJWT("eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxIiwic3ViIjoiMTExIiwiaXNzIjoidXNlciIsImlhdCI6MTYwMTM0MzYyNywiZXhwIjoxNjAxMzUzNjI3fQ.q5Ssg2LM1OzzgvVWqLhgP_Hko0-pfeNO5bvpUE5KQ-s");
System.out.println(isTrue);
System.out.println(validateJWT(createJWT("1","123",100000)));
//byte[] encodedKey = Base64.decode("DQJWT");
//System.out.println(encodedKey);
}
/**
@ -69,7 +69,7 @@ public class JwtUtils {
}
public static SecretKey generalKey() {
byte[] encodedKey = Base64.decode("JWTDQ123456");
byte[] encodedKey = Base64.decodeBase64("DQJWT");
SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES");
return key;
}

@ -3,6 +3,9 @@ package com.daqing.framework.util;
import org.springframework.util.DigestUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
/**
* @author zcw
* @version 1.0
@ -18,7 +21,9 @@ public class Md5Util {
return DigestUtils.md5DigestAsHex(str.getBytes());
}
public static void main(String[] args) {
System.out.printf(md5("1234561"));
public static void main(String[] args) throws UnsupportedEncodingException {
//System.out.printf(md5("1234561"));
String s = URLEncoder.encode("www.occupationlab.com", "utf-8");
System.out.println(s);
}
}

Loading…
Cancel
Save