lib/TWiki/Net/UserCredAgent.pm
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
permissions -rw-r--r--
RELEASE 4.2.0 freetown
     1 # Module of TWiki Enterprise Collaboration Platform, http://TWiki.org/
     2 #
     3 # Copyright (C) 2007 TWiki Contributors. All Rights Reserved.
     4 # TWiki Contributors are listed in the AUTHORS file in the root
     5 # of this distribution. NOTE: Please extend that file, not this notice.
     6 #
     7 # This program is free software; you can redistribute it and/or
     8 # modify it under the terms of the GNU General Public License
     9 # as published by the Free Software Foundation; either version 2
    10 # of the License, or (at your option) any later version. For
    11 # more details read LICENSE in the root of this distribution.
    12 #
    13 # This program is distributed in the hope that it will be useful,
    14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    16 #
    17 # As per the GPL, removal of this notice is prohibited.
    18 
    19 # LWP::UserAgent subclass used to pass in username and password,
    20 # and use the TWiki proxy setup
    21 
    22 package TWiki::Net::UserCredAgent;
    23 use base 'LWP::UserAgent';
    24 
    25 sub new {
    26     my ($class, $user, $pass) = @_;
    27     my $this = $class->SUPER::new();
    28     $this->{user} = $user;
    29     $this->{pass} = $pass;
    30     if ($TWiki::cfg{PROXY}{HOST}) {
    31         my $proxy = $TWiki::cfg{PROXY}{HOST};
    32         if ($TWiki::cfg{PROXY}{PORT}) {
    33             $proxy .= ':'.$TWiki::cfg{PROXY}{PORT};
    34         }
    35         $this->proxy([ 'http', 'https' ], $proxy);
    36     }
    37     return $this;
    38 }
    39 
    40 sub get_basic_credentials {
    41     my($this, $realm, $uri) = @_;
    42     return ($this->{user}, $this->{pass});
    43 };
    44 
    45 1;