« FB11X/Preferences/Role/ParameterValueEditing.pm
↑ Summary
Preferences/RolesFor/Result/PrfOwner.pm »
| 1 | |||
| 2 | package OpusVL::Preferences::Schema; | ||
| 3 | |||
| 4 | =head1 SYNOPSIS | ||
| 5 | |||
| 6 | This is the DBIx::Class schema for the Preferences module. | ||
| 7 | |||
| 8 | =head1 ATTRIBUTES | ||
| 9 | |||
| 10 | =head2 encryption_key | ||
| 11 | |||
| 12 | An Encryption key to use for symmetric cryptography of selected fields. | ||
| 13 | |||
| 14 | This will be used in the L<OpusVL::SimpleCrypto> module, see that for | ||
| 15 | how to generate keys. | ||
| 16 | |||
| 17 | =head2 encryption_salt | ||
| 18 | |||
| 19 | A salt to use for symmetric cryptography of selected fields. | ||
| 20 | |||
| 21 | This will be used in the L<OpusVL::SimpleCrypto> module, see that for | ||
| 22 | how to generate keys and salt. | ||
| 23 | |||
| 24 | =head2 encryption_client | ||
| 25 | |||
| 26 | The client to perform encryption. If the key or salt are not provided | ||
| 27 | this will return undef. | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | 4 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 32 | 4 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 33 | 0 | ▶ | use OpusVL::SimpleCrypto; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 34 | |||
| 35 | extends 'DBIx::Class::Schema'; | ||
| 36 | |||
| 37 | has encryption_key => (is => 'rw', isa => 'Str'); | ||
| 38 | has encryption_salt => (is => 'rw', isa => 'Str'); | ||
| 39 | has encryption_client => (is => 'ro', lazy => 1, builder => '_build_encryption_client'); | ||
| 40 | |||
| 41 | sub _build_encryption_client | ||
| 42 | { | ||
| 43 | my $self = shift; | ||
| 44 | return undef unless $self->encryption_salt && $self->encryption_key; | ||
| 45 | my $crypto = OpusVL::SimpleCrypto->new({ | ||
| 46 | key_string => $self->encryption_key, | ||
| 47 | deterministic_salt_string => $self->encryption_salt, | ||
| 48 | }); | ||
| 49 | return $crypto; | ||
| 50 | } | ||
| 51 | |||
| 52 | sub schema_version { 2 } | ||
| 53 | |||
| 54 | __PACKAGE__->load_namespaces; | ||
| 55 | |||
| 56 | __PACKAGE__->meta->make_immutable(inline_constructor => 0); | ||
| 57 | |||
| 58 | 1; | ||
| 59 | |||