本文整理汇总了Java中io.jsonwebtoken.Header类的典型用法代码示例。如果您正苦于以下问题:Java Header类的具体用法?Java Header怎么用?Java Header使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Header类属于io.jsonwebtoken包,在下文中一共展示了Header类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: signClaims
import io.jsonwebtoken.Header; //导入依赖的package包/类
static private String signClaims(Claims claims)
{
// Header
Map<String, Object> header = new HashMap<>();
header.put(Header.TYPE, Header.JWT_TYPE);
header.put(JwsHeader.ALGORITHM, signatureAlgorithm);
// Signature key
Key key = new SecretKeySpec(getSecretKey(),
signatureAlgorithm.getJcaName());
String ret = Jwts.builder().
setHeader(header).
setClaims(claims).
signWith(signatureAlgorithm, key).
compact();
return ret;
}
开发者ID:UnionVMS,项目名称:USM,代码行数:20,代码来源:DefaultJwtTokenHandler.java
示例2: resolveCompressionCodec
import io.jsonwebtoken.Header; //导入依赖的package包/类
@Override
public CompressionCodec resolveCompressionCodec(Header header) {
String cmpAlg = getAlgorithmFromHeader(header);
final boolean hasCompressionAlgorithm = Strings.hasText(cmpAlg);
if (!hasCompressionAlgorithm) {
return null;
}
if (CompressionCodecs.DEFLATE.getAlgorithmName().equalsIgnoreCase(cmpAlg)) {
return CompressionCodecs.DEFLATE;
}
if (CompressionCodecs.GZIP.getAlgorithmName().equalsIgnoreCase(cmpAlg)) {
return CompressionCodecs.GZIP;
}
throw new CompressionException("Unsupported compression algorithm '" + cmpAlg + "'");
}
开发者ID:jwtk,项目名称:jjwt,代码行数:19,代码来源:DefaultCompressionCodecResolver.java
示例3: validateJwtToken
import io.jsonwebtoken.Header; //导入依赖的package包/类
protected void validateJwtToken(String token, String username) {
Assert.assertNotNull(token);
Assert.assertFalse(token.isEmpty());
int i = token.lastIndexOf('.');
Assert.assertTrue(i > 0);
String withoutSignature = token.substring(0, i + 1);
Jwt<Header, Claims> jwsClaims = Jwts.parser().parseClaimsJwt(withoutSignature);
Claims claims = jwsClaims.getBody();
String subject = claims.getSubject();
Assert.assertEquals(username, subject);
}
开发者ID:thingsboard,项目名称:thingsboard,代码行数:12,代码来源:AbstractControllerTest.java
示例4: onPlaintextJwt
import io.jsonwebtoken.Header; //导入依赖的package包/类
@Override
public Map<String, Object> onPlaintextJwt(@SuppressWarnings("rawtypes") Jwt<Header, String> jwt) {
if (config.getRequireSigned()) {
super.onPlaintextJwt(jwt);
}
return Collections.emptyMap();
}
开发者ID:apiman,项目名称:apiman-plugins,代码行数:8,代码来源:ConfigCheckingJwtHandler.java
示例5: createTokenForUser
import io.jsonwebtoken.Header; //导入依赖的package包/类
public String createTokenForUser(UserAuthentication user) {
return Jwts.builder()
.setSubject(user.getInternalId() != null ? user.getInternalId() + "" : null)
.setHeaderParam(Header.TYPE, Header.JWT_TYPE)
.claim(CLAIM_AUTH_PROVIDER, user.getAuthProvider())
.claim(CLAIM_EXTERNAL_ID, user.getExternalId())
.claim(CLAIM_GIVEN_NAME, user.getGivenName())
.claim(CLAIM_SURNAME, user.getSurname())
.claim(CLAIM_EMAIL, user.getEmail())
.claim(CLAIM_AUTHORITIES, user.getAuthorities().stream().map(a -> a.getAuthority()).collect(Collectors.toList()))
.setIssuedAt(new Date())
.setExpiration(new Date(new Date().getTime() + DAY_DURATION))
.signWith(SignatureAlgorithm.HS256, secretKey)
.compact();
}
开发者ID:HelfenKannJeder,项目名称:come2help,代码行数:16,代码来源:JwtTokenHandler.java
示例6: createTokenForUser
import io.jsonwebtoken.Header; //导入依赖的package包/类
public String createTokenForUser(UserAuthentication user) {
return Jwts.builder()
.setSubject(user.getName())
.setHeaderParam(Header.TYPE, Header.JWT_TYPE)
.claim(CLAIM_AUTH_PROVIDER, user.getAuthProvider())
.claim(CLAIM_EXTERNAL_ID, user.getExternalId())
.claim(CLAIM_GIVEN_NAME, user.getGivenName())
.claim(CLAIM_SURNAME, user.getSurname())
.claim(CLAIM_EMAIL, user.getEmail())
.setIssuedAt(new Date())
.setExpiration(new Date(new Date().getTime() + DAY_DURATION))
.signWith(SignatureAlgorithm.HS256, secretKey)
.compact();
}
开发者ID:andreas-eberle,项目名称:spring-oauth2-jwt-minimal,代码行数:15,代码来源:JwtTokenHandler.java
示例7: parsePlaintextJwt
import io.jsonwebtoken.Header; //导入依赖的package包/类
@Override
public Jwt<Header, String> parsePlaintextJwt(String plaintextJwt) {
return parse(plaintextJwt, new JwtHandlerAdapter<Jwt<Header, String>>() {
@Override
public Jwt<Header, String> onPlaintextJwt(Jwt<Header, String> jwt) {
return jwt;
}
});
}
开发者ID:jwtk,项目名称:jjwt,代码行数:10,代码来源:DefaultJwtParser.java
示例8: parseClaimsJwt
import io.jsonwebtoken.Header; //导入依赖的package包/类
@Override
public Jwt<Header, Claims> parseClaimsJwt(String claimsJwt) {
try {
return parse(claimsJwt, new JwtHandlerAdapter<Jwt<Header, Claims>>() {
@Override
public Jwt<Header, Claims> onClaimsJwt(Jwt<Header, Claims> jwt) {
return jwt;
}
});
} catch (IllegalArgumentException iae) {
throw new UnsupportedJwtException("Signed JWSs are not supported.", iae);
}
}
开发者ID:jwtk,项目名称:jjwt,代码行数:14,代码来源:DefaultJwtParser.java
示例9: getIdentityId
import io.jsonwebtoken.Header; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public String getIdentityId(final String keycloakToken) throws JsonProcessingException, IOException {
Jwt<Header, Claims> jwt = getJwt(keycloakToken);
return jwt.getBody().getSubject();
}
开发者ID:redhat-developer,项目名称:che-starter,代码行数:6,代码来源:KeycloakTokenParser.java
示例10: getSessionState
import io.jsonwebtoken.Header; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public String getSessionState(final String keycloakToken) throws JsonProcessingException, IOException {
Jwt<Header, Claims> jwt = getJwt(keycloakToken);
return jwt.getBody().get(SESSION_STATE).toString();
}
开发者ID:redhat-developer,项目名称:che-starter,代码行数:6,代码来源:KeycloakTokenParser.java
示例11: getJwt
import io.jsonwebtoken.Header; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private Jwt<Header, Claims> getJwt(final String keycloakToken) {
String jwt = keycloakToken.replaceFirst(TOKEN_PREFIX, "");
String tokenWithoutSignature = getJWSWithoutSignature(jwt);
return Jwts.parser().parseClaimsJwt(tokenWithoutSignature);
}
开发者ID:redhat-developer,项目名称:che-starter,代码行数:7,代码来源:KeycloakTokenParser.java
示例12: getTokenBody
import io.jsonwebtoken.Header; //导入依赖的package包/类
public static Map<String, Object> getTokenBody(String jwsToken) {
String jwtToken = jwsToken.substring(0, jwsToken.lastIndexOf(".") + 1);
Jwt<Header, Claims> untrusted = Jwts.parser().parseClaimsJwt(jwtToken);
return untrusted.getBody();
}
开发者ID:EhsanMashhadi,项目名称:RepositoryPattern,代码行数:6,代码来源:JwtTokenHelper.java
示例13: onClaimsJwt
import io.jsonwebtoken.Header; //导入依赖的package包/类
@Override
public Map<String, Object> onClaimsJwt(@SuppressWarnings("rawtypes") Jwt<Header, Claims> jwt) {
return config.getRequireSigned() ? super.onClaimsJwt(jwt) : jwt.getBody();
}
开发者ID:apiman,项目名称:apiman-plugins,代码行数:5,代码来源:ConfigCheckingJwtHandler.java
示例14: DefaultJwt
import io.jsonwebtoken.Header; //导入依赖的package包/类
public DefaultJwt(Header header, B body) {
this.header = header;
this.body = body;
}
开发者ID:jwtk,项目名称:jjwt,代码行数:5,代码来源:DefaultJwt.java
示例15: getHeader
import io.jsonwebtoken.Header; //导入依赖的package包/类
@Override
public Header getHeader() {
return header;
}
开发者ID:jwtk,项目名称:jjwt,代码行数:5,代码来源:DefaultJwt.java
示例16: getAlgorithmFromHeader
import io.jsonwebtoken.Header; //导入依赖的package包/类
private String getAlgorithmFromHeader(Header header) {
Assert.notNull(header, "header cannot be null.");
return header.getCompressionAlgorithm();
}
开发者ID:jwtk,项目名称:jjwt,代码行数:6,代码来源:DefaultCompressionCodecResolver.java
注:本文中的io.jsonwebtoken.Header类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论