source: TI12-security/trunk/perl/ndgaccess.pl @ 3781

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/perl/ndgaccess.pl@4565
Revision 3781, 1.4 KB checked in by pjkersha, 12 years ago (diff)

Added catch for NDG::Security::Client object creation.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5use CGI;
6
7# TODO: remove for production - this is for debug only
8use CGI::Carp qw/fatalsToBrowser/;
9
10use NDG::Security::Client;
11
12my $cgi = CGI->new();
13#my $session = ndgsecurity::ssoclient->new($cgi);
14my $cfgFilePath = "/var/www/cgi-bin/NDG/Security/conf/ndg-security-client.cfg";
15my $session = eval {new NDG::Security::Client($cfgFilePath, $cgi)};
16if ($@)
17{
18    print $cgi->header('text/html');
19    print $cgi->start_html('NDG Secured Resource'),
20    $cgi->h1('NDG Secured Resource'),
21    "An error occured initialising the security configuration", $cgi->p,
22    $cgi->hr;
23   
24    print $cgi->end_html;
25}
26else
27{
28    # Call Single Sign On handler
29    my $redirectHdr = $session->ssoHandler();
30    if ($redirectHdr)
31    {
32        # A redirect header has been created indicating
33        # 1) the handler has received a response from a Single Sign Service
34        # or
35        # 2) User is not logged in - redirecting to WAYF
36        print $redirectHdr;
37    }
38    else
39    {
40        # Check access for this page
41        my $dir = "/var/www/cgi-bin/";
42        my $msg;
43       
44        my $accessDecision = $session->pep($dir);
45       
46        print $cgi->header('text/html');
47        print $cgi->start_html('NDG Secured Resource'),
48        $cgi->h1('NDG Secured Resource'),
49        $accessDecision->{msg}, $cgi->p,
50        $cgi->hr;
51       
52        print $cgi->end_html;
53    }
54}
Note: See TracBrowser for help on using the repository browser.