There is a login program which delivers a cookie.With this cookie I have to get the authentication done so that servlet can be called.
The OS which i am using is windows NT(in which the domino server is running, and for which i am in need of the authentication, in which my servlet file-i am in need of - is available) and the Linux server.(in which the apache server is running and the file, which does the authentication process is available.)
I am herewith sending the file(dologin.pm), which does the authentication work, which is a perl file. Also, i am sending the file which apeals or tries to get the authentication by use of the above said file.
doLogin program:should return a cookie which inturn should get the authentication done from the server.Can you suggest a way to get this done
package SSO::dologin; use strict; use Apache::Constants qw(:common); use Apache::Constants qw(:methods); use Apache::Constants qw(:response);
use SSO::LDAP; use SSO::UserProfile; use SSO::Server; use SSO::Cookie; use SSO::Cache; use SSO::Hash;
sub handler {
my $r = shift;
my %inputvals=$r->content; my $username=$inputvals{'username'}; my $password=$inputvals{'password'};
if((not defined $username) || (not defined $password)) { $r->log_reason("UserName/Password Not given ",$r->filename); return FORBIDDEN; }
my $userprofile = SSO::UserProfile->new(); $userprofile->UserName($username); $userprofile->Password($password);
my $ldapserver = SSO::Server->new(); my $ldapIP = $r->dir_config("LDAPServer"); my $ldapport = $r->dir_config("LDAPServerPort");
#If the ldap IP and Port are not given return error if(not defined $ldapIP) { $r->log_reason("Environment Variable LDAPServer is not Set",$r->filename); return SERVER_ERROR; }
$ldapserver->IP($ldapIP); $ldapserver->Port($ldapport); my $ldap=SSO::LDAP->new(); my $authstatus=$ldap->AuthenticateUser($ldapserver,$userprofile); if(!$authstatus) { $r->log_reason(" Unable to Authenticate UserName/Password",$r->filename); return FORBIDDEN; }
# Check the user status if(!$userprofile->UserStatus) { $r->log_reason(" User Status : Disabled ",$r->filename); return FORBIDDEN; }
# Generate Hash key (SessionId) for the User my $theexpduration = $r->dir_config("SessionExpiryDur");
#If the expiry duration is not given return error if(not defined $theexpduration) { $r->log_reason("Environment Variable SessionExpiryDur is not Set",$r->filename); return SERVER_ERROR; } $userprofile->SessionExpiryDur($theexpduration);
my $hash=SSO::Hash->new; my $sessionid=$hash->generateSessionId($userprofile,$r);
if ((not defined $sessionid) || ($sessionid eq "")) { $r->log_reason("SessionID not generated ",$r->filename); return SERVER_ERROR; }
my $multilogin = $r->dir_config("MultiLogin"); my $cache=SSO::Cache->new(); if((not defined $multilogin) || ($multilogin == 0 )) { # If the user already present in cache remove him $cache->removeUserByUserName($userprofile->UserName); }
$cache->addUser($userprofile);
my $cook=SSO::Cookie->new(); $cook->setCookie_ErrHeader("SSOAuthSessionID",$userprofile->SessionId,$r) ;
my $homepage = $r->dir_config("UsersHomePage");
my @form = ("/forms/","dologin","dologout","index.html"); foreach(@form){ if(($r->header_in('referer') =~/$_/i)) { $homepage = $r->dir_config("UsersHomePage"); last if 1 ; } else { $homepage = $r->header_in('referer'); } }
if(not defined $homepage) { $r->log_reason("Environment Variable UsersHomePage is not Set",$r->filename); return SERVER_ERROR; }