Ignore:
Timestamp:
09/04/08 09:45:36 (12 years ago)
Author:
pjkersha
Message:

Working Perl NDG Single Sign On client.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/perl/ndglogin.pl

    r3771 r3775  
    44use warnings; 
    55use CGI; 
    6 #use MIME::Base64::URLSafe; 
    7 use ndgsecurity::ssoclient qw (urlSafeB64Encode); 
    8   
     6#use ndgsecurity::ssoclient; 
     7use NDG::Security::Client; 
     8 
    99my $cgi = CGI->new(); 
    1010#my $session = ndgsecurity::ssoclient->new($cgi); 
    11 my $session = eval {new ndgsecurity::ssoclient($cgi)}; 
     11my $session = eval {new NDG::Security::Client($cgi)}; 
    1212 
    13 $session->sessionHandler(); 
    14 my $wayfURI = "https://localhost/sso/wayf"; 
    15  
    16 # Refer back to THIS URL but over https rather than http 
    17 my $returnTo = "https://" . $cgi->virtual_host() . $cgi->url(-absolute=>1); 
    18 my $b64encReturnTo = "";#urlSafeB64Encode($returnTo); 
    19  
    20 print $cgi->header('text/html'); 
    21 print $cgi->start_html('NDG Login'), 
    22 $cgi->h1('NDG Login'), 
    23 $returnTo, $cgi->br, 
    24 $cgi->start_form(-action=>$wayfURI), 
    25 $cgi->hidden('r', $b64encReturnTo), $cgi->br, 
    26 $cgi->submit('NDG Login'), 
    27 $cgi->end_form, $cgi->p, 
    28 $cgi->hr; 
    29  
    30 print $cgi->end_html; 
    31  
     13# Call Single Sign On handler 
     14my $redirectHdr = $session->ssoHandler(); 
     15if ($redirectHdr) 
     16{ 
     17    # A redirect header has created indicating the handler has received a response from 
     18    # a Single Sign Service 
     19    print $redirectHdr; 
     20} 
     21else 
     22{ 
     23    # Create a form based on the WAYF address and encoded return to address formulated by 
     24    # ssoHandler 
     25    print $cgi->header('text/html'); 
     26    print $cgi->start_html('NDG Login'), 
     27    $cgi->h1('NDG Login'), 
     28    $cgi->start_form(-action=>$session->{wayfURI}), 
     29    $cgi->hidden('r', $session->{b64encReturnToURL}), $cgi->br, 
     30    $cgi->submit('NDG Login'), 
     31    $cgi->end_form, $cgi->p, 
     32    $cgi->hr; 
    3233     
     34    print $cgi->end_html; 
     35} 
     36     
Note: See TracChangeset for help on using the changeset viewer.