Niklas,

Thanks for the quick reply. I apologize for not being very specific in
my previous post. I used the FileObserver interface which allows me to
receive notification of various file events such as download, upload,
mkdir etc. These notifications also contain the FtpIoSession which in
turn contains information of the user, remote address etc. which is
what I mainly need for the audit log. However, these notifications are
available only when the user requested action is successful. However,
I would like to log any unsuccessful requests as well. So, the
FileObserver alone cannot get me what I want.

Do you have any other suggestions? I personally would prefer to extend
the functionality of Ftplet to send more information on the
afterCommand method call. This approach seems to be more straight
forward and easy to implement. What do you think? If you agree, I
would be glad to help you with design/coding.

FYI, here is the snippet of code that works for me to some extent
using the FileObserver:

        ServerFtpStatistics stats = (ServerFtpStatistics)
server.getServerContext().getFtpStatistics();
        stats.setFileObserver(new FileObserver() {

            public void notifyDelete(FtpIoSession session, FileObject file) {
                System.out.println("**********************************");
                System.out.println("Remote Address: "
                    + session.getRemoteAddress());
                System.out.println("Session ID: " + session.getId());
                System.out.println("User: " + session.getUser());
                System.out.println("Description: " + "File "
                    + ((NativeFileObject)file).getPhysicalFile() + "
was deleted");
                System.out.println("**********************************");
            }

            public void notifyDownload(FtpIoSession session, FileObject file,
                long size) {
                System.out.println("**********************************");
                System.out.println("Remote Address: "
                    + session.getRemoteAddress());
                System.out.println("Session ID: " + session.getId());
                System.out.println("User: " + session.getUser());
                System.out.println("Description: " + "File "
                    + ((NativeFileObject)file).getPhysicalFile() + "
was downloaded");
                System.out.println("File Size: " + size);
                System.out.println("**********************************");
            }

            public void notifyMkdir(FtpIoSession arg0, FileObject arg1) {
                //TODO implement
            }

            public void notifyRmdir(FtpIoSession arg0, FileObject arg1) {
                //TODO implement
            }

            public void notifyUpload(FtpIoSession session, FileObject file,
                long size) {
                System.out.println("**********************************");
                System.out.println("Remote Address: "
                    + session.getRemoteAddress());
                System.out.println("Session ID: " + session.getId());
                System.out.println("User: " + session.getUser());
                System.out.println("Description: " + "File "
                    + ((NativeFileObject)file).getPhysicalFile() + "
was uploaded");
                System.out.println("File Size: " + size);
                System.out.println("**********************************");
            }

        });

I look forward to hearing from you with any ideas/comments.

Regards,

Sai Pullabhotla
Phone: (402) 408-5753
Fax: (402) 408-6861
www.jMethods.com



On Fri, Nov 14, 2008 at 2:54 PM, Niklas Gustavsson <[EMAIL PROTECTED]> wrote:
>
> On Fri, Nov 14, 2008 at 9:47 PM, Sai Pullabhotla
> <[EMAIL PROTECTED]> wrote:
> > I digged into the code and javadoc some more and found that I could achieve
> > the functionality I want by using the FtpStatistics/ServerFtpStatistics
> > interface. Is this the correct way to go?
>
> If what you need are the number of occurrences of different actions, then yes.
>
> /niklas

Reply via email to