forked from lyj8330328/leyou
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c947400
commit fd777c8
Showing
15 changed files
with
345 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 60 additions & 60 deletions
120
...authentication/leyou-authentication-common/src/test/java/com/leyou/auth/test/JwtTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,60 @@ | ||
package com.leyou.auth.test; | ||
|
||
import com.leyou.auth.entity.UserInfo; | ||
import com.leyou.auth.utils.JwtUtils; | ||
import com.leyou.auth.utils.RsaUtils; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.security.PrivateKey; | ||
import java.security.PublicKey; | ||
import java.util.Date; | ||
|
||
/** | ||
* @Author: 98050 | ||
* @Time: 2018-10-23 20:58 | ||
* @Feature: JWT测试 | ||
*/ | ||
public class JwtTest { | ||
|
||
private static final String pubKeyPath = "G:\\tmp\\rsa\\rsa.pub"; | ||
|
||
private static final String priKeyPath = "G:\\tmp\\rsa\\rsa.pri"; | ||
|
||
private PublicKey publicKey; | ||
|
||
private PrivateKey privateKey; | ||
|
||
@Test | ||
public void testRsa() throws Exception { | ||
RsaUtils.generateKey(pubKeyPath, priKeyPath, "234"); | ||
} | ||
|
||
@Before | ||
public void testGetRsa() throws Exception { | ||
this.publicKey = RsaUtils.getPublicKey(pubKeyPath); | ||
this.privateKey = RsaUtils.getPrivateKey(priKeyPath); | ||
} | ||
|
||
@Test | ||
public void testGenerateToken() throws Exception { | ||
// 生成token | ||
String token = JwtUtils.generateToken(new UserInfo(20L, "jack"), privateKey, 5); | ||
System.out.println("token = " + token); | ||
} | ||
|
||
@Test | ||
public void testParseToken() throws Exception { | ||
String token = "eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MjAsInVzZXJuYW1lIjoiamFjayIsImV4cCI6MTU0MDMwMjU4MX0.KFGDe8V8TwLl5xGqM1brPV50JXf3Z6G4cXPIeYxsqaeeol06BnXNNsyLAbUSrFxloUf-hQqO41O1OrtERllU-JfZXs6MA6rTBSfpar2MJRSZyDGKqfBpPoRED3yZv8oFuzI_94GONqsipmGyQFqWUkhTf9k0tZ5LPRvvGl9tkvc"; | ||
|
||
// 解析token | ||
UserInfo user = JwtUtils.getInfoFromToken(token, publicKey); | ||
System.out.println("id: " + user.getId()); | ||
System.out.println("userName: " + user.getUsername()); | ||
} | ||
|
||
@Test | ||
public void date(){ | ||
System.out.println(new Date()); | ||
} | ||
} | ||
//package com.leyou.auth.test; | ||
// | ||
//import com.leyou.auth.entity.UserInfo; | ||
//import com.leyou.auth.utils.JwtUtils; | ||
//import com.leyou.auth.utils.RsaUtils; | ||
//import org.junit.Before; | ||
//import org.junit.Test; | ||
// | ||
//import java.security.PrivateKey; | ||
//import java.security.PublicKey; | ||
//import java.util.Date; | ||
// | ||
///** | ||
// * @Author: 98050 | ||
// * @Time: 2018-10-23 20:58 | ||
// * @Feature: JWT测试 | ||
// */ | ||
//public class JwtTest { | ||
// | ||
// private static final String pubKeyPath = "G:\\tmp\\rsa\\rsa.pub"; | ||
// | ||
// private static final String priKeyPath = "G:\\tmp\\rsa\\rsa.pri"; | ||
// | ||
// private PublicKey publicKey; | ||
// | ||
// private PrivateKey privateKey; | ||
// | ||
// @Test | ||
// public void testRsa() throws Exception { | ||
// RsaUtils.generateKey(pubKeyPath, priKeyPath, "234"); | ||
// } | ||
// | ||
// @Before | ||
// public void testGetRsa() throws Exception { | ||
// this.publicKey = RsaUtils.getPublicKey(pubKeyPath); | ||
// this.privateKey = RsaUtils.getPrivateKey(priKeyPath); | ||
// } | ||
// | ||
// @Test | ||
// public void testGenerateToken() throws Exception { | ||
// // 生成token | ||
// String token = JwtUtils.generateToken(new UserInfo(20L, "jack"), privateKey, 5); | ||
// System.out.println("token = " + token); | ||
// } | ||
// | ||
// @Test | ||
// public void testParseToken() throws Exception { | ||
// String token = "eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MjAsInVzZXJuYW1lIjoiamFjayIsImV4cCI6MTU0MDMwMjU4MX0.KFGDe8V8TwLl5xGqM1brPV50JXf3Z6G4cXPIeYxsqaeeol06BnXNNsyLAbUSrFxloUf-hQqO41O1OrtERllU-JfZXs6MA6rTBSfpar2MJRSZyDGKqfBpPoRED3yZv8oFuzI_94GONqsipmGyQFqWUkhTf9k0tZ5LPRvvGl9tkvc"; | ||
// | ||
// // 解析token | ||
// UserInfo user = JwtUtils.getInfoFromToken(token, publicKey); | ||
// System.out.println("id: " + user.getId()); | ||
// System.out.println("userName: " + user.getUsername()); | ||
// } | ||
// | ||
// @Test | ||
// public void date(){ | ||
// System.out.println(new Date()); | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ spring: | |
name: registry | ||
profile: dev | ||
label: master | ||
uri: http://127.0.0.1:10011 | ||
uri: http://192.168.19.122:10011 |
Oops, something went wrong.