use of lombok.NonNull in project testcontainers-java by testcontainers.
the class SimpleMySQLTest method performQuery.
@NonNull
protected ResultSet performQuery(MySQLContainer containerRule, String sql) throws SQLException {
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl(containerRule.getJdbcUrl());
hikariConfig.setUsername(containerRule.getUsername());
hikariConfig.setPassword(containerRule.getPassword());
HikariDataSource ds = new HikariDataSource(hikariConfig);
Statement statement = ds.getConnection().createStatement();
statement.execute(sql);
ResultSet resultSet = statement.getResultSet();
resultSet.next();
return resultSet;
}
use of lombok.NonNull in project testcontainers-java by testcontainers.
the class SimpleMariaDBTest method performQuery.
@NonNull
protected ResultSet performQuery(MariaDBContainer containerRule, String sql) throws SQLException {
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl(containerRule.getJdbcUrl());
hikariConfig.setUsername(containerRule.getUsername());
hikariConfig.setPassword(containerRule.getPassword());
HikariDataSource ds = new HikariDataSource(hikariConfig);
Statement statement = ds.getConnection().createStatement();
statement.execute(sql);
ResultSet resultSet = statement.getResultSet();
resultSet.next();
return resultSet;
}
use of lombok.NonNull in project pravega by pravega.
the class TokenVerifierImpl method verifyToken.
@Override
public JsonWebToken verifyToken(@NonNull String resource, String token, @NonNull AuthHandler.Permissions expectedLevel) throws TokenExpiredException, InvalidTokenException, InvalidClaimException, TokenException {
if (Strings.isNullOrEmpty(token)) {
throw new InvalidTokenException("Token is null or empty");
}
// All key value pairs inside the payload are returned, including standard fields such as sub (for subject),
// aud (for audience), iat, exp, as well as custom fields of the form "<resource> -> <permission>" set by
// Pravega.
JsonWebToken jwt = JwtParser.parse(token, tokenSigningKey);
Map<String, Object> permissionsByResource = jwt.getPermissionsByResource();
Optional<Map.Entry<String, Object>> matchingClaim = permissionsByResource.entrySet().stream().filter(entry -> resourceMatchesClaimKey(entry.getKey(), resource) && expectedLevel.compareTo(AuthHandler.Permissions.valueOf(entry.getValue().toString())) <= 0).findFirst();
if (!matchingClaim.isPresent()) {
log.debug(String.format("No matching claim found for resource [%s] and permission [%s] in token.", resource, expectedLevel));
throw new InvalidClaimException(String.format("No matching claim found for resource: [%s] and permission: [%s] in the delegation token.", resource, expectedLevel));
}
return jwt;
}
use of lombok.NonNull in project pravega by pravega.
the class FixedKeyLengthTableSegmentLayout method get.
@Override
CompletableFuture<List<TableEntry>> get(@NonNull DirectSegmentAccess segment, @NonNull List<BufferView> keys, TimeoutTimer timer) {
val segmentInfo = segment.getInfo();
ensureSegmentType(segmentInfo.getName(), segmentInfo.getType());
val attributes = keys.stream().map(key -> {
ensureValidKeyLength(segmentInfo.getName(), key.getLength());
return AttributeId.from(key.getCopy());
}).collect(Collectors.toList());
logRequest("get", segmentInfo.getName(), keys.size());
return getByAttributes(segment, attributes, timer);
}
use of lombok.NonNull in project pravega by pravega.
the class HashTableSegmentLayout method entryDeltaIterator.
@Override
AsyncIterator<IteratorItem<TableEntry>> entryDeltaIterator(@NonNull DirectSegmentAccess segment, long fromPosition, Duration fetchTimeout) {
val segmentInfo = segment.getInfo();
ensureSegmentType(segmentInfo.getName(), segmentInfo.getType());
Preconditions.checkArgument(fromPosition <= segmentInfo.getLength(), "fromPosition (%s) can not exceed the length (%s) of the TableSegment.", fromPosition, segmentInfo.getLength());
logRequest("entryDeltaIterator", segment.getSegmentId(), fromPosition);
long compactionOffset = segmentInfo.getAttributes().getOrDefault(TableAttributes.COMPACTION_OFFSET, 0L);
// All of the most recent keys will exist beyond the compactionOffset.
long startOffset = Math.max(fromPosition, compactionOffset);
// We should clear if the starting position may have been truncated out due to compaction.
boolean shouldClear = fromPosition < compactionOffset;
// Maximum length of the TableSegment we want to read until.
int maxBytesToRead = (int) (segmentInfo.getLength() - startOffset);
TableEntryDeltaIterator.ConvertResult<IteratorItem<TableEntry>> converter = item -> CompletableFuture.completedFuture(new IteratorItemImpl<TableEntry>(item.getKey().serialize(), Collections.singletonList(item.getValue())));
return TableEntryDeltaIterator.<IteratorItem<TableEntry>>builder().segment(segment).entrySerializer(serializer).executor(executor).maxBytesToRead(maxBytesToRead).startOffset(startOffset).currentBatchOffset(fromPosition).fetchTimeout(fetchTimeout).resultConverter(converter).shouldClear(shouldClear).build();
}
Aggregations