/*_############################################################################
  _##
  _##  SNMP4J-Agent 3 - FileAuditListener.java
  _##
  _##  Copyright (C) 2005-2026  Frank Fock (SNMP4J.org)
  _##
  _##  Licensed under the Apache License, Version 2.0 (the "License");
  _##  you may not use this file except in compliance with the License.
  _##  You may obtain a copy of the License at
  _##
  _##      http://www.apache.org/licenses/LICENSE-2.0
  _##
  _##  Unless required by applicable law or agreed to in writing, software
  _##  distributed under the License is distributed on an "AS IS" BASIS,
  _##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  _##  See the License for the specific language governing permissions and
  _##  limitations under the License.
  _##
  _##########################################################################*/

package org.snmp4j.agent.audit;

import java.util.EventListener;

/**
 * The {@code FileAuditListener} interface is implemented by objects that want to monitor and
 * optionally prevent file system access (read, write, create and delete) within the SNMP4J-Agent.
 * Implementations are notified before a file is read, written, created or deleted through the single
 * {@link #fileAudit(FileAuditEvent)} method.
 * <p>
 * The {@link #fileAudit(FileAuditEvent)} method acts both as an authorization hook and as an audit
 * hook: returning {@code false} denies (prevents) the corresponding file access, while returning
 * {@code true} allows it. Implementations may additionally write the audited {@link FileAuditEvent}
 * to a dedicated audit log.
 * <p>
 * This interface is the file system equivalent of the
 * {@link org.snmp4j.transport.TransportAuditListener} used for transport level auditing.
 *
 * @author Frank Fock
 * @version 3.12.0
 * @since 3.12.0
 */
public interface FileAuditListener extends EventListener {

    /**
     * Audits a file system operation described by the provided {@link FileAuditEvent} and decides
     * whether the operation is permitted.
     *
     * @param event
     *    the {@link FileAuditEvent} describing the file operation to be audited.
     * @return
     *    {@code true} if the operation is permitted, {@code false} to deny (prevent) it. The return
     *    value is ignored for {@link FileAuditEvent.FileOperation#DELETE} events that report an
     *    already executed deletion.
     */
    boolean fileAudit(FileAuditEvent event);
}
