Search in sources :

Example 16 with ResourcePattern

use of org.apache.kafka.common.resource.ResourcePattern in project kafka by apache.

the class DeleteAclsResponse method aclBinding.

public static AclBinding aclBinding(DeleteAclsMatchingAcl matchingAcl) {
    ResourcePattern resourcePattern = new ResourcePattern(ResourceType.fromCode(matchingAcl.resourceType()), matchingAcl.resourceName(), PatternType.fromCode(matchingAcl.patternType()));
    AccessControlEntry accessControlEntry = new AccessControlEntry(matchingAcl.principal(), matchingAcl.host(), AclOperation.fromCode(matchingAcl.operation()), AclPermissionType.fromCode(matchingAcl.permissionType()));
    return new AclBinding(resourcePattern, accessControlEntry);
}
Also used : ResourcePattern(org.apache.kafka.common.resource.ResourcePattern) AccessControlEntry(org.apache.kafka.common.acl.AccessControlEntry) AclBinding(org.apache.kafka.common.acl.AclBinding)

Example 17 with ResourcePattern

use of org.apache.kafka.common.resource.ResourcePattern in project kafka by apache.

the class DescribeAclsResponse method aclBindings.

private static Stream<AclBinding> aclBindings(DescribeAclsResource resource) {
    return resource.acls().stream().map(acl -> {
        ResourcePattern pattern = new ResourcePattern(ResourceType.fromCode(resource.resourceType()), resource.resourceName(), PatternType.fromCode(resource.patternType()));
        AccessControlEntry entry = new AccessControlEntry(acl.principal(), acl.host(), AclOperation.fromCode(acl.operation()), AclPermissionType.fromCode(acl.permissionType()));
        return new AclBinding(pattern, entry);
    });
}
Also used : ResourcePattern(org.apache.kafka.common.resource.ResourcePattern) AccessControlEntry(org.apache.kafka.common.acl.AccessControlEntry) AclBinding(org.apache.kafka.common.acl.AclBinding)

Aggregations

ResourcePattern (org.apache.kafka.common.resource.ResourcePattern)17 AccessControlEntry (org.apache.kafka.common.acl.AccessControlEntry)14 AclBinding (org.apache.kafka.common.acl.AclBinding)13 Test (org.junit.jupiter.api.Test)6 HashSet (java.util.HashSet)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Set (java.util.Set)2 VersionedAcls (kafka.security.authorizer.AclAuthorizer.VersionedAcls)2 AclEntry (kafka.security.authorizer.AclEntry)2 AclBindingFilter (org.apache.kafka.common.acl.AclBindingFilter)2 PatternType (org.apache.kafka.common.resource.PatternType)2 ResourcePatternFilter (org.apache.kafka.common.resource.ResourcePatternFilter)2 StandardAclTest (org.apache.kafka.metadata.authorizer.StandardAclTest)2 StandardAclWithIdTest (org.apache.kafka.metadata.authorizer.StandardAclWithIdTest)2 ByteBuffer (java.nio.ByteBuffer)1 Collection (java.util.Collection)1 EnumMap (java.util.EnumMap)1