cn.hutool.jwt.JWTHeader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hutool-all Show documentation
Show all versions of hutool-all Show documentation
Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。
package cn.hutool.jwt;
import java.util.Map;
/**
* JWT头部信息
*
* @author looly
* @since 5.7.0
*/
public class JWTHeader extends Claims {
private static final long serialVersionUID = 1L;
//Header names
/**
* 加密算法,通常为HMAC SHA256(HS256)
*/
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";
/**
* 构造,初始化默认(typ=JWT)
*/
public JWTHeader() {}
/**
* 增加“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 headerClaims) {
putAll(headerClaims);
return this;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy