| 1 | package Apache::AuthCookie::Params::Base; | ||
| 2 | $Apache::AuthCookie::Params::Base::VERSION = '3.32'; | ||
| 3 | # ABSTRACT: Internal CGI AuthCookie Params Base Class | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | use Class::Load qw(load_class); | ||
| 8 | use Apache::AuthCookie::Util qw(is_blank); | ||
| 9 | |||
| 10 | |||
| 11 | sub new { | ||
| 12 | my ($class, $r) = @_; | ||
| 13 | |||
| 14 | my $debug = $r->dir_config("AuthCookieDebug") || 0; | ||
| 15 | |||
| 16 | # use existing params object if possible | ||
| 17 | my $obj = $r->pnotes($class); | ||
| 18 | if (defined $obj) { | ||
| 19 | return $obj; | ||
| 20 | } | ||
| 21 | |||
| 22 | # if an encoding is in effect, then always use the ::CGI interface because | ||
| 23 | # libapreq has no support for UTF-8 | ||
| 24 | my $auth_name = $r->auth_name; | ||
| 25 | |||
| 26 | if (!is_blank($r->dir_config("${auth_name}Encoding"))) { | ||
| 27 | $obj = __PACKAGE__->_new_instance($r); | ||
| 28 | } | ||
| 29 | else { | ||
| 30 | $obj = $class->_new_instance($r); | ||
| 31 | } | ||
| 32 | |||
| 33 | $r->pnotes($class, $obj); | ||
| 34 | |||
| 35 | return $obj; | ||
| 36 | } | ||
| 37 | |||
| 38 | sub _new_instance { | ||
| 39 | my ($self, $r) = @_; | ||
| 40 | |||
| 41 | load_class('Apache::AuthCookie::Params::CGI'); | ||
| 42 | |||
| 43 | return Apache::AuthCookie::Params::CGI->new($r); | ||
| 44 | } | ||
| 45 | |||
| 46 | 1; | ||
| 47 | |||
| 48 | __END__ |