Search in sources :

Example 1 with InvalidTokenException

use of tech.aroma.thrift.exceptions.InvalidTokenException in project aroma-data-operations by RedRoma.

the class CassandraTokenRepository method tryToConvertRowToToken.

private AuthenticationToken tryToConvertRowToToken(Row row) throws OperationFailedException, InvalidTokenException {
    AuthenticationToken token;
    try {
        token = tokenMapper.apply(row);
    } catch (Exception ex) {
        LOG.error("Could not map Row {} to Token", row, ex);
        throw new OperationFailedException("Failed to query for Token: " + ex.getMessage());
    }
    checkThat(token).throwing(InvalidTokenException.class).is(completeToken());
    return token;
}
Also used : InvalidTokenException(tech.aroma.thrift.exceptions.InvalidTokenException) AuthenticationToken(tech.aroma.thrift.authentication.AuthenticationToken) OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) InvalidTokenException(tech.aroma.thrift.exceptions.InvalidTokenException) TException(org.apache.thrift.TException) InvalidArgumentException(tech.aroma.thrift.exceptions.InvalidArgumentException) OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException)

Example 2 with InvalidTokenException

use of tech.aroma.thrift.exceptions.InvalidTokenException in project aroma-data-operations by RedRoma.

the class TokenRepository method doesTokenBelongTo.

default boolean doesTokenBelongTo(@NonEmpty String tokenId, @NonEmpty String ownerId) throws InvalidTokenException, TException {
    checkThat(tokenId, ownerId).throwing(InvalidArgumentException.class).usingMessage("tokenId and ownerId are required").are(nonEmptyString());
    AuthenticationToken token = this.getToken(tokenId);
    checkThat(token).throwing(InvalidTokenException.class).is(tokenContainingOwnerId());
    return Objects.equals(ownerId, token.ownerId);
}
Also used : InvalidTokenException(tech.aroma.thrift.exceptions.InvalidTokenException) AuthenticationToken(tech.aroma.thrift.authentication.AuthenticationToken)

Aggregations

AuthenticationToken (tech.aroma.thrift.authentication.AuthenticationToken)2 InvalidTokenException (tech.aroma.thrift.exceptions.InvalidTokenException)2 TException (org.apache.thrift.TException)1 InvalidArgumentException (tech.aroma.thrift.exceptions.InvalidArgumentException)1 OperationFailedException (tech.aroma.thrift.exceptions.OperationFailedException)1