本文整理了Java中io.jsonwebtoken.Claims.setIssuer()
方法的一些代码示例,展示了Claims.setIssuer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Claims.setIssuer()
方法的具体详情如下:
包路径:io.jsonwebtoken.Claims
类名称:Claims
方法名:setIssuer
暂无
代码示例来源:origin: jwtk/jjwt
@Override
public JwtParser requireIssuer(String issuer) {
expectedClaims.setIssuer(issuer);
return this;
}
代码示例来源:origin: jwtk/jjwt
@Override
public JwtBuilder setIssuer(String iss) {
if (Strings.hasText(iss)) {
ensureClaims().setIssuer(iss);
} else {
if (this.claims != null) {
claims.setIssuer(iss);
}
}
return this;
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void refresh_token() {
setSecretKey(A_SECRET_KEY);
underTest.start();
Date now = new Date();
Date createdAt = DateUtils.parseDate("2016-01-01");
// Expired in 10 minutes
Date expiredAt = new Date(now.getTime() + 10 * 60 * 1000);
Claims token = new DefaultClaims()
.setId("id")
.setSubject("subject")
.setIssuer("sonarqube")
.setIssuedAt(createdAt)
.setExpiration(expiredAt);
token.put("key", "value");
// Refresh the token with a higher expiration time
String encodedToken = underTest.refresh(token, 20 * 60);
Claims result = underTest.decode(encodedToken).get();
assertThat(result.getId()).isEqualTo("id");
assertThat(result.getSubject()).isEqualTo("subject");
assertThat(result.getIssuer()).isEqualTo("sonarqube");
assertThat(result.getIssuedAt()).isEqualTo(createdAt);
assertThat(result.get("key")).isEqualTo("value");
// Expiration date has been changed
assertThat(result.getExpiration()).isNotEqualTo(expiredAt)
.isAfterOrEqualsTo(new Date(now.getTime() + 19 * 1000));
}
代码示例来源:origin: io.jsonwebtoken/jjwt
@Override
public JwtParser requireIssuer(String issuer) {
expectedClaims.setIssuer(issuer);
return this;
}
代码示例来源:origin: io.jsonwebtoken/jjwt-impl
@Override
public JwtParser requireIssuer(String issuer) {
expectedClaims.setIssuer(issuer);
return this;
}
代码示例来源:origin: io.jsonwebtoken/jjwt
@Override
public JwtBuilder setIssuer(String iss) {
if (Strings.hasText(iss)) {
ensureClaims().setIssuer(iss);
} else {
if (this.claims != null) {
claims.setIssuer(iss);
}
}
return this;
}
代码示例来源:origin: io.jsonwebtoken/jjwt-impl
@Override
public JwtBuilder setIssuer(String iss) {
if (Strings.hasText(iss)) {
ensureClaims().setIssuer(iss);
} else {
if (this.claims != null) {
claims.setIssuer(iss);
}
}
return this;
}
代码示例来源:origin: Jasig/uPortal
protected Claims createClaims(
Class<? extends ITokenizable> clazz, String username, Date expires) {
// Registered claims
final Claims rslt =
Jwts.claims()
.setIssuer(JWT_ISSUER)
.setSubject(username)
.setExpiration(expires)
.setIssuedAt(new Date())
.setId(UUID.randomUUID().toString());
// Deserialization class
rslt.put(JwtClaims.CLASS.getName(), clazz.getName());
return rslt;
}
代码示例来源:origin: jloisel/securing-rest-api-spring-security
private String newToken(final Map<String, String> attributes, final int expiresInSec) {
final DateTime now = dates.now();
final Claims claims = Jwts
.claims()
.setIssuer(issuer)
.setIssuedAt(now.toDate());
if (expiresInSec > 0) {
final DateTime expiresAt = now.plusSeconds(expiresInSec);
claims.setExpiration(expiresAt.toDate());
}
claims.putAll(attributes);
return Jwts
.builder()
.setClaims(claims)
.signWith(HS256, secretKey)
.compressWith(COMPRESSION_CODEC)
.compact();
}
内容来源于网络,如有侵权,请联系作者删除!