Show
Ignore:
Timestamp:
18.09.2012 18:10:37 (8 years ago)
Author:
ak19
Message:

Fixes to get Remote Greenstone 3 working with client-gli: 1. client-GLI should not start the local GS3 server, since client-GLI will be running against a remote server. 2. The encryption process for authentication had been changed for GS3, so now Authentication.java has a main function which is invoked by gliserver's gsdlCGI.pm to encrypt the password. 4. UsersDB when converted to txt for parsing by gliserver.pl has a different structure, so gliserver.pl needs to take that into account. 5. util.pm's functions for prepending and appending to environment variables needs to use an OS dependant path separator. This was not noticed when testing the remote GS server on 32 bit linux so far, but the windows style path separator (semicolon) used so far didn't work on the 64 bit linux test machine.

Location:
main/trunk/greenstone2/common-src/cgi-bin
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/common-src/cgi-bin/gliserver.pl

    r25963 r26206  
    230230    # Get the user account information from the usersDB database 
    231231    my %users_db_data = (); 
    232     foreach my $users_db_entry (split(/-{70}/, $users_db_content)) { 
    233     if ($users_db_entry =~ m/\n?\[(.+)\]\n/) { 
     232 
     233    # a line dividing one user entry from another is made up of 70 hyphens for GS2 (37 hyphens for GS3) 
     234    my $horizontal_divider = ($gsdl_cgi->greenstone_version() == 2) ? q/-{70}/ : q/-{37}/; 
     235    foreach my $users_db_entry (split($horizontal_divider, $users_db_content)) {     
     236    if ($users_db_entry =~ m/\n?\[(.+)\]\n/ || $users_db_entry =~ m/\n?USERNAME = ([^\n]*)\n/) { # GS2 and GS3 formats 
    234237        $users_db_data{$1} = $users_db_entry; 
    235238    } 
     
    243246 
    244247    # Check password 
    245     my ($valid_user_password) = ($user_data =~ m/\<password\>(.*)/); 
     248    my $pwdLine = ($gsdl_cgi->greenstone_version() == 2) ? q/\<password\>(.*)/ : q/\n?PASSWORD = (.*)\n/; 
     249    my ($valid_user_password) = ($user_data =~ m/$pwdLine/); 
    246250    if ($user_password ne $valid_user_password) { 
    247251    $gsdl_cgi->generate_error("Authentication failed: incorrect password."); 
     
    249253 
    250254    # Check group 
    251     my ($user_groups) = ($user_data =~ m/\<groups\>(.*)/); 
     255    my $groupLine = ($gsdl_cgi->greenstone_version() == 2) ? q/\<groups\>(.*)/ : q/\n?GROUPS = (.*)\n/; 
     256    my ($user_groups) = ($user_data =~ m/$groupLine/); 
    252257 
    253258    if ($collection eq "") { 
  • main/trunk/greenstone2/common-src/cgi-bin/gsdlCGI.pm

    r25078 r26206  
    517517    }  
    518518    $ENV{'GSDL3HOME'} = $gsdl3home; 
    519     }  
    520     
     519    } 
    521520     
    522521    my $gsdl_bin_script = &util::filename_cat($gsdlhome,"bin","script"); 
     
    751750} 
    752751 
     752# used with old GS3 authentication 
    753753sub rot13() 
    754754{ 
     
    775775} 
    776776 
     777# used along with new GS3 authentication 
     778sub hash_pwd() 
     779{ 
     780    my $self = shift @_; 
     781    my ($password)=@_; 
     782 
     783    my $gsdl3srchome = $ENV{'GSDL3SRCHOME'}; 
     784     
     785    my $java = get_java_path(); 
     786    my $java_gsdl3_classpath = &util::filename_cat($gsdl3srchome, "web", "WEB-INF", "lib", "gsdl3.jar"); 
     787    my $java_remaining_classpath = &util::filename_cat($gsdl3srchome, "web", "WEB-INF", "lib", "*"); # log4j etc 
     788    my $java_classpath; 
     789    my $gsdlos = $ENV{'GSDLOS'}; 
     790    if ($gsdlos !~ m/windows/){ 
     791    $java_classpath = $java_gsdl3_classpath . ":" . $java_remaining_classpath; 
     792    }else{ 
     793    $java_classpath = $java_gsdl3_classpath . ";" . $java_remaining_classpath; 
     794    } 
     795     
     796    my $java_command="\"$java\" -classpath \"$java_classpath\" org.greenstone.gsdl3.service.Authentication \"$password\""; # 2>&1"; 
     797    my $hashedpwd = `$java_command`; 
     798 
     799    return $hashedpwd; 
     800} 
     801 
    777802sub encrypt_password 
    778803{ 
     
    781806    if (defined $self->param("pw")) { ## 
    782807    if ($self->{'greenstone_version'} == 3) { # GS3 is in Java, so needs different encryption 
    783         $self->param('-name' => "pw", '-value' => $self->rot13($self->clean_param("pw"))); 
     808        #$self->param('-name' => "pw", '-value' => $self->rot13($self->clean_param("pw"))); ## when using old GS3 authentication 
     809 
     810        my $hashedPwd = $self->hash_pwd($self->clean_param("pw")); # for GS3's new Authentication 
     811        $self->param('-name' => "pw", '-value' => $hashedPwd); 
    784812    } 
    785813    else { # GS2 (and versions of GS other than 3?)