#!/usr/local/bin/perl -w use strict; use LWP::UserAgent; use LWP::Simple; use HTTP::Cookies; use HTTP::Request::Common; use HTTP::Headers; . . . sub do_LWPsetup { my $ref2browser = shift; $HTTP::Request::Common::DYNAMIC_FILE_UPLOAD = 1; #create an LWP browser object $$ref2browser = LWP::UserAgent->new(); #allow POST redirects push @{$$ref2browser->requests_redirectable}, 'POST'; #enable cookie support (dont know if this is really neccesary $$ref2browser->cookie_jar(new HTTP::Cookies ); return 1; } sub do_logon { my $userid = shift; my $password = shift; my $url = shift; my $browser = shift; my $loginurl = "$url/logon.jsp"; my $resp = $browser->post($loginurl, [ 'j_username' => $userid, 'j_password' => $password, 'submit' => 'Submit' ]); print "do_logon " . __FILE__ . "[" . __LINE__ ."] resp =[" . Dumper($resp) . "]\n"; if (do_errorcheck($resp,'Logon')) { print $resp->{'_msg'} . "\n"; return 0; } if ($debug_level > 0) { print "\nLogon Success: $userid"; } return 1; } . . . getUserPassword( \$user, \$password ); my $browser; my $rc = do_LWPsetup( \$browser ); if ($rc==0) { print "Failure: do_LWPStuff failed\n"; exit 1; } if (!do_logon( $user, $password, $url, $browser )) { print "Failure: do_logon failed\n"; exit 2; } else { print "Where in!\n"; } #### Enter user: TEST001 Enter password: ******* do_logon BEGIN myscript.pl[269] do_logon resp myscript.pl[283] resp =[$VAR1 = bless( { '_protocol' => 'HTTP/1.1', '_content' => ' xyz Secure HTTP File Uploader Logon


Enter your name:
Enter your password:

', '_rc' => '200', '_headers' => bless( { 'connection' => 'close', 'x-powered-by' => [ 'Servlet/2.4', 'JSP/2.0' ], 'client-response-num' => 1, 'set-cookie' => 'JSESSIONID=27CCB71220635A381F38052A601A5C33; Path=/xyzSecureUpLoad_III; Secure', 'date' => 'Mon, 01 Mar 2004 17:43:47 GMT', 'client-ssl-cert-issuer' => '/C=US/ST=California/L=Santa Clara/O=Sun Microsystems/OU=SunONE/CN=S1AS', 'client-ssl-cipher' => 'EDH-RSA-DES-CBC3-SHA', 'client-peer' => 'localhost:1043', 'content-length' => '661', 'client-date' => 'Mon, 01 Mar 2004 17:43:47 GMT', 'content-type' => 'text/html;charset=ISO-8859-1', 'client-ssl-warning' => 'Peer certificate not verified', 'client-ssl-cert-subject' => '/C=US/ST=California/L=Santa Clara/O=Sun Microsystems/OU=SunONE/CN=S1AS', 'server' => 'Sun-Java-System/Application-Server-PE-8.0', 'title' => 'xyz Secure HTTP File Uploader (ASHFU) Logon' }, 'HTTP::Headers' ), '_msg' => 'OK', '_request' => bless( { '_content' => 'j_username=TEST001&j_password=TEST001&submit=Submit', '_uri' => bless( do{\(my $o = 'https://localhost:1043/xyzSecureUpLoad_III/logon.jsp')}, 'URI::https' ), '_headers' => bless( { 'user-agent' => 'libwww-perl/5.69', 'content-type' => 'application/x-www-form-urlencoded', 'content-length' => 51 }, 'HTTP::Headers' ), '_method' => 'POST' }, 'HTTP::Request' ) }, 'HTTP::Response' ); ] do_logon END myscript.pl[289] ##
## my $loginurl = "$url/logon.jsp"; #### my $loginurl = "$url/j_security_check"; #### HTTP Status 400 - Invalid direct reference to form login page type Status report message Invalid direct reference to form login page description The request sent by the client was syntactically incorrect (Invalid direct reference to form login page). J2EETM 1.4 Application Server