replace TokenClaimsValidator with not so generic AccessTokenValidator interface and fixed duplicated code of BearerRealm and JwtAccessTokenResolve

This commit is contained in:
Sebastian Sdorra
2018-12-21 08:35:18 +01:00
parent 46d6e88530
commit ac4a57f2f3
9 changed files with 187 additions and 421 deletions

View File

@@ -30,26 +30,25 @@
*/
package sonia.scm.security;
import java.util.Map;
import sonia.scm.plugin.ExtensionPoint;
/**
* Validates the claims of a jwt token. The validator is called durring authentication
* with a jwt token.
* Validates an {@link AccessToken}. The validator is called during authentication
* with an {@link AccessToken}.
*
* @author Sebastian Sdorra
* @since 2.0.0
*/
@ExtensionPoint
public interface TokenClaimsValidator {
public interface AccessTokenValidator {
/**
* Returns {@code true} if the claims is valid. If the token is not valid and the
* Returns {@code true} if the {@link AccessToken} is valid. If the token is not valid and the
* method returns {@code false}, the authentication is treated as failed.
*
* @param claims token claims
* @param token the access token to verify
*
* @return {@code true} if the claims is valid
* @return {@code true} if the token is valid
*/
boolean validate(Map<String, Object> claims);
boolean validate(AccessToken token);
}