|
Lines 19-32
package Koha::Auth::Identity::Provider;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use base qw(Koha::Object); |
22 |
use base qw(Koha::Object Koha::Object::JSONFields); |
| 23 |
|
|
|
| 24 |
use JSON qw( decode_json encode_json ); |
| 25 |
use Try::Tiny; |
| 26 |
|
23 |
|
| 27 |
use Koha::Auth::Identity::Provider::Domains; |
24 |
use Koha::Auth::Identity::Provider::Domains; |
| 28 |
use Koha::Exceptions; |
25 |
use Koha::Exceptions; |
| 29 |
use Koha::Exceptions::Object; |
|
|
| 30 |
|
26 |
|
| 31 |
=head1 NAME |
27 |
=head1 NAME |
| 32 |
|
28 |
|
|
Lines 61-71
Returns a I<hashref> containing the configuration parameters for the provider.
Link Here
|
| 61 |
sub get_config { |
57 |
sub get_config { |
| 62 |
my ($self) = @_; |
58 |
my ($self) = @_; |
| 63 |
|
59 |
|
| 64 |
return try { |
60 |
return $self->decode_json_field( { field => 'config' } ); |
| 65 |
return decode_json( Encode::encode_utf8( $self->config ) ); |
|
|
| 66 |
} catch { |
| 67 |
Koha::Exceptions::Object::BadValue->throw("Error reading JSON data: $_"); |
| 68 |
}; |
| 69 |
} |
61 |
} |
| 70 |
|
62 |
|
| 71 |
=head3 set_config |
63 |
=head3 set_config |
|
Lines 104-117
sub set_config {
Link Here
|
| 104 |
} |
96 |
} |
| 105 |
} |
97 |
} |
| 106 |
|
98 |
|
| 107 |
try { |
99 |
return $self->set_encoded_json_field( { data => $config, field => 'config' } ); |
| 108 |
my $encoded_config = encode_json($config); |
|
|
| 109 |
$self->config($encoded_config); |
| 110 |
} catch { |
| 111 |
Koha::Exceptions::Object::BadValue->throw("Error serializing data into JSON: $_"); |
| 112 |
}; |
| 113 |
|
| 114 |
return $self; |
| 115 |
} |
100 |
} |
| 116 |
|
101 |
|
| 117 |
=head3 get_mapping |
102 |
=head3 get_mapping |
|
Lines 125-135
Returns a I<hashref> containing the attribute mapping for the provider.
Link Here
|
| 125 |
sub get_mapping { |
110 |
sub get_mapping { |
| 126 |
my ($self) = @_; |
111 |
my ($self) = @_; |
| 127 |
|
112 |
|
| 128 |
return try { |
113 |
return $self->decode_json_field( { field => 'mapping' } ); |
| 129 |
return decode_json( Encode::encode_utf8( $self->mapping ) ); |
|
|
| 130 |
} catch { |
| 131 |
Koha::Exceptions::Object::BadValue->throw("Error reading JSON data: $_"); |
| 132 |
}; |
| 133 |
} |
114 |
} |
| 134 |
|
115 |
|
| 135 |
=head3 set_mapping |
116 |
=head3 set_mapping |
|
Lines 143-156
This method stores the passed mappings in JSON format.
Link Here
|
| 143 |
sub set_mapping { |
124 |
sub set_mapping { |
| 144 |
my ( $self, $mapping ) = @_; |
125 |
my ( $self, $mapping ) = @_; |
| 145 |
|
126 |
|
| 146 |
try { |
127 |
return $self->set_encoded_json_field( { data => $mapping, field => 'mapping' } ); |
| 147 |
my $encoded_mapping = encode_json($mapping); |
|
|
| 148 |
$self->mapping($encoded_mapping); |
| 149 |
} catch { |
| 150 |
Koha::Exceptions::Object::BadValue->throw("Error serializing data into JSON: $_"); |
| 151 |
}; |
| 152 |
|
| 153 |
return $self; |
| 154 |
} |
128 |
} |
| 155 |
|
129 |
|
| 156 |
=head3 upgrade_class |
130 |
=head3 upgrade_class |
| 157 |
- |
|
|