Ticket #1 (closed task: fixed)

Opened 2 years ago

Last modified 2 years ago

Create example FTP server for Java/PeopleCode presentation

Reported by: chris.heller Owned by: chris.heller
Priority: major Component: AdvancedJavaPeopleCode
Keywords: Cc:

Description (last modified by chris.heller) (diff)

This is to track our initial work in creating a working FTP server in PeopleCode using the great  Java FTP library from  Apache.

See AdvancedJavaPeopleCode for more background on this.

Login to comment or add yourself to cc list

Attachments

mina-core-2.0.0-M6.jar Download (0.6 MB) - added by chris.heller 2 years ago.
slf4j-api-1.5.2.jar Download (17.0 KB) - added by chris.heller 2 years ago.
ftplet-api-1.0.3.jar Download (22.1 KB) - added by chris.heller 2 years ago.
ftpserver-core-1.0.3.jar Download (267.5 KB) - added by chris.heller 2 years ago.
slf4j-log4j12-1.5.2.jar Download (9.3 KB) - added by chris.heller 2 years ago.
myusers.properties Download (378 bytes) - added by chris.heller 2 years ago.
Example user config file - definitely not production quality!
bad_login_FTPSERV_DEMO.log Download (5.2 KB) - added by chris.heller 2 years ago.
Example log with bad login
successful_login_FTPSERV_DEMO.log Download (0.7 KB) - added by chris.heller 2 years ago.
FTP log with our successful login

Change History

Changed 2 years ago by chris.heller

Work on ticket #1. This is just the skeleton outline of what we will get working. The example Java code comes from  http://mina.apache.org/ftpserver/embedding-ftpserver-in-5-minutes.html

(Comment automatically added from changeset [44])

Changed 2 years ago by chris.heller

Document the required .jar files that are needed in the PSHOME/class directory and do the basic translation of the java code to PeopleCode for ticket #1.

(Comment automatically added from changeset [8])

Changed 2 years ago by chris.heller

Changed 2 years ago by chris.heller

Changed 2 years ago by chris.heller

Changed 2 years ago by chris.heller

Changed 2 years ago by chris.heller

Changed 2 years ago by chris.heller

  • status changed from new to accepted

I've attached the required .jar files that we used for the project. These are just copies from the Apache site ; there are no local changes that we needed to make.

Changed 2 years ago by chris.heller

When we run the App Engine program we get the following error message in the log file.

Java Exception: java.lang.NoClassDefFoundError: FtpServerFactory: finding class FtpServerFactory (2,725) FTPSERV_DEMO.MAIN.GBL.default.1900-01-01.Step01.OnExecute  PCPC:55  Statement:1
 Message Set Number: 2
 Message Number: 725
 Message Reason: Java Exception: %1: finding class %2 (2,725)

Changed 2 years ago by chris.heller

PeopleCode's Java integration does not support importing references to Java classes, so we need to fully qualify the class name in order for the CreateJavaObject? call to succeed. ticket #1.

(Comment automatically added from changeset [9])

Changed 2 years ago by chris.heller

Now that we have fully qualified the class name, our program runs to success.

But, we don't want the program to quit so quickly; we want it to stay running so that we can connect to it with an FTP client.

Changed 2 years ago by chris.heller

The FTP server is starting in it's own thread, so the server.start() call returns after creating the thread and our App Engine program then finishes. So, we'll wait for a little while before letting the program end. That will give us some time to try connecting with our client FTP program. Work on ticket #1

(Comment automatically added from changeset [10])

Changed 2 years ago by chris.heller

Work on ticket #1 - initialize log4j properly so that we get output from the FTP library in our log file. Also, configure the FTP server object with a demo user configuration source.

(Comment automatically added from changeset [11])

Changed 2 years ago by chris.heller

changeset:11 fixed up the log4j:WARN No appenders could be found for logger that we were previously seeing in the logs. That was happening because the PeopleCode/Java? integration does not provide any defaults for log4j, and most Java libraries that use log4j do not provide any default configuration - it's expected that this is set at the system level.

However, we're still not able to login with our FTP client.

Changed 2 years ago by chris.heller

Example user config file - definitely not production quality!

Changed 2 years ago by chris.heller

Example log with bad login

Changed 2 years ago by chris.heller

The attached bad_login_FTPSERV_DEMO.log shows that the server is recognizing that we are trying to use the admin account that we defined in the myusers.properties file, but it is still getting authentication denied.

Changed 2 years ago by chris.heller

Work on ticket #1 - initialize log4j so that we are logging at the INFO level; helps keep our logs a little bit more manageable and demonstrates the use of Java statics from PeopleCode as well.

For more examples of using log4j within PeopleCode, take a look at Jim Marion's weblog,  http://jjmpsj.blogspot.com/search/label/log4j

(Comment automatically added from changeset [12])

Changed 2 years ago by chris.heller

In changeset:13 we added a bit of code to tell the Java library that the passwords in the user config file were not encrypted.

We figured this out from reading more of  the example code on the Apache website and by looking at some of the options that the Apache MINA library offers for  configuring the user manager logic.

What we'd probably do if we were to continue working on this code would be to hook up the FTP server's user manager to validate user accounts directly against PeopleSoft via the PRTL_SS_CI ComponentInterface? so that any external signon PeopleCode would execute.

Changed 2 years ago by chris.heller

FTP log with our successful login

Changed 2 years ago by chris.heller

changeset:13 was what did the trick to get our first successful login to our PeopleCode hosted FTP server.

Here's the transcript from the command line FTP client included with Microsoft Windows.

C:\temp>ftp grey-09b740ac20
Connected to grey-09b740ac20.gsdemo.local.
220 Service ready for new user.
User (grey-09b740ac20.gsdemo.local:(none)): admin
331 User name okay, need password for admin.
Password:
230 User logged in, proceed.
ftp> ls
200 Command PORT okay.
150 File status okay; about to open data connection.
.statsvn
Desktop
Favorites
My Documents
Start Menu
hudson
psft
Sti_Trace.log
g2mdlhlpx.exe
java0.log
java0.log.lck
java1.log
java1.log.lck
java2.log
java2.log.lck
java3.log
java3.log.lck
226 Closing data connection.
ftp: 204 bytes received in 0.06Seconds 3.24Kbytes/sec.
ftp> quit
221 Goodbye.
C:\temp>

The file listing there matches up correctly with the directory on the server that we had mapped in the attachment:myusers.properties Download configuration file.

Changed 2 years ago by chris.heller

  • status changed from accepted to closed
  • resolution set to fixed

The interesting thing with the Apache MINA library is that it is not bound directly to serving files from the filesystem. We could hook things up so that we were serving files from the PeopleSoft report repository (filtered by the user's security of course) or point it to being able to manage attachments that are stored in the database.

Imagine the following (currently hypothetical) FTP session transcript.

cd HCM91PRD     (the database)
cd EMPL_PHOTO   (the PeopleSoft record)
cd 8001         (the employee ID)
put 8001.jpg    (uploads file and stores in EMPLOYEE_PHOTO field)

Changed 2 years ago by chris.heller

  • description modified (diff)
Note: See TracTickets for help on using tickets.