| 1 | package Ubic::Credentials; | ||
| 2 | $Ubic::Credentials::VERSION = '1.59'; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | # ABSTRACT: base class for OS-specific credential methods | ||
| 7 | |||
| 8 | |||
| 9 | use List::MoreUtils qw(uniq); | ||
| 10 | |||
| 11 | use Params::Validate qw(:all); | ||
| 12 | use Carp; | ||
| 13 | |||
| 14 | our $OS_CLASS; | ||
| 15 | |||
| 16 | sub import { | ||
| 17 | my %module = ( | ||
| 18 | MSWin32 => 'Windows', | ||
| 19 | darwin => 'MacOSX', | ||
| 20 | ); | ||
| 21 | |||
| 22 | my $module = $ENV{UBIC_CREDENTIALS_OS} || $ENV{UBIC_OS} || $module{$^O} || 'POSIX'; | ||
| 23 | |||
| 24 | require "Ubic/Credentials/OS/$module.pm"; | ||
| 25 | $OS_CLASS = "Ubic::Credentials::OS::$module"; | ||
| 26 | } | ||
| 27 | |||
| 28 | |||
| 29 | sub new { | ||
| 30 | my $class = shift; | ||
| 31 | return $OS_CLASS->new(@_) if $class eq 'Ubic::Credentials'; | ||
| 32 | croak 'constructor not implemented'; | ||
| 33 | } | ||
| 34 | |||
| 35 | sub set_effective { | ||
| 36 | croak 'not implemented'; | ||
| 37 | } | ||
| 38 | |||
| 39 | sub reset_effective { | ||
| 40 | croak 'not implemented'; | ||
| 41 | } | ||
| 42 | |||
| 43 | sub eq { | ||
| 44 | croak 'not implemented'; | ||
| 45 | } | ||
| 46 | |||
| 47 | sub set { | ||
| 48 | croak 'not implemented'; | ||
| 49 | } | ||
| 50 | |||
| 51 | sub as_string { | ||
| 52 | my $self = shift; | ||
| 53 | return "$self"; # ugly default stringification; please override in subclasses | ||
| 54 | } | ||
| 55 | |||
| 56 | |||
| 57 | 1; | ||
| 58 | |||
| 59 | __END__ |