Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleKafkaRequestContextRequest Context
package org.apache.kafka.common;

import java.net.InetAddress;
import org.apache.kafka.common.annotation.InterfaceStability;
import org.apache.kafka.common.security.auth.KafkaPrincipal;
import org.apache.kafka.common.security.auth.SecurityProtocol;

/**
 * Request context interface that provides data from request header as well as connection
 * and authentication information to plugins.
 */
@InterfaceStability.Evolving
public interface KafkaRequestContext {

    /**
     * Returns name of listener on which request was received.
     */
    String listenerName();

    /**
     * Returns the security protocol for the listener on which request was received.
     */
    SecurityProtocol securityProtocol();

    /**
     * Returns authenticated principal for the connection on which request was received.
     */
    KafkaPrincipal principal();

    /**
     * Returns client IP address from which request was sent.
     */
    InetAddress clientAddress();

    /**
     * Returns the request type (ApiKey) from the request header. For fetch requests,
     * the metrics names FetchFollower and FetchConsumer will be used to distinguish between
     * replica fetch requests and client fetch requests.
     */
    String requestType();

    /**
     * Returns the request version from the request header.
     */
    int requestVersion();

    /**
     * Returns the client id from the request header.
     */
    String clientId();

    /**
     * Returns the correlation id from the request header.
     */
    int correlationId();
}

...

Code Block
languagejava
titleAuthorizationModeAuthorization Mode
package org.apache.kafka.server.authorizer;

public enum AuthorizationMode {
    /**
     * Access was requested to resource. If authorization result is ALLOWED, access is granted to
     * the resource to perform the request. If DENIED, request is failed with authorization failure.
     */
    MANDATORY,

    /**
     * Access was requested to resource. If authorization result is ALLOWED, access is granted to
     * the resource to perform the request. If DENIED, alternative authorization rules are applied
     * to determine if access is allowed.
     */
    OPTIONAL,

    /**
     * Access was requested to authorized resources (e.g. to subscribe to regex pattern).
     * Request is performed on resources whose authorization result is ALLOWED and the rest of
     * the resources are filtered out.
     */
    FILTER,

    /**
     * Request to list authorized operations. No access is actually performed by this request
     * based on the authorization result.
     */
    LIST_AUTHORIZED
}

...

Code Block
languagejava
titleResult classes for authorizer operationsAuthorizer Operation Results
package org.apache.kafka.server.authorizer;

public enum AuthorizationResult {
    ALLOWED,
    DENIED
}

import org.apache.kafka.common.annotation.InterfaceStability;
@InterfaceStability.Evolving
public class AclCreateResult {
    private final Throwable exception;

    public AclCreateResult() {
        this(null);
    }

    public AclCreateResult(Throwable exception) {
        this.exception = exception;
    }

    /**
     * Returns any exception during create. If exception is null, the request has succeeded.
     */
    public Throwable exception() {
        return exception;
    }

    /**
     * Returns true if the request failed.
     */
    public boolean failed() {
        return exception != null;
    }
}

import org.apache.kafka.common.annotation.InterfaceStability;
@InterfaceStability.Evolving
public class AclDeleteResult {
    private final Throwable exception;
    private final boolean deleted;

    public AclDeleteResult(Throwable exception) {
        this(false, exception);
    }

    public AclDeleteResult(boolean deleted) {
        this(deleted, null);
    }

    private AclDeleteResult(boolean deleted, Throwable exception) {
        this.deleted = deleted;
        this.exception = exception;
    }

    /**
     * Returns any exception while attempting to delete an ACL.
     */
    public Throwable exception() {
        return exception;
    }

    /**
     * Returns true if request has failed with an exception. {@link #deleted()} indicates if
     * an ACL was deleted.
     */
    public boolean failed() {
        return exception != null;
    }

    /**
     * Returns true if a delete was performed.
     */
    public boolean deleted() {
        return deleted;
    }
}

...