use of org.apache.kafka.common.acl.AclBinding in project kafka by apache.
the class AclControlManager method createAcls.
ControllerResult<List<AclCreateResult>> createAcls(List<AclBinding> acls) {
List<AclCreateResult> results = new ArrayList<>(acls.size());
List<ApiMessageAndVersion> records = new ArrayList<>(acls.size());
for (AclBinding acl : acls) {
try {
validateNewAcl(acl);
} catch (Throwable t) {
ApiException e = (t instanceof ApiException) ? (ApiException) t : new UnknownServerException("Unknown error while trying to create ACL", t);
results.add(new AclCreateResult(e));
continue;
}
StandardAcl standardAcl = StandardAcl.fromAclBinding(acl);
if (existingAcls.add(standardAcl)) {
StandardAclWithId standardAclWithId = new StandardAclWithId(newAclId(), standardAcl);
idToAcl.put(standardAclWithId.id(), standardAcl);
records.add(new ApiMessageAndVersion(standardAclWithId.toRecord(), (short) 0));
}
results.add(AclCreateResult.SUCCESS);
}
return new ControllerResult<>(records, results, true);
}
use of org.apache.kafka.common.acl.AclBinding 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);
}
use of org.apache.kafka.common.acl.AclBinding 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);
});
}
Aggregations