Search in sources :

Example 1 with StandardAcl

use of org.apache.kafka.metadata.authorizer.StandardAcl in project kafka by apache.

the class AclControlManager method deleteAclsForFilter.

AclDeleteResult deleteAclsForFilter(AclBindingFilter filter, List<ApiMessageAndVersion> records) {
    List<AclBindingDeleteResult> deleted = new ArrayList<>();
    for (Entry<Uuid, StandardAcl> entry : idToAcl.entrySet()) {
        Uuid id = entry.getKey();
        StandardAcl acl = entry.getValue();
        AclBinding binding = acl.toBinding();
        if (filter.matches(binding)) {
            deleted.add(new AclBindingDeleteResult(binding));
            records.add(new ApiMessageAndVersion(new RemoveAccessControlEntryRecord().setId(id), (short) 0));
        }
    }
    return new AclDeleteResult(deleted);
}
Also used : Uuid(org.apache.kafka.common.Uuid) AclBindingDeleteResult(org.apache.kafka.server.authorizer.AclDeleteResult.AclBindingDeleteResult) ApiMessageAndVersion(org.apache.kafka.server.common.ApiMessageAndVersion) ArrayList(java.util.ArrayList) AclDeleteResult(org.apache.kafka.server.authorizer.AclDeleteResult) StandardAcl(org.apache.kafka.metadata.authorizer.StandardAcl) AclBinding(org.apache.kafka.common.acl.AclBinding) RemoveAccessControlEntryRecord(org.apache.kafka.common.metadata.RemoveAccessControlEntryRecord)

Example 2 with StandardAcl

use of org.apache.kafka.metadata.authorizer.StandardAcl 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);
}
Also used : StandardAclWithId(org.apache.kafka.metadata.authorizer.StandardAclWithId) ApiMessageAndVersion(org.apache.kafka.server.common.ApiMessageAndVersion) ArrayList(java.util.ArrayList) AclBinding(org.apache.kafka.common.acl.AclBinding) StandardAcl(org.apache.kafka.metadata.authorizer.StandardAcl) AclCreateResult(org.apache.kafka.server.authorizer.AclCreateResult) UnknownServerException(org.apache.kafka.common.errors.UnknownServerException) ApiException(org.apache.kafka.common.errors.ApiException)

Example 3 with StandardAcl

use of org.apache.kafka.metadata.authorizer.StandardAcl in project kafka by apache.

the class AclsImage method write.

public void write(Consumer<List<ApiMessageAndVersion>> out) {
    List<ApiMessageAndVersion> batch = new ArrayList<>();
    for (Entry<Uuid, StandardAcl> entry : acls.entrySet()) {
        StandardAclWithId aclWithId = new StandardAclWithId(entry.getKey(), entry.getValue());
        batch.add(new ApiMessageAndVersion(aclWithId.toRecord(), (short) 0));
    }
    out.accept(batch);
}
Also used : Uuid(org.apache.kafka.common.Uuid) StandardAclWithId(org.apache.kafka.metadata.authorizer.StandardAclWithId) ApiMessageAndVersion(org.apache.kafka.server.common.ApiMessageAndVersion) ArrayList(java.util.ArrayList) StandardAcl(org.apache.kafka.metadata.authorizer.StandardAcl)

Aggregations

ArrayList (java.util.ArrayList)3 StandardAcl (org.apache.kafka.metadata.authorizer.StandardAcl)3 ApiMessageAndVersion (org.apache.kafka.server.common.ApiMessageAndVersion)3 Uuid (org.apache.kafka.common.Uuid)2 AclBinding (org.apache.kafka.common.acl.AclBinding)2 StandardAclWithId (org.apache.kafka.metadata.authorizer.StandardAclWithId)2 ApiException (org.apache.kafka.common.errors.ApiException)1 UnknownServerException (org.apache.kafka.common.errors.UnknownServerException)1 RemoveAccessControlEntryRecord (org.apache.kafka.common.metadata.RemoveAccessControlEntryRecord)1 AclCreateResult (org.apache.kafka.server.authorizer.AclCreateResult)1 AclDeleteResult (org.apache.kafka.server.authorizer.AclDeleteResult)1 AclBindingDeleteResult (org.apache.kafka.server.authorizer.AclDeleteResult.AclBindingDeleteResult)1