Class UnixDomainAgentProfilePolicy
- All Implemented Interfaces:
Serializable, EventListener, org.snmp4j.agent.audit.AgentAuditPolicy, org.snmp4j.agent.audit.FileAuditListener, org.snmp4j.agent.MOServerLookupListener, org.snmp4j.transport.TransportAuditListener
UnixDomainAgentProfilePolicy extends the DefaultAgentAuditPolicy by support for the
"unix" address domain of UnixDomainAddress.
A Unix domain socket operation is always local, so the AgentPolicyProfile.NetworkAccess
restrictions of the policy profile - which are based on the comparison of InetAddress
instances and therefore not applicable to a socket file path - are not evaluated for such an operation.
The file system operations that are necessary for a Unix domain socket operation are checked instead:
the socket's (local) file path is matched against the allowed files and directories of the
AgentPolicyProfile exactly like any other file access audited through
DefaultAgentAuditPolicy.fileAudit(FileAuditEvent). The audited transport operation is mapped to the file operation it
implies:
TransportAuditEvent.TransportOperation.LISTEN:FileAuditEvent.FileOperation.CREATEof the local socket file, because binding a Unix domain server socket creates that file.TransportAuditEvent.TransportOperation.CLOSE:FileAuditEvent.FileOperation.DELETEof the local socket file, because closing the transport removes that file.TransportAuditEvent.TransportOperation.SEND:FileAuditEvent.FileOperation.WRITEof the peer's socket file.TransportAuditEvent.TransportOperation.RECEIVE:FileAuditEvent.FileOperation.READof the peer's socket file.
SEND and RECEIVE the local socket file is checked instead of the peer's file if the
peer socket is unnamed (auto-bound), which is the regular case for an accepted client connection.
Transport operations of any other address domain are audited by DefaultAgentAuditPolicy
unchanged, thus this policy can be used for an agent that serves Unix domain sockets and IP transports
at the same time.
Like its superclass, this policy denies a violating operation only on audit level
AgentAuditLevel.RESTRICT.
- Since:
- 1.2.2
- Version:
- 1.2.2
- Author:
- Frank Fock
- See Also:
-
Field Summary
Fields inherited from class org.snmp4j.agent.audit.DefaultAgentAuditPolicy
CONFIDENTIAL, DEFAULT, LOG, OFF, TEST, WARN -
Constructor Summary
ConstructorsConstructorDescriptionUnixDomainAgentProfilePolicy(org.snmp4j.agent.audit.AgentPolicyProfile agentPolicyProfile, org.snmp4j.agent.audit.AgentAuditLevel auditLevel) Creates aUnixDomainAgentProfilePolicythat logs audit records through theLogFactorylogging only.UnixDomainAgentProfilePolicy(org.snmp4j.agent.audit.AgentPolicyProfile agentPolicyProfile, org.snmp4j.agent.audit.AgentAuditLevel auditLevel, OutputStream auditOutputStream) Creates aUnixDomainAgentProfilePolicythat logs audit records through theLogFactorylogging and, in addition, writes a copy of every audit record to the suppliedOutputStream. -
Method Summary
Modifier and TypeMethodDescriptionprotected UnixDomainAddressgetAuditedSocketAddress(org.snmp4j.transport.TransportAuditEvent event) Determines the Unix domain address whose socket file is accessed by the audited transport operation.protected org.snmp4j.agent.audit.FileAuditEvent.FileOperationgetImpliedFileOperation(org.snmp4j.transport.TransportAuditEvent.TransportOperation transportOperation) Maps an audited transport operation to the file operation it implies on the socket file of a Unix domain socket.protected static booleanhasSocketFile(UnixDomainAddress address) Checks whether the supplied Unix domain address refers to a named socket, i.e. a socket that has a path in the file system.protected booleanisSocketFileAccessAllowed(org.snmp4j.transport.TransportAuditEvent event, UnixDomainAddress socketAddress) Checks whether the file access that the audited Unix domain socket operation needs on the socket file of the supplied address is permitted by theAgentPolicyProfile.protected booleanisTransportOperationAllowed(org.snmp4j.transport.TransportAuditEvent event) Evaluates whether the supplied transport operation is permitted by theAgentPolicyProfile.Methods inherited from class org.snmp4j.agent.audit.DefaultAgentAuditPolicy
fileAudit, getAgentPolicyProfile, getAuditLevel, isFileOperationAllowed, isManagedObjectAccessAllowed, logDecision, lookupEvent, queryEvent, setAuditOutputStream, transportAuditMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.snmp4j.agent.audit.AgentAuditPolicy
isAuditEnabledMethods inherited from interface org.snmp4j.agent.MOServerLookupListener
completedUse
-
Constructor Details
-
UnixDomainAgentProfilePolicy
public UnixDomainAgentProfilePolicy(org.snmp4j.agent.audit.AgentPolicyProfile agentPolicyProfile, org.snmp4j.agent.audit.AgentAuditLevel auditLevel) Creates aUnixDomainAgentProfilePolicythat logs audit records through theLogFactorylogging only.- Parameters:
agentPolicyProfile- the policy profile that defines the access restrictions to enforce, ornullto permit all operations (audit only).auditLevel- the audit level to apply, ornullwhich is interpreted asAgentAuditLevel.OFF.
-
UnixDomainAgentProfilePolicy
public UnixDomainAgentProfilePolicy(org.snmp4j.agent.audit.AgentPolicyProfile agentPolicyProfile, org.snmp4j.agent.audit.AgentAuditLevel auditLevel, OutputStream auditOutputStream) Creates aUnixDomainAgentProfilePolicythat logs audit records through theLogFactorylogging and, in addition, writes a copy of every audit record to the suppliedOutputStream.- Parameters:
agentPolicyProfile- the policy profile that defines the access restrictions to enforce, ornullto permit all operations (audit only).auditLevel- the audit level to apply, ornullwhich is interpreted asAgentAuditLevel.OFF.auditOutputStream- an optional output stream that receives a copy of every audit record (for example aFileOutputStream,System.outorSystem.err), ornullfor logging throughLogFactoryonly.
-
-
Method Details
-
isTransportOperationAllowed
protected boolean isTransportOperationAllowed(org.snmp4j.transport.TransportAuditEvent event) Evaluates whether the supplied transport operation is permitted by theAgentPolicyProfile. A Unix domain socket operation is evaluated by checking the socket file it operates on against the allowed files and directories of the policy profile (seeisSocketFileAccessAllowed(TransportAuditEvent, UnixDomainAddress)), any other operation is evaluated byDefaultAgentAuditPolicy.- Overrides:
isTransportOperationAllowedin classorg.snmp4j.agent.audit.DefaultAgentAuditPolicy- Parameters:
event- the transport audit event to evaluate.- Returns:
trueif the operation is permitted by the policy profile,falseotherwise.
-
isSocketFileAccessAllowed
protected boolean isSocketFileAccessAllowed(org.snmp4j.transport.TransportAuditEvent event, UnixDomainAddress socketAddress) Checks whether the file access that the audited Unix domain socket operation needs on the socket file of the supplied address is permitted by theAgentPolicyProfile. The check is delegated toDefaultAgentAuditPolicy.isFileOperationAllowed(FileAuditEvent)with the file operation returned bygetImpliedFileOperation(TransportAuditEvent.TransportOperation), so the same allowed files and directories apply as for any other file access of the agent.- Parameters:
event- the audited transport event.socketAddress- the Unix domain address whose socket file is accessed by the audited operation.- Returns:
trueif the implied file operation is permitted by the policy profile,falseotherwise.
-
getAuditedSocketAddress
Determines the Unix domain address whose socket file is accessed by the audited transport operation.- Parameters:
event- the audited transport event.- Returns:
- the local
UnixDomainAddressforTransportAuditEvent.TransportOperation.LISTENandTransportAuditEvent.TransportOperation.CLOSE, the peer address forTransportAuditEvent.TransportOperation.SENDandTransportAuditEvent.TransportOperation.RECEIVEunless its socket is unnamed (then the local address is returned), ornullif neither the peer nor the local address of the event is aUnixDomainAddress(i.e. the event does not refer to a Unix domain socket).
-
getImpliedFileOperation
protected org.snmp4j.agent.audit.FileAuditEvent.FileOperation getImpliedFileOperation(org.snmp4j.transport.TransportAuditEvent.TransportOperation transportOperation) Maps an audited transport operation to the file operation it implies on the socket file of a Unix domain socket.- Parameters:
transportOperation- the audited transport operation.- Returns:
FileAuditEvent.FileOperation.CREATEforLISTEN(binding creates the socket file),FileAuditEvent.FileOperation.DELETEforCLOSE(closing removes the socket file),FileAuditEvent.FileOperation.WRITEforSEND, andFileAuditEvent.FileOperation.READforRECEIVE.
-
hasSocketFile
Checks whether the supplied Unix domain address refers to a named socket, i.e. a socket that has a path in the file system.- Parameters:
address- a Unix domain address ornull.- Returns:
trueifaddresshas a non-empty socket file path,falseotherwise.
-