use of org.apache.kafka.common.acl.AccessControlEntryFilter in project apache-kafka-on-k8s by banzaicloud.
the class RequestResponseTest method createDeleteAclsRequest.
private DeleteAclsRequest createDeleteAclsRequest() {
List<AclBindingFilter> filters = new ArrayList<>();
filters.add(new AclBindingFilter(new ResourceFilter(ResourceType.ANY, null), new AccessControlEntryFilter("User:ANONYMOUS", null, AclOperation.ANY, AclPermissionType.ANY)));
filters.add(new AclBindingFilter(new ResourceFilter(ResourceType.ANY, null), new AccessControlEntryFilter("User:bob", null, AclOperation.ANY, AclPermissionType.ANY)));
return new DeleteAclsRequest.Builder(filters).build();
}
use of org.apache.kafka.common.acl.AccessControlEntryFilter in project kafka by apache.
the class DeleteAclsRequest method aclBindingFilter.
private static AclBindingFilter aclBindingFilter(DeleteAclsFilter filter) {
ResourcePatternFilter patternFilter = new ResourcePatternFilter(ResourceType.fromCode(filter.resourceTypeFilter()), filter.resourceNameFilter(), PatternType.fromCode(filter.patternTypeFilter()));
AccessControlEntryFilter entryFilter = new AccessControlEntryFilter(filter.principalFilter(), filter.hostFilter(), AclOperation.fromCode(filter.operation()), AclPermissionType.fromCode(filter.permissionType()));
return new AclBindingFilter(patternFilter, entryFilter);
}
use of org.apache.kafka.common.acl.AccessControlEntryFilter in project kafka by apache.
the class AclControlManagerTest method testValidateFilter.
/**
* Verify that validateFilter catches invalid filters.
*/
@Test
public void testValidateFilter() {
AclControlManager.validateFilter(new AclBindingFilter(new ResourcePatternFilter(ResourceType.ANY, "*", LITERAL), new AccessControlEntryFilter("User:*", "*", AclOperation.ANY, AclPermissionType.ANY)));
assertEquals("Unknown patternFilter.", assertThrows(InvalidRequestException.class, () -> AclControlManager.validateFilter(new AclBindingFilter(new ResourcePatternFilter(ResourceType.ANY, "*", PatternType.UNKNOWN), new AccessControlEntryFilter("User:*", "*", AclOperation.ANY, AclPermissionType.ANY)))).getMessage());
assertEquals("Unknown entryFilter.", assertThrows(InvalidRequestException.class, () -> AclControlManager.validateFilter(new AclBindingFilter(new ResourcePatternFilter(ResourceType.ANY, "*", MATCH), new AccessControlEntryFilter("User:*", "*", AclOperation.ANY, AclPermissionType.UNKNOWN)))).getMessage());
}
use of org.apache.kafka.common.acl.AccessControlEntryFilter in project kafka by apache.
the class DescribeAclsRequest method filter.
public AclBindingFilter filter() {
ResourcePatternFilter rpf = new ResourcePatternFilter(ResourceType.fromCode(data.resourceTypeFilter()), data.resourceNameFilter(), PatternType.fromCode(data.patternTypeFilter()));
AccessControlEntryFilter acef = new AccessControlEntryFilter(data.principalFilter(), data.hostFilter(), AclOperation.fromCode(data.operation()), AclPermissionType.fromCode(data.permissionType()));
return new AclBindingFilter(rpf, acef);
}
Aggregations