本文整理了Java中com.nimbusds.jose.Payload.toJSONObject()
方法的一些代码示例,展示了Payload.toJSONObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Payload.toJSONObject()
方法的具体详情如下:
包路径:com.nimbusds.jose.Payload
类名称:Payload
方法名:toJSONObject
[英]Returns a JSON object representation of this payload.
[中]返回此有效负载的JSON对象表示形式。
代码示例来源:origin: com.nimbusds/nimbus-jose-jwt
@Override
public JWTClaimsSet getJWTClaimsSet()
throws ParseException {
JSONObject json = getPayload().toJSONObject();
if (json == null) {
throw new ParseException("Payload of unsecured JOSE object is not a valid JSON object", 0);
}
return JWTClaimsSet.parse(json);
}
代码示例来源:origin: com.nimbusds/nimbus-jose-jwt
@Override
public JWTClaimsSet getJWTClaimsSet()
throws ParseException {
JSONObject json = getPayload().toJSONObject();
if (json == null) {
throw new ParseException("Payload of JWS object is not a valid JSON object", 0);
}
return JWTClaimsSet.parse(json);
}
代码示例来源:origin: rancher/cattle
private Map<String, Object> getJSONObject(JOSEObject jose, boolean encrypted) throws TokenException {
Long exp = (Long) jose.getPayload().toJSONObject().get("exp");
if (exp != null && exp * 1000 <= System.currentTimeMillis()) {
throw new TokenException("Expired Token");
}
return jose.getPayload().toJSONObject();
}
代码示例来源:origin: com.nimbusds/nimbus-jose-jwt
@Override
public JWTClaimsSet getJWTClaimsSet()
throws ParseException {
Payload payload = getPayload();
if (payload == null) {
return null;
}
JSONObject json = payload.toJSONObject();
if (json == null) {
throw new ParseException("Payload of JWE object is not a valid JSON object", 0);
}
return JWTClaimsSet.parse(json);
}
代码示例来源:origin: naturalprogrammer/spring-lemon
/**
* Parses a token
*/
protected JWTClaimsSet parseToken(String token) {
// Parse the JWS and verify it, e.g. on client-side
JWSObject jwsObject;
try {
jwsObject = JWSObject.parse(token);
if (jwsObject.verify(verifier))
return JWTClaimsSet.parse(jwsObject.getPayload().toJSONObject());
} catch (JOSEException | ParseException e) {
throw new BadCredentialsException(e.getMessage());
}
throw new BadCredentialsException("JWS verification failed!");
}
}
代码示例来源:origin: com.atlassian.connect/atlassian-connect-spring-boot-jwt
public JWTClaimsSet parse(String jwt) throws JwtParseException {
JWSObject jwsObject = parseJWSObject(jwt);
try {
return JWTClaimsSet.parse(jwsObject.getPayload().toJSONObject());
} catch (ParseException e) {
throw new JwtParseException(e);
}
}
代码示例来源:origin: imloama/api-server-seed
public static JWTUser getJWTUser(String token) throws JWTException {
if (StringUtils.isEmpty(token)) {
throw new JWTException("没有找到token信息!");
}
try {
JWSObject jwsObject = JWSObject.parse(token);
if (JWT.verify(jwsObject)) {
// 判断有效期,不在有效期内则直接抛出错误
JWTUser user = new JWTUser(jwsObject.getPayload().toJSONObject());
if (user.getExp() >= Calendar.getInstance().getTimeInMillis()) {
return user;
} else {
throw new JWTException("token已经超过有效期!");
}
} else {
throw new JWTException("token校验失败!");
}
} catch (Exception e) {
throw new JWTException(e);
}
}
代码示例来源:origin: com.atlassian.connect/atlassian-connect-spring-boot-jwt
JSONObject jsonPayload = jwsObject.getPayload().toJSONObject();
JWTClaimsSet claims;
代码示例来源:origin: com.atlassian.jwt/jwt-core
JSONObject jsonPayload = jwsObject.getPayload().toJSONObject();
JWTClaimsSet claims;
代码示例来源:origin: com.atlassian.jwt/jwt-core
@Nonnull
@Override
public Jwt parse(String jwt) throws JwtParseException
{
JWSObject jwsObject = parseJWSObject(jwt);
try
{
JWTClaimsSet claims = JWTClaimsSet.parse(jwsObject.getPayload().toJSONObject());
return new SimpleJwt(claims.getIssuer(), claims.getSubject(), jwsObject.getPayload().toString());
}
catch (ParseException e)
{
throw new JwtParseException(e);
}
}
代码示例来源:origin: com.atlassian.asap/asap-java
@Override
public VerifiableJwt parse(String serializedJwt) throws JwtParseException, UnsupportedAlgorithmException
{
final JWSObject jwsObject;
final JWTClaimsSet claims;
try
{
jwsObject = JWSObject.parse(serializedJwt);
validateRequiredHeaders(jwsObject);
JSONObject jsonPayload = jwsObject.getPayload().toJSONObject();
claims = JWTClaimsSet.parse(jsonPayload);
}
catch (ParseException e)
{
throw new JwtParseException(e);
}
validateRequiredClaims(claims);
return NimbusVerifiableJwt.buildVerifiableJwt(jwsObject, claims);
}
代码示例来源:origin: com.atlassian.jwt/jwt-core
public SimpleUnverifiedJwt parse(String jwt) throws JwtParseException
{
JWSObject jwsObject = parseJWSObject(jwt);
try
{
JWTClaimsSet claims = JWTClaimsSet.parse(jwsObject.getPayload().toJSONObject());
return new SimpleUnverifiedJwt(jwsObject.getHeader().getAlgorithm().getName(), claims.getIssuer(), claims.getSubject(), jwsObject.getPayload().toString());
}
catch (ParseException e)
{
throw new JwtParseException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!