/** * 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 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]); } }
/** * 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);