JWTClaimsSet claims = new JWTClaimsSet.Builder(JWTClaimsSet.parse(writer.toString())) .audience(Lists.newArrayList(client.getClientId())) .issuer(config.getIssuer())
/** * Parses a JSON Web Token (JWT) claims set from the specified JSON * object string representation. * * @param s The JSON object string to parse. Must not be {@code null}. * * @return The JWT claims set. * * @throws ParseException If the specified JSON object string doesn't * represent a valid JWT claims set. */ public static JWTClaimsSet parse(final String s) throws ParseException { return parse(JSONObjectUtils.parse(s)); } }
@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); }
@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); }
@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); }
/** * 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!"); } }
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); } }
claims = JWTClaimsSet.parse(jsonPayload); } catch (ParseException e) {
@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); } }
claims = JWTClaimsSet.parse(jsonPayload);
@Test(groups = TCKConstants.TEST_GROUP_DEBUG, description = "Validate how to use the HS256 signature alg") public void testHS256() throws Exception { JWTClaimsSet claimsSet = JWTClaimsSet.parse("{\"sub\":\"jdoe\"}"); SignedJWT signedJWT = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claimsSet); SecureRandom random = new SecureRandom(); BigInteger secret = BigInteger.probablePrime(256, random); JWSSigner signer = new MACSigner(secret.toByteArray()); signedJWT.sign(signer); }
JWTClaimsSet claimsSet = JWTClaimsSet.parse(jwtContent); JWSAlgorithm alg = JWSAlgorithm.RS256; if(invalidClaims.contains(InvalidClaims.ALG)) {
@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); }
JWTClaimsSet claims = new JWTClaimsSet.Builder(JWTClaimsSet.parse(writer.toString())) .audience(Lists.newArrayList(client.getClientId())) .issuer(config.getIssuer())
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); } }