@Override public Payload process(final String compactJOSE, final C context) throws ParseException, BadJOSEException, JOSEException { return process(JOSEObject.parse(compactJOSE), context); }
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(); }
/** * Parses a signed JSON Web Token (JWT) from the specified string in * compact format. * * @param s The string to parse. Must not be {@code null}. * * @return The signed JWT. * * @throws ParseException If the string couldn't be parsed to a valid * signed JWT. */ public static SignedJWT parse(final String s) throws ParseException { Base64URL[] parts = JOSEObject.split(s); if (parts.length != 3) { throw new ParseException("Unexpected number of Base64URL parts, must be three", 0); } return new SignedJWT(parts[0], parts[1], parts[2]); } }
private void setRequestObjectValues(String requestObjectString, RequestObject requestObjectInstance) throws RequestObjectException { try { JOSEObject jwt = JOSEObject.parse(requestObjectString); if (jwt.getHeader().getAlgorithm() == null || jwt.getHeader().getAlgorithm().equals(JWSAlgorithm.NONE)) { requestObjectInstance.setPlainJWT(PlainJWT.parse(requestObjectString)); } else { requestObjectInstance.setSignedJWT(SignedJWT.parse(requestObjectString)); } } catch (ParseException e) { String errorMessage = "No Valid JWT is found for the Request Object."; if (log.isDebugEnabled()) { log.debug(errorMessage + "Received Request Object: " + requestObjectString, e); } throw new RequestObjectException(OAuth2ErrorCodes.INVALID_REQUEST, errorMessage); } }
if (algs != null && ! algs.contains(joseObject.getHeader().getAlgorithm())) return false;
/** * Parses a JWS object from the specified string in compact format. The * parsed JWS object will be given a {@link State#SIGNED} state. * * @param s The string to parse. Must not be {@code null}. * * @return The JWS object. * * @throws ParseException If the string couldn't be parsed to a valid * JWS object. */ public static JWSObject parse(final String s) throws ParseException { Base64URL[] parts = JOSEObject.split(s); if (parts.length != 3) { throw new ParseException("Unexpected number of Base64URL parts, must be three", 0); } return new JWSObject(parts[0], parts[1], parts[2]); } }
/** * Parses an encrypted JSON Web Token (JWT) from the specified string in * compact format. * * @param s The string to parse. Must not be {@code null}. * * @return The encrypted JWT. * * @throws ParseException If the string couldn't be parsed to a valid * encrypted JWT. */ public static EncryptedJWT parse(final String s) throws ParseException { Base64URL[] parts = JOSEObject.split(s); if (parts.length != 5) { throw new ParseException("Unexpected number of Base64URL parts, must be five", 0); } return new EncryptedJWT(parts[0], parts[1], parts[2], parts[3], parts[4]); } }
/** * Parses a JWE object from the specified string in compact form. The * parsed JWE object will be given an {@link State#ENCRYPTED} state. * * @param s The string to parse. Must not be {@code null}. * * @return The JWE object. * * @throws ParseException If the string couldn't be parsed to a valid * JWE object. */ public static JWEObject parse(final String s) throws ParseException { Base64URL[] parts = JOSEObject.split(s); if (parts.length != 5) { throw new ParseException("Unexpected number of Base64URL parts, must be five", 0); } return new JWEObject(parts[0], parts[1], parts[2], parts[3], parts[4]); } }
/** * Parses an unsecured (plain) JSON Web Token (JWT) from the specified * string in compact format. * * @param s The string to parse. Must not be {@code null}. * * @return The unsecured JWT. * * @throws ParseException If the string couldn't be parsed to a valid * unsecured JWT. */ public static PlainJWT parse(final String s) throws ParseException { Base64URL[] parts = JOSEObject.split(s); if (! parts[2].toString().isEmpty()) { throw new ParseException("Unexpected third Base64URL part in the unsecured JWT object", 0); } return new PlainJWT(parts[0], parts[1]); } }
/** * Parses an unsecured JOSE object from the specified string in compact * format. * * @param s The string to parse. Must not be {@code null}. * * @return The unsecured JOSE object. * * @throws ParseException If the string couldn't be parsed to a valid * unsecured JOSE object. */ public static PlainObject parse(final String s) throws ParseException { Base64URL[] parts = JOSEObject.split(s); if (! parts[2].toString().isEmpty()) { throw new ParseException("Unexpected third Base64URL part", 0); } return new PlainObject(parts[0], parts[1]); } }
throws ParseException { Base64URL[] parts = split(s);