[aMail-checkins] CVS: new_project/program/lib/Storage EMail.pm,1.6,1.7
Brought to you by:
bit-man
|
From: Victor A. R. <bi...@us...> - 2002-08-23 18:02:03
|
Update of /cvsroot/amail/new_project/program/lib/Storage
In directory usw-pr-cvs1:/tmp/cvs-serv15045/program/lib/Storage
Modified Files:
EMail.pm
Log Message:
Alpha 1 stage for aMail::Storage and aMail::Storage::EMail
Index: EMail.pm
===================================================================
RCS file: /cvsroot/amail/new_project/program/lib/Storage/EMail.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** EMail.pm 23 Aug 2002 00:02:49 -0000 1.6
--- EMail.pm 23 Aug 2002 18:02:00 -0000 1.7
***************
*** 39,43 ****
################ Settings
my @acceptedMethods = [ 'AMAIL' ];
! my $db_path = '/home/bit-man/initialize_user';
#########################################
--- 39,44 ----
################ Settings
my @acceptedMethods = [ 'AMAIL' ];
! my $db_path = '/home/bit-man/aMail/initialize_user';
! my $Debug = 1;
#########################################
***************
*** 68,71 ****
--- 69,74 ----
my $name = "myNewFolder";
+ ### ... handler craetion via new() ...
+
die "Crash !!!!\n"
unless $handler->authAuthenticate( $authMethod, $aMail_ID, $SID)->result;
***************
*** 75,78 ****
--- 78,82 ----
Note: all methods return 0 (zero) on success, and not zero on error.
+
=cut
***************
*** 88,92 ****
use SOAP::Lite;
!
my @auth_methods = $handler->authGetMethods()->result;
--- 92,98 ----
use SOAP::Lite;
!
! ### ... handler craetion via new() ...
!
my @auth_methods = $handler->authGetMethods()->result;
***************
*** 113,119 ****
my $pass = 'secret';
! die "Can't authenticate !!!!\n"
! unless $handler->authAuthenticate( $authMethod, $user, $pass)->result;
=cut
--- 119,126 ----
my $pass = 'secret';
! ### ... handler craetion via new() ...
+ die "Can't authenticate !!!!\n"
+ unless ! $handler->authAuthenticate( $authMethod, $user, $pass)->result;
=cut
***************
*** 124,128 ****
my @param = @_;
! print "Auth. Method: $authMethod \n";
$_ = $authMethod;
--- 131,135 ----
my @param = @_;
! print "Auth. Method: $authMethod \n" if $Debug;
$_ = $authMethod;
***************
*** 136,177 ****
sub folderCreate() {
my $self = shift;
my $folder = shift;
my @param = @_;
- $SID = $param[1];
- my $aMail_ID = $param[0];
! return 0 if ( ! handlePAM( $aMail_ID ) );
! print "Folder creation: $folder\n";
! ###########################################
! my $user_path = "$db_path/$aMail_ID";
! return 0 if ( ! Check_folder_name($folder) );
!
!
! my $mailbox_file = "$user_path/folders";
! safe_open_update( *MAILBOX{IO}, $mailbox_file);
! flock(MAILBOX,2) || return 2;
! while (($_ = <MAILBOX>) and $_ ne "\n") {
! push @folders,$_;
! }
! foreach (@folders) {
! if ($_ =~ /^$folder,/) {
! close MAILBOX;
! return 1;
! }
! }
! my @messages = <MAILBOX>;
! push @folders, "$folder,0,0,0\n";
! seek MAILBOX, 0, 0;
! print MAILBOX @folders,"\n",@messages;
! close MAILBOX;
!
! ###########################################
! return 1;
}
--- 143,232 ----
+ =head2 folderCreate
+
+ Creates a folder
+
+ Returns :
+
+ =over 4
+
+ =item *
+ 1 if unsupported uthentication method
+
+ =item *
+ 2 if authentication failed
+
+ =item *
+ 3 if the folder file can't be locked
+
+ =item *
+ 4 if the folder already exists
+
+ =back
+
+ Usage:
+
+ use SOAP::Lite;
+
+ my $name = 'myFolder';
+
+ ### ... handler craetion via new() ...
+ ### ... authentication via authAuthenticate() ...
+
+ die "Can't create folder $name !!!!\n"
+ unless ! $handler->folderCreate( $name,
+ $authMethod'}, @authParams )->result;
+
+ =cut
+
sub folderCreate() {
my $self = shift;
my $folder = shift;
+ my $authMethod = shift;
my @param = @_;
! $_ = $authMethod;
! /$AMAIL/ && do {
! $SID = $param[1];
! my $aMail_ID = $param[0];
! print "===================== folderCreate\n" if $Debug;
! print "aMail ID: $aMail_ID\n" if $Debug;
! return 2 unless ! handlePAM( $aMail_ID );
! print "Folder creation: $folder\n" if $Debug;
! ###########################################
! my $user_path = "$db_path/$aMail_ID";
! my $mailbox_file = "$user_path/folders";
!
! safe_open_update( *MAILBOX{IO}, $mailbox_file);
! flock(MAILBOX,2) || return 3;
! print "Folder file locked.\n" if $Debug;
!
! while (($_ = <MAILBOX>) and $_ ne "\n") {
! push @folders,$_;
! }
! foreach (@folders) {
! if ($_ =~ /^$folder,/) {
! close MAILBOX;
! return 4; ## Folder already exists
! }
! }
!
! ## Folder creation in folders file
! my @messages = <MAILBOX>;
! push @folders, "$folder,0,0,0\n";
! seek MAILBOX, 0, 0;
! print MAILBOX @folders,"\n",@messages;
! close MAILBOX;
!
! print "Folder created !!!\n" if $Debug;
! ### Successfull completion
! return 0;
! };
!
! return 1; ### Sorry, invalid auth method
}
***************
*** 228,232 ****
=pod
! =head2 pam_conversation()
Default conversation routine used in PAM
--- 283,287 ----
=pod
! =head2 local_pam_conversation()
Default conversation routine used in PAM
***************
*** 241,245 ****
=cut
! sub pam_conversation {
my @res;
--- 296,300 ----
=cut
! sub local_pam_conversation {
my @res;
***************
*** 252,259 ****
if ($code == PAM_PROMPT_ECHO_OFF() ) {
$ans = $SID;
! print "SID (convers_off): $ans \n";
}
elsif ($code == PAM_PROMPT_ECHO_ON() ) { $ans = $SID;
! print "SID (convers_on): $SID \n"; }
elsif ($code == PAM_ERROR_MSG() ) { $problem = $code }
elsif ($code == PAM_TEXT_INFO() ) { }
--- 307,314 ----
if ($code == PAM_PROMPT_ECHO_OFF() ) {
$ans = $SID;
! print "SID (convers_off): $ans \n" if $Debug;
}
elsif ($code == PAM_PROMPT_ECHO_ON() ) { $ans = $SID;
! print "SID (convers_on): $SID \n" if $Debug; }
elsif ($code == PAM_ERROR_MSG() ) { $problem = $code }
elsif ($code == PAM_TEXT_INFO() ) { }
***************
*** 269,290 ****
sub handlePAM() {
my $aMail_ID = shift;
! my $sec_handle = new aMail::PAM( "aMail_Storage_EMail", $aMail_ID, \&pam_conversation );
$problem = ( ref($sec_handle) ? PAM_SUCCESS() : ref($sec_handle) );
! print "Problem: $problem\n";
return $problem unless ( $problem == PAM_SUCCESS() );
! print "Authenticate\n";
$problem = $sec_handle->pam_authenticate();
return $problem unless ( $problem == PAM_SUCCESS() );
! print "Mgmt\n";
$problem = $sec_handle->pam_acct_mgmt();
return $problem unless ( $problem == PAM_SUCCESS() );
! print "Open_session\n";
$problem = $sec_handle->pam_open_session();
return $problem unless ( $problem == PAM_SUCCESS() );
! print "END\n";
return 0;
}
--- 324,345 ----
sub handlePAM() {
my $aMail_ID = shift;
! my $sec_handle = new aMail::PAM( "aMail_Storage_EMail", $aMail_ID, \&local_pam_conversation );
$problem = ( ref($sec_handle) ? PAM_SUCCESS() : ref($sec_handle) );
! print "Problem: $problem\n" if $Debug;
return $problem unless ( $problem == PAM_SUCCESS() );
! print "Authenticate\n" if $Debug;
$problem = $sec_handle->pam_authenticate();
return $problem unless ( $problem == PAM_SUCCESS() );
! print "Mgmt\n" if $Debug;
$problem = $sec_handle->pam_acct_mgmt();
return $problem unless ( $problem == PAM_SUCCESS() );
! print "Open_session\n" if $Debug;
$problem = $sec_handle->pam_open_session();
return $problem unless ( $problem == PAM_SUCCESS() );
! print "END\n" if $Debug;
return 0;
}
|