1
0
mirror of https://gitee.com/dromara/hutool.git synced 2025-04-05 17:37:59 +08:00
hutool/hutool-json/src/main/java/cn/hutool/json/jwt/JWTHeader.java
2021-06-10 16:26:31 +08:00

60 lines
1.0 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cn.hutool.json.jwt;
import java.util.Map;
/**
* JWT头部信息
*
* @author looly
*/
public class JWTHeader extends Claims {
private static final long serialVersionUID = 1L;
//Header names
/**
* 加密算法通常为HMAC SHA256HS256
*/
public static String ALGORITHM = "alg";
/**
* 声明类型一般为jwt
*/
public static String TYPE = "typ";
/**
* 内容类型content type
*/
public static String CONTENT_TYPE = "cty";
/**
* jwk的ID编号
*/
public static String KEY_ID = "kid";
/**
* 增加“kid”头信息
*
* @param keyId kid
* @return this
*/
public JWTHeader setKeyId(String keyId) {
setClaim(KEY_ID, keyId);
return this;
}
/**
* 增加自定义JWT认证头
*
* @param headerClaims 头信息
* @return this
*/
public JWTHeader addHeaders(Map<String, ?> headerClaims) {
if (headerClaims == null) {
return this;
}
for (Map.Entry<String, ?> entry : headerClaims.entrySet()) {
setClaim(entry.getKey(), entry.getValue());
}
return this;
}
}