File: index.pl

package info (click to toggle)
lemonldap-ng 0.9.4.1-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,840 kB
  • ctags: 1,187
  • sloc: perl: 10,032; makefile: 478; xml: 93; sh: 73; sql: 69
file content (73 lines) | stat: -rwxr-xr-x 2,026 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/perl

use strict;
use warnings;

use HTML::Template;
use Lemonldap::NG::Portal::AuthLA;

# Local parameter to set the installation directory

my $portal = Lemonldap::NG::Portal::AuthLA->new(
    {
        # Liberty Parameters
        laSp => {
            certificate => "__DIR__/ressources/lemonsp-key-public.pem",
            metadata    => "__DIR__/ressources/lemonsp-metadata.xml",
            privkey     => "__DIR__/ressources/lemonsp-key-private.pem",
            secretkey   => "__DIR__/ressources/lemonsp-key-private.pem",
        },
        laIdpsFile           => "__DIR__/idps.xml",
        laDebug              => 0,
        laLdapLoginAttribute => "uid",

        # Liberty Storage Options are now generic CGI::Session options
        laStorage        => "File",
        laStorageOptions => { Directory => "__DIR__/var/assertion", },

        # Parameters that permit to access lemonldap::NG::Handler local cache
        localStorage        => 'Cache::FileCache',
        localStorageOptions => {},
    }
);

if ( $portal->process() ) {

    print $portal->header('text/html; charset=utf8');
    my $template = HTML::Template->new( filename => "__DIR__/tpl/menu.tpl" );

    my @sites = ();
    foreach ( $portal->getProtectedSites ) {
        my %row_data;
        $row_data{SITE_NAME} = $_;
        push( @sites, \%row_data );
    }
    @sites = sort { $a cmp $b } @sites;
    $template->param( AUTH_SITES => \@sites );

    print $template->output;

}
else {

    # Retrieve IDP list.

    my @idps = ();
    foreach ( $portal->getIdpIDs ) {
        my %row_data;
        $row_data{IDPNAME} = $_;
        push( @idps, \%row_data );
    }
    @idps = sort { $a cmp $b } @idps;

    # Print template

    print $portal->header;
    my $template = HTML::Template->new( filename => "__DIR__/tpl/auth.tpl" );
    $template->param( AUTH_ERROR => $portal->error );
    $template->param( AUTH_URL   => $portal->param('url') );
    $template->param( AUTH_IDPS  => \@idps );
    print $template->output;

}