当前位置:网站首页>(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
边栏推荐
- Redis下载与安装
- 软件测试开发:发送第一封测试报告邮件
- Test development engineer diary 002 - starting from 0 interface automation
- BlockingQueue详细介绍
- Multithreading basics (multithreaded memory, security, communication, thread pools and blocking queues)
- 测试开发工程师成长日记003 - 接口自动化框架搭建
- 测试开发工程师成长日记008 - 浅谈一些Bug/用例管理平台/协作平台
- debian 问题
- RAID磁盘阵列
- 网络协议04 - 物理层和数据链路层
猜你喜欢

Selenium02

Test Development Engineer Growth Diary 018 - Record of Required Questions for Test Interview (Continuous Update)

Application of graph computing in network security analysis

图计算在网络安全分析中的应用

Biotin-NHS LC(72040-63-2)生物素接头|站点特定探针

Test development engineer growth diary 016 - those things about the test

Vineyard: An open source distributed in-memory data management framework

DNS域名解析服务

向量叉乘的几何意义及其模的计算

Multithreading basics (multithreaded memory, security, communication, thread pools and blocking queues)
随机推荐
Network Protocol 04 - Physical and Data Link Layers
【Untitled】
基于 JupyterLab 插件在 GraphScope 中交互式构图
测试开发工程师成长日记017 - bug的生命周期
关于memcache内核,全网最通俗的讲解
DHCP原理与配置
Build an intelligent network security management and control system for digital government
Mastering JESD204B (2) – Debugging of AD6676
debian vsftpd + ssl
图计算101:图计算的类型、语言与系统
debian 问题
Graph analysis like NetworkX with GraphScope
GAIA-IR: Parallelized Graph Query Engine on GraphScope
Advanced multi-threading (CountDownLatch, deadlock, thread-safe collection class)
MongoDB-CUD without R
从安装到编译: 10分钟教你在本地使用和开发GraphScope
藏不住了,我要揭露云原生的那些不好
掌握JESD204B(三)–AD6676的调试
matlab机器学习_01
Proftpd配置文件