当前位置:网站首页>(GGG)JWT
(GGG)JWT
2022-07-30 07:49:00 【Leo, Fei】
Official website:JSON Web Tokens- jwt.io


Link with .
Encrypted by the JWT header
The authentication information json data used by JWT is encrypted and obtained
Encrypted by A and B, it is the verification part
Import dependencies
io.jsonwebtoken jjwt 0.9.1 Generate token and set expiration time
@Testvoid JwtTest() {//generate token//1, prepare dataMap map = new HashMap();map.put("id",123);map.put("name","rang rang");/ / According to the current system change the time to set the expiration time laterlong now = System.currentTimeMillis();//2. Use the tool class of JWT to generate tokenString token = Jwts.builder().signWith(SignatureAlgorithm.HS512, "rang rang 01") //Specify the encryption algorithm.setClaims(map) //Write data.setExpiration(new Date(now + 390000)) //Expiration time.compact();System.out.println(token);}
Parse
@Testpublic void parseTest(){try{String token ="eyJhbGciOiJIUzUxMiJ9.eyJuYW1lIjoicmFuZyByYW5nIiwiaWQiOjEyMywiZXhwIjoxNjU4OTAwODQxfQ.LYLQGfxCwNVbM3Jl_021B1KO78S1785XE9bgd8gknyVMDmGyqsJqsFeSpsf7NhppqPfYy8QxeeEN222pm9v5uw";Claims body = Jwts.parser().setSigningKey("rang rang 01").parseClaimsJws(token).getBody();Object id = body.get("id");Object name = body.get("name");System.out.println(id);System.out.println(name);}catch (ExpiredJwtException e) {System.out.println("token expired");}catch(SignatureException e) {System.out.println("token is invalid");}}
JWT Detailed Explanation Detailed URL of the boss, self-fetching
边栏推荐
- 从安装到编译: 10分钟教你在本地使用和开发GraphScope
- Required request body is missing 问题解决
- GNNLab:基于空间共享思想设计的新型 GNN 系统
- Network Protocol 04 - Physical and Data Link Layers
- SE_01
- 测试开发工程师成长日记002 - 从0开始做接口自动化
- 多线程进阶(锁策略,自旋+CAS,Synchronized,JUC,信号量)
- Azide-SS-biotin|CAS:1620523-64-9|生物素-二硫键-叠氮可降解 (cleavable) 的 ADC linke
- 如何理解普吕克坐标(几何理解)
- Shortcut keys commonly used in the use of Word
猜你喜欢

Graph analysis like NetworkX with GraphScope

Required request body is missing 问题解决

Data types of Redis6

02-Use of Cycript

如何将matlab数据导入modelsim仿真

Mastering JESD204B (3) – Debugging of AD6676

How to save modelsim simulation data as a file

Rapidly develop GraphScope graph analysis applications

A New Paradigm for Distributed Deep Learning Programming: Global Tensor

搭建vsftpd服务并实现本地用户访问
随机推荐
02-Use of Cycript
idea内置翻译插件
引导过程与服务控制
使用 Grafana 的 Redis Data Source 插件监控 Redis
【无标题】
05-Theos
Test and Development Engineer Growth Diary 009 - Environment Pai Pai Station: Development Environment, Test Environment, Production Environment, UAT Environment, Simulation Environment
矩阵的行列式的计算及其源码
Mastering JESD204B (3) – Debugging of AD6676
Azide-SS-biotin|CAS:1620523-64-9|生物素-二硫键-叠氮可降解 (cleavable) 的 ADC linke
04-packing and unpacking
Selenium02
测试开发工程师成长日记009 - 环境排排站:开发环境、测试环境、生产环境、UAT环境、仿真环境
测试开发工程师成长日记007 - Bug的优先级定义及填写规范
Alamofire source code analysis - POST request
Rodrigues:旋转矩阵的向量表达
测开基础知识01
MySQL主从复制配置搭建,一步到位
How to import matlab data into modelsim simulation
如何使用xilinx的FFT ip