use of tech.aroma.thrift.authentication.AuthenticationToken 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;
}
use of tech.aroma.thrift.authentication.AuthenticationToken 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);
}
use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class MappersTest method testAuthenticationTokenMapper.
@Test
public void testAuthenticationTokenMapper() throws Exception {
Function<Row, AuthenticationToken> mapper = Mappers.tokenMapper();
assertThat(mapper, notNullValue());
token.unsetOrganizationName();
Row tokenRow = rowFor(token);
AuthenticationToken result = mapper.apply(tokenRow);
assertThat(result, is(token));
}
use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class CassandraTokenRepository method createStatementToDeleteToken.
private Statement createStatementToDeleteToken(String tokenId) throws TException {
UUID tokenUuid = UUID.fromString(tokenId);
// Need to get Token first
AuthenticationToken token = this.getToken(tokenId);
UUID ownerUuid = UUID.fromString(token.ownerId);
BatchStatement batch = new BatchStatement();
Statement deleteFromMainTable = QueryBuilder.delete().all().from(Tokens.TABLE_NAME).where(eq(TOKEN_ID, tokenUuid));
batch.add(deleteFromMainTable);
Statement deleteFromOwnersTable = QueryBuilder.delete().all().from(Tokens.TABLE_NAME_BY_OWNER).where(eq(OWNER_ID, ownerUuid));
batch.add(deleteFromOwnersTable);
return batch;
}
use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class MemoryTokenRepository method expired.
@Override
public void expired(String key, AuthenticationToken value) {
String ownerId = value.ownerId;
if (isNullOrEmpty(ownerId)) {
return;
}
synchronized (tokens) {
this.deleteTokenFromOwner(value);
List<AuthenticationToken> ownerTokens = this.tokensByOwner.getOrDefault(value.ownerId, Lists.emptyList());
if (!Lists.isEmpty(ownerTokens)) {
tokensByOwner.remove(ownerId);
}
}
}
Aggregations