im.toss.http.parser.Rfc7230TokenValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http-auth-parser Show documentation
Show all versions of http-auth-parser Show documentation
HTTP Authorization header parser
The newest version!
package im.toss.http.parser;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Validates a token
*
* @see Section 3.2.6 of RFC 7230
*/
class Rfc7230TokenValidator extends AbstractTokenValidator {
/**
* Validates a token
*
* @param token a token. Must not be null.
* @throws TokenValidationException if the token is not valid
* @see Section 3.2.6 of RFC 7230
*/
@Override
public void validate(String token) {
Pattern p = Pattern.compile("[^-A-Za-z0-9!#$%&'*+.^_`|~ \"\\\\]");
Matcher matcher = p.matcher(token);
if (matcher.find()) {
throw new TokenValidationException(unexpectedCharacterError(matcher.group(),
matcher.start()));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy