本文整理汇总了Java中com.auth0.jwt.interfaces.Claim类的典型用法代码示例。如果您正苦于以下问题:Java Claim类的具体用法?Java Claim怎么用?Java Claim使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Claim类属于com.auth0.jwt.interfaces包,在下文中一共展示了Claim类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testExtendedJwtCreatorInvalidEmail
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testExtendedJwtCreatorInvalidEmail() throws Exception {
thrown.expect(InvalidClaimException.class);
thrown.expectMessage("The Claim 'email' value doesn't match the required one.");
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = ExtendedJwtCreator.build()
.withNbf(nbf) //this must be called first since ExtendedJwtCreator.build() returns an instance of ExtendedJwtCreator
.withPicture(PICTURE)
.withEmail("invalid")
.withIssuer("issuer")
.withSubject("subject")
.withAudience("audience")
.withExp(exp)
.withIat(iat)
.withName(NAME)
.sign(algorithm);
GoogleVerification verification = ExtendedJWT.require(algorithm);
JWT verifier = verification.createVerifierForExtended(PICTURE, EMAIL, asList("issuer"), asList("audience"),
NAME, 1, 1, 1).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims, exp);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:24,代码来源:ExtendedJwtCreatorTest.java
示例2: validateToken
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
private User validateToken(String token) {
try {
Algorithm algorithm = Algorithm.HMAC256(Constants.JWT_TOKEN_KEY);
JWTVerifier verifier = JWT.require(algorithm)
.withIssuer("jwtauth")
.build(); //Reusable verifier instance
DecodedJWT jwt = verifier.verify(token);
//Get the userId from token claim.
Claim userId = jwt.getClaim("userId");
// Find user by token subject(id).
UserDao userDao = new UserDao();
return userDao.findUserById(userId.asLong());
} catch (UnsupportedEncodingException | JWTVerificationException e){
LOGGER.error(e.getMessage(), e);
}
return null;
}
开发者ID:Petrakus,项目名称:java-jwt-auth,代码行数:20,代码来源:RESTService.java
示例3: testFbJwtCreatorNoneAlgorithmAllowed
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testFbJwtCreatorNoneAlgorithmAllowed() throws Exception {
Algorithm algorithm = Algorithm.none();
String token = FbJwtCreator.build()
.withExp(exp)
.withIat(iat)
.withUserId(USER_ID)
.withAppId(APP_ID)
.setIsNoneAlgorithmAllowed(true)
.sign(algorithm);
Verification verification = FbJWT.require(algorithm);
JWT verifier = verification.createVerifierForFb(USER_ID, APP_ID).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:17,代码来源:FbJwtCreatorTest.java
示例4: testFbJwtCreatorArrayClaim
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testFbJwtCreatorArrayClaim() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = FbJwtCreator.build()
.withExp(exp)
.withIat(iat)
.withUserId(USER_ID)
.withAppId(APP_ID)
.setIsNoneAlgorithmAllowed(true)
.withArrayClaim("arrayKey", "arrayValue1", "arrayValue2")
.sign(algorithm);
Verification verification = FbJWT.require(algorithm);
JWT verifier = verification.createVerifierForFb(USER_ID, APP_ID).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:18,代码来源:FbJwtCreatorTest.java
示例5: testFbJwtCreatorNonStandardClaimStringValue
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testFbJwtCreatorNonStandardClaimStringValue() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = FbJwtCreator.build()
.withExp(exp)
.withIat(iat)
.withUserId(USER_ID)
.withAppId(APP_ID)
.setIsNoneAlgorithmAllowed(true)
.withNonStandardClaim("nonStandardClaim", "nonStandardClaimValue")
.sign(algorithm);
Verification verification = FbJWT.require(algorithm);
JWT verifier = verification.createVerifierForFb(USER_ID, APP_ID).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:18,代码来源:FbJwtCreatorTest.java
示例6: testFbJwtCreatorNonStandardClaimIntegerValue
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testFbJwtCreatorNonStandardClaimIntegerValue() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = FbJwtCreator.build()
.withExp(exp)
.withIat(iat)
.withUserId(USER_ID)
.withAppId(APP_ID)
.setIsNoneAlgorithmAllowed(true)
.withNonStandardClaim("nonStandardClaim", 999)
.sign(algorithm);
Verification verification = FbJWT.require(algorithm);
JWT verifier = verification.createVerifierForFb(USER_ID, APP_ID).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:18,代码来源:FbJwtCreatorTest.java
示例7: testFbJwtCreatorNonStandardClaimLongValue
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testFbJwtCreatorNonStandardClaimLongValue() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = FbJwtCreator.build()
.withExp(exp)
.withIat(iat)
.withUserId(USER_ID)
.withAppId(APP_ID)
.setIsNoneAlgorithmAllowed(true)
.withNonStandardClaim("nonStandardClaim", 999L)
.sign(algorithm);
Verification verification = FbJWT.require(algorithm);
JWT verifier = verification.createVerifierForFb(USER_ID, APP_ID).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:18,代码来源:FbJwtCreatorTest.java
示例8: testFbJwtCreatorNonStandardClaimDoubleValue
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testFbJwtCreatorNonStandardClaimDoubleValue() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = FbJwtCreator.build()
.withExp(exp)
.withIat(iat)
.withUserId(USER_ID)
.withAppId(APP_ID)
.setIsNoneAlgorithmAllowed(true)
.withNonStandardClaim("nonStandardClaim", 9.99)
.sign(algorithm);
Verification verification = FbJWT.require(algorithm);
JWT verifier = verification.createVerifierForFb(USER_ID, APP_ID).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:18,代码来源:FbJwtCreatorTest.java
示例9: testFbJwtCreatorNonStandardClaimDateValue
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testFbJwtCreatorNonStandardClaimDateValue() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = FbJwtCreator.build()
.withExp(exp)
.withIat(iat)
.withUserId(USER_ID)
.withAppId(APP_ID)
.setIsNoneAlgorithmAllowed(true)
.withNonStandardClaim("nonStandardClaim", new Date())
.sign(algorithm);
Verification verification = FbJWT.require(algorithm);
JWT verifier = verification.createVerifierForFb(USER_ID, APP_ID).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:18,代码来源:FbJwtCreatorTest.java
示例10: testFbJwtCreatorExpTimeHasPassed
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testFbJwtCreatorExpTimeHasPassed() throws Exception {
thrown.expect(TokenExpiredException.class);
thrown.expectMessage("The Token has expired on Wed Oct 29 00:00:00 PDT 2014.");
String myDate = "2014/10/29";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
Date date = sdf.parse(myDate);
long expLong = date.getTime();
Date expDate = new Date(expLong);
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = FbJwtCreator.build()
.withExp(expDate)
.withIat(iat)
.withUserId(USER_ID)
.withAppId(APP_ID)
.setIsNoneAlgorithmAllowed(true)
.withNonStandardClaim("nonStandardClaim", new Date())
.sign(algorithm);
Verification verification = FbJWT.require(algorithm);
JWT verifier = verification.createVerifierForFb(USER_ID, APP_ID).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:27,代码来源:FbJwtCreatorTest.java
示例11: testScopedJwtCreatorBase16Encoding
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testScopedJwtCreatorBase16Encoding() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = ScopedJwtCreator.build()
.withScope("scope")
.withIssuer("issuer")
.withSubject("subject")
.withAudience("audience")
.withExp(exp)
.withIat(iat)
.signBase16Encoding(algorithm);
Verification verification = ScopedJWT.require(algorithm);
JWT verifier = verification.createVerifierForScoped("scope", asList("issuer"), asList("audience"), 1, 1).build();
DecodedJWT jwt = verifier.decode16Bytes(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims, exp);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:18,代码来源:ScopedJwtCreatorTest.java
示例12: testScopedJwtCreatorBase32Encoding
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testScopedJwtCreatorBase32Encoding() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = ScopedJwtCreator.build()
.withScope("scope")
.withIssuer("issuer")
.withSubject("subject")
.withAudience("audience")
.withExp(exp)
.withIat(iat)
.signBase32Encoding(algorithm);
Verification verification = ScopedJWT.require(algorithm);
JWT verifier = verification.createVerifierForScoped("scope", asList("issuer"), asList("audience"), 1, 1).build();
DecodedJWT jwt = verifier.decode32Bytes(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims, exp);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:18,代码来源:ScopedJwtCreatorTest.java
示例13: testScopedJwtCreatorNoneAlgorithmAllowed
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testScopedJwtCreatorNoneAlgorithmAllowed() throws Exception {
Algorithm algorithm = Algorithm.none();
String token = ScopedJwtCreator.build()
.withScope("scope")
.withIssuer("issuer")
.withSubject("subject")
.withAudience("audience")
.setIsNoneAlgorithmAllowed(true)
.withExp(exp)
.withIat(iat)
.sign(algorithm);
Verification verification = ScopedJWT.require(algorithm);
JWT verifier = verification.createVerifierForScoped("scope", asList("issuer"), asList("audience"), 1, 1).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims, exp);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:19,代码来源:ScopedJwtCreatorTest.java
示例14: testScopedJwtCreatorArrayClaim
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testScopedJwtCreatorArrayClaim() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = ScopedJwtCreator.build()
.withScope("scope")
.withIssuer("issuer")
.withSubject("subject")
.withAudience("audience")
.withArrayClaim("arrayKey", "arrayValue1", "arrayValue2")
.withExp(exp)
.withIat(iat)
.sign(algorithm);
Verification verification = ScopedJWT.require(algorithm);
JWT verifier = verification.createVerifierForScoped("scope", asList("issuer"), asList("audience"), 1, 1).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims, exp);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:19,代码来源:ScopedJwtCreatorTest.java
示例15: testScopedJwtCreatorNonStandardClaimStringValue
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testScopedJwtCreatorNonStandardClaimStringValue() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = ScopedJwtCreator.build()
.withScope("scope")
.withIssuer("issuer")
.withSubject("subject")
.withAudience("audience")
.withNonStandardClaim("nonStandardClaim", "nonStandardClaimValue")
.withExp(exp)
.withIat(iat)
.sign(algorithm);
Verification verification = ScopedJWT.require(algorithm);
JWT verifier = verification.createVerifierForScoped("scope", asList("issuer"), asList("audience"), 1, 1).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims, exp);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:19,代码来源:ScopedJwtCreatorTest.java
示例16: testScopedJwtCreatorNonStandardClaimIntegerValue
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testScopedJwtCreatorNonStandardClaimIntegerValue() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = ScopedJwtCreator.build()
.withScope("scope")
.withIssuer("issuer")
.withSubject("subject")
.withAudience("audience")
.withNonStandardClaim("nonStandardClaim", 999)
.withExp(exp)
.withIat(iat)
.sign(algorithm);
Verification verification = ScopedJWT.require(algorithm);
JWT verifier = verification.createVerifierForScoped("scope", asList("issuer"), asList("audience"), 1, 1).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims, exp);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:19,代码来源:ScopedJwtCreatorTest.java
示例17: testScopedJwtCreatorNonStandardClaimDoubleValue
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testScopedJwtCreatorNonStandardClaimDoubleValue() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = ScopedJwtCreator.build()
.withScope("scope")
.withIssuer("issuer")
.withSubject("subject")
.withAudience("audience")
.withNonStandardClaim("nonStandardClaim", 9.99)
.withExp(exp)
.withIat(iat)
.sign(algorithm);
Verification verification = ScopedJWT.require(algorithm);
JWT verifier = verification.createVerifierForScoped("scope", asList("issuer"), asList("audience"), 1, 1).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims, exp);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:19,代码来源:ScopedJwtCreatorTest.java
示例18: testScopedJwtCreatorNonStandardClaimLongValue
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testScopedJwtCreatorNonStandardClaimLongValue() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = ScopedJwtCreator.build()
.withScope("scope")
.withIssuer("issuer")
.withSubject("subject")
.withAudience("audience")
.withNonStandardClaim("nonStandardClaim", 999L)
.withExp(exp)
.withIat(iat)
.sign(algorithm);
Verification verification = ScopedJWT.require(algorithm);
JWT verifier = verification.createVerifierForScoped("scope", asList("issuer"), asList("audience"), 1, 1).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims, exp);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:19,代码来源:ScopedJwtCreatorTest.java
示例19: testScopedJwtCreatorNonStandardClaimBooleanValue
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testScopedJwtCreatorNonStandardClaimBooleanValue() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = ScopedJwtCreator.build()
.withScope("scope")
.withIssuer("issuer")
.withSubject("subject")
.withAudience("audience")
.withNonStandardClaim("nonStandardClaim", true)
.withExp(exp)
.withIat(iat)
.sign(algorithm);
Verification verification = ScopedJWT.require(algorithm);
JWT verifier = verification.createVerifierForScoped("scope", asList("issuer"), asList("audience"), 1, 1).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims, exp);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:19,代码来源:ScopedJwtCreatorTest.java
示例20: testScopedJwtCreatorNonStandardClaimDateValue
import com.auth0.jwt.interfaces.Claim; //导入依赖的package包/类
@Test
public void testScopedJwtCreatorNonStandardClaimDateValue() throws Exception {
Algorithm algorithm = Algorithm.HMAC256("secret");
String token = ScopedJwtCreator.build()
.withScope("scope")
.withIssuer("issuer")
.withSubject("subject")
.withAudience("audience")
.withNonStandardClaim("nonStandardClaim", new Date())
.withExp(exp)
.withIat(iat)
.sign(algorithm);
Verification verification = ScopedJWT.require(algorithm);
JWT verifier = verification.createVerifierForScoped("scope", asList("issuer"), asList("audience"), 1, 1).build();
DecodedJWT jwt = verifier.decode(token);
Map<String, Claim> claims = jwt.getClaims();
verifyClaims(claims, exp);
}
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:19,代码来源:ScopedJwtCreatorTest.java
注:本文中的com.auth0.jwt.interfaces.Claim类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论