Class SimpleAccessControlSftpEventListener
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
-
- org.apache.sshd.contrib.server.subsystem.sftp.SimpleAccessControlSftpEventListener
-
- All Implemented Interfaces:
java.util.EventListener,SshdEventListener,SftpEventListener
public abstract class SimpleAccessControlSftpEventListener extends AbstractSftpEventListenerAdapter
Provides a simple access control by making a distinction between methods that provide information - including reading data - and those that modify it
-
-
Field Summary
Fields Modifier and Type Field Description static SimpleAccessControlSftpEventListenerREAD_ONLY_ACCESSOR-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleAccessControlSftpEventListener()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidblocking(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length, int mask)Called prior to blocking a file sectionvoidcreating(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs)Called prior to creating a directoryprotected abstract booleanisAccessAllowed(ServerSession session, java.lang.String remoteHandle, java.nio.file.Path localPath)protected booleanisAccessAllowed(ServerSession session, java.lang.String remoteHandle, Handle localHandle)protected abstract booleanisModificationAllowed(ServerSession session, java.lang.String remoteHandle, java.nio.file.Path localPath)voidlinking(ServerSession session, java.nio.file.Path source, java.nio.file.Path target, boolean symLink)Called prior to creating a linkvoidmodifyingAttributes(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs)Called prior to modifying the attributes of a file / directoryvoidmoving(ServerSession session, java.nio.file.Path srcPath, java.nio.file.Path dstPath, java.util.Collection<java.nio.file.CopyOption> opts)Called prior to renaming a file / directoryvoidopening(ServerSession session, java.lang.String remoteHandle, Handle localHandle)Specified file / directory is being openedvoidreadEntries(ServerSession session, java.lang.String remoteHandle, DirectoryHandle localHandle, java.util.Map<java.lang.String,java.nio.file.Path> entries)Result of reading entries from a directory - Note: it may be a partial result if the directory contains more entries than can be accommodated in the responsevoidreading(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen)Preparing to read from a filevoidremoved(ServerSession session, java.nio.file.Path path, boolean isDirectory, java.lang.Throwable thrown)Called after a file has been removedvoidremoving(ServerSession session, java.nio.file.Path path, boolean isDirectory)Called prior to removing a filevoidunblocking(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length)Called prior to un-blocking a file sectionvoidwriting(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen)Preparing to write to file-
Methods inherited from class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
blocked, closed, closing, created, destroying, exiting, initialized, linked, modifiedAttributes, moved, open, openFailed, read, readingEntries, receivedExtension, unblocked, written
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.sftp.server.SftpEventListener
received
-
-
-
-
Field Detail
-
READ_ONLY_ACCESSOR
public static final SimpleAccessControlSftpEventListener READ_ONLY_ACCESSOR
-
-
Method Detail
-
opening
public void opening(ServerSession session, java.lang.String remoteHandle, Handle localHandle) throws java.io.IOException
Description copied from interface:SftpEventListenerSpecified file / directory is being opened- Specified by:
openingin interfaceSftpEventListener- Overrides:
openingin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the file / directorylocalHandle- The associated file / directoryHandle- Throws:
java.io.IOException- If failed to handle the call
-
readEntries
public void readEntries(ServerSession session, java.lang.String remoteHandle, DirectoryHandle localHandle, java.util.Map<java.lang.String,java.nio.file.Path> entries) throws java.io.IOException
Description copied from interface:SftpEventListenerResult of reading entries from a directory - Note: it may be a partial result if the directory contains more entries than can be accommodated in the response- Specified by:
readEntriesin interfaceSftpEventListener- Overrides:
readEntriesin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the directorylocalHandle- The associatedDirectoryHandleentries- AMapof the listed entries - key = short name, value =Pathof the sub-entry- Throws:
java.io.IOException- If failed to handle the call
-
reading
public void reading(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) throws java.io.IOException
Description copied from interface:SftpEventListenerPreparing to read from a file- Specified by:
readingin interfaceSftpEventListener- Overrides:
readingin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file from which to readdata- Buffer holding the read datadataOffset- Offset of read data in bufferdataLen- Requested read length- Throws:
java.io.IOException- If failed to handle the call
-
isAccessAllowed
protected boolean isAccessAllowed(ServerSession session, java.lang.String remoteHandle, Handle localHandle) throws java.io.IOException
- Parameters:
session- TheServerSessionthrow which the request was maderemoteHandle- The remote handle valuelocalHandle- The local handle- Returns:
trueif allowed to access the handle- Throws:
java.io.IOException- If failed to handle the call
-
isAccessAllowed
protected abstract boolean isAccessAllowed(ServerSession session, java.lang.String remoteHandle, java.nio.file.Path localPath) throws java.io.IOException
- Parameters:
session- TheServerSessionthrow which the request was maderemoteHandle- The remote handle valuelocalPath- The localPath- Returns:
trueif allowed to access the path- Throws:
java.io.IOException- If failed to handle the call
-
writing
public void writing(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) throws java.io.IOException
Description copied from interface:SftpEventListenerPreparing to write to file- Specified by:
writingin interfaceSftpEventListener- Overrides:
writingin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file to which to writedata- Buffer holding the written datadataOffset- Offset of write data in bufferdataLen- Requested write length- Throws:
java.io.IOException- If failed to handle the call
-
blocking
public void blocking(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length, int mask) throws java.io.IOException
Description copied from interface:SftpEventListenerCalled prior to blocking a file section- Specified by:
blockingin interfaceSftpEventListener- Overrides:
blockingin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file for lockinglength- Section size for lockingmask- Lock mask flags - seeSSH_FXP_BLOCKmessage- Throws:
java.io.IOException- If failed to handle the call- See Also:
SftpEventListener.blocked(ServerSession, String, FileHandle, long, long, int, Throwable)
-
unblocking
public void unblocking(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length) throws java.io.IOException
Description copied from interface:SftpEventListenerCalled prior to un-blocking a file section- Specified by:
unblockingin interfaceSftpEventListener- Overrides:
unblockingin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file for un-lockinglength- Section size for un-locking- Throws:
java.io.IOException- If failed to handle the call
-
creating
public void creating(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs) throws java.io.IOException
Description copied from interface:SftpEventListenerCalled prior to creating a directory- Specified by:
creatingin interfaceSftpEventListener- Overrides:
creatingin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledpath- DirectoryPathto be createdattrs- Requested associated attributes to set- Throws:
java.io.IOException- If failed to handle the call- See Also:
SftpEventListener.created(ServerSession, Path, Map, Throwable)
-
moving
public void moving(ServerSession session, java.nio.file.Path srcPath, java.nio.file.Path dstPath, java.util.Collection<java.nio.file.CopyOption> opts) throws java.io.IOException
Description copied from interface:SftpEventListenerCalled prior to renaming a file / directory- Specified by:
movingin interfaceSftpEventListener- Overrides:
movingin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledsrcPath- The sourcePathdstPath- The targetPathopts- The resolved renaming options- Throws:
java.io.IOException- If failed to handle the call- See Also:
SftpEventListener.moved(ServerSession, Path, Path, Collection, Throwable)
-
removing
public void removing(ServerSession session, java.nio.file.Path path, boolean isDirectory) throws java.io.IOException
Description copied from interface:SftpEventListenerCalled prior to removing a file- Specified by:
removingin interfaceSftpEventListener- Overrides:
removingin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledpath- ThePathabout to be removedisDirectory- Whether this is a folder or a file- Throws:
java.io.IOException- If failed to handle the call- See Also:
SftpEventListener.removed(ServerSession, Path, boolean, Throwable)
-
removed
public void removed(ServerSession session, java.nio.file.Path path, boolean isDirectory, java.lang.Throwable thrown) throws java.io.IOException
Description copied from interface:SftpEventListenerCalled after a file has been removed- Specified by:
removedin interfaceSftpEventListener- Overrides:
removedin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledpath- ThePathto be removedisDirectory- Whether this was a folder or a filethrown- If not-nullthen the reason for the failure to execute- Throws:
java.io.IOException- If failed to handle the call
-
linking
public void linking(ServerSession session, java.nio.file.Path source, java.nio.file.Path target, boolean symLink) throws java.io.IOException
Description copied from interface:SftpEventListenerCalled prior to creating a link- Specified by:
linkingin interfaceSftpEventListener- Overrides:
linkingin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledsource- The sourcePathtarget- The targetPathsymLink-true= symbolic link- Throws:
java.io.IOException- If failed to handle the call- See Also:
SftpEventListener.linked(ServerSession, Path, Path, boolean, Throwable)
-
modifyingAttributes
public void modifyingAttributes(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs) throws java.io.IOException
Description copied from interface:SftpEventListenerCalled prior to modifying the attributes of a file / directory- Specified by:
modifyingAttributesin interfaceSftpEventListener- Overrides:
modifyingAttributesin classAbstractSftpEventListenerAdapter- Parameters:
session- TheServerSessionthrough which the request was handledpath- The file / directoryPathto be modifiedattrs- The attributesMap- names and values depend on the O/S, view, type, etc...- Throws:
java.io.IOException- If failed to handle the call- See Also:
SftpEventListener.modifiedAttributes(ServerSession, Path, Map, Throwable)
-
isModificationAllowed
protected abstract boolean isModificationAllowed(ServerSession session, java.lang.String remoteHandle, java.nio.file.Path localPath) throws java.io.IOException
- Parameters:
session- TheServerSessionthrow which the request was maderemoteHandle- The remote handle valuelocalPath- The localPath- Returns:
trueif allowed to modify the path- Throws:
java.io.IOException- If failed to handle the call
-
-