Search in sources :

Example 1 with AccessControlEntryFilter

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();
}
Also used : ResourceFilter(org.apache.kafka.common.resource.ResourceFilter) AclBindingFilter(org.apache.kafka.common.acl.AclBindingFilter) ArrayList(java.util.ArrayList) AccessControlEntryFilter(org.apache.kafka.common.acl.AccessControlEntryFilter)

Example 2 with AccessControlEntryFilter

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);
}
Also used : AclBindingFilter(org.apache.kafka.common.acl.AclBindingFilter) ResourcePatternFilter(org.apache.kafka.common.resource.ResourcePatternFilter) AccessControlEntryFilter(org.apache.kafka.common.acl.AccessControlEntryFilter)

Example 3 with AccessControlEntryFilter

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());
}
Also used : AclBindingFilter(org.apache.kafka.common.acl.AclBindingFilter) ResourcePatternFilter(org.apache.kafka.common.resource.ResourcePatternFilter) AccessControlEntryFilter(org.apache.kafka.common.acl.AccessControlEntryFilter) StandardAclWithIdTest(org.apache.kafka.metadata.authorizer.StandardAclWithIdTest) StandardAclTest(org.apache.kafka.metadata.authorizer.StandardAclTest) Test(org.junit.jupiter.api.Test)

Example 4 with AccessControlEntryFilter

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);
}
Also used : AclBindingFilter(org.apache.kafka.common.acl.AclBindingFilter) ResourcePatternFilter(org.apache.kafka.common.resource.ResourcePatternFilter) AccessControlEntryFilter(org.apache.kafka.common.acl.AccessControlEntryFilter)

Aggregations

AccessControlEntryFilter (org.apache.kafka.common.acl.AccessControlEntryFilter)4 AclBindingFilter (org.apache.kafka.common.acl.AclBindingFilter)4 ResourcePatternFilter (org.apache.kafka.common.resource.ResourcePatternFilter)3 ArrayList (java.util.ArrayList)1 ResourceFilter (org.apache.kafka.common.resource.ResourceFilter)1 StandardAclTest (org.apache.kafka.metadata.authorizer.StandardAclTest)1 StandardAclWithIdTest (org.apache.kafka.metadata.authorizer.StandardAclWithIdTest)1 Test (org.junit.jupiter.api.Test)1