| 1 | # This code is part of Perl distribution User-Identity version 4.00. | ||
| 2 | # The POD got stripped from this file by OODoc version 3.05. | ||
| 3 | # For contributors see file ChangeLog. | ||
| 4 | |||
| 5 | # This software is copyright (c) 2003-2025 by Mark Overmeer. | ||
| 6 | |||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||
| 9 | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | ||
| 10 | |||
| 11 | |||
| 12 | package User::Identity::System;{ | ||
| 13 | our $VERSION = '4.00'; | ||
| 14 | } | ||
| 15 | |||
| 16 | use parent 'User::Identity::Item'; | ||
| 17 | |||
| 18 | use strict; | ||
| 19 | use warnings; | ||
| 20 | |||
| 21 | use Log::Report 'user-identity'; | ||
| 22 | |||
| 23 | use User::Identity (); | ||
| 24 | use Scalar::Util qw/weaken/; | ||
| 25 | |||
| 26 | #-------------------- | ||
| 27 | |||
| 28 | sub type { 'network' } | ||
| 29 | |||
| 30 | |||
| 31 | sub init($) | ||
| 32 | { my ($self, $args) = @_; | ||
| 33 | |||
| 34 | $self->SUPER::init($args); | ||
| 35 | exists $args->{$_} && ($self->{'UIS_'.$_} = delete $args->{$_}) | ||
| 36 | for qw/hostname location os password username/; | ||
| 37 | |||
| 38 | $self->{UIS_hostname} ||= 'localhost'; | ||
| 39 | $self; | ||
| 40 | } | ||
| 41 | |||
| 42 | #-------------------- | ||
| 43 | |||
| 44 | sub hostname() { $_[0]->{UIS_hostname} } | ||
| 45 | sub username() { $_[0]->{UIS_username} } | ||
| 46 | sub os() { $_[0]->{UIS_os} } | ||
| 47 | sub password() { $_[0]->{UIS_password} } | ||
| 48 | |||
| 49 | |||
| 50 | sub location() | ||
| 51 | { my $self = shift; | ||
| 52 | my $location = $self->{MI_location} or return; | ||
| 53 | |||
| 54 | unless(ref $location) | ||
| 55 | { my $user = $self->user or return; | ||
| 56 | $location = $user->find(location => $location); | ||
| 57 | } | ||
| 58 | |||
| 59 | $location; | ||
| 60 | } | ||
| 61 | |||
| 62 | 1; |