#################### main pod documentation begin ################### =head1 NAME Zymonic::Action::SendKeys Zymonic Workflow System Action module =head1 SYNOPSIS use Zymonic::Action::Sendkeys; Works with the KeyEntry Form class to send the key(s) to the Decryptor. =head1 DESCRIPTION Works with the KeyEntry Form class to send the key(s) to the Decryptor. =head1 USAGE Include the class in the XML, must be preceeded by the KeyEntry state. =head1 BUGS NONE =head1 SUPPORT As in the license, Zymonic is provided without warranty or support unless purchased separately, however... If you email zymonic-support@zednax.com your issue will be noted and may receive a response. For security issues, please contact zymonic-security@zednax.com and someone will respond within 8 working hours. =head1 AUTHOR Alex Masidlover et al. CPAN ID: MODAUTHOR Zednax Limited alex.masidlover@zednax.com http://www.zednax.com =head1 COPYRIGHT This program is free software licensed under the... Zymonic Public License 1.0 The full text of the license can be found in the LICENSE file included with this module. Other licenses may be acceptable if including parts of Zymonic in larger projects, please contact Zednax for details. =head1 SEE ALSO Zymonic perl(1). =cut #################### main pod documentation end ################### package Zymonic::Action::SendKeys; use strict; BEGIN { use Exporter (); use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 'D1-r7186'; @ISA = qw(Exporter); #Give a hoot don't pollute, do not export more than needed by default @EXPORT = qw(); @EXPORT_OK = qw(); %EXPORT_TAGS = (); } use base "Zymonic::Action"; use Zymonic; use Exception::Class ( 'Zymonic::Exception::Decryptor' => { isa => 'Zymonic::Exception', fields => ['decryptor'], description => 'Decryptor related exception', }, 'Zymonic::Exception::Decryptor::Action' => { isa => 'Zymonic::Exception::Decryptor', fields => ['decryptor'], description => 'Decryptor related exception', }, 'Zymonic::Exception::Decryptor::Action::SendKeys' => { isa => 'Zymonic::Exception::Decryptor::Action', fields => ['decryptor'], description => 'Decryptor related exception', }, 'Zymonic::Exception::Decryptor::Action::SendKeys::Decryptor' => { isa => 'Zymonic::Exception::Decryptor::Action::SendKeys', fields => ['decryptor_error'], description => 'Error from decryptor: [[decryptor_error]]', }, 'Zymonic::Exception::Decryptor::Action::SendKeys::NoForm' => { isa => 'Zymonic::Exception::Decryptor::Action::SendKeys', description => 'No form or record found to get fields from', }, ); #################### subroutine header begin #################### =head2 do Usage : $action->do Purpose : Performs the action, i.e. generates the report Returns : nothing Argument : nothing Throws : TODO Comment : nothing =cut #################### subroutine header end #################### sub do { my $self = shift; my $fake = shift || ''; my $no_display_attributes = shift || 0; my $conditions = $self->conditions($fake); $self->{condition_passed} = 'false'; $self->{success} = 'false'; if ( $conditions->{condition_passed} ) { $self->{condition_passed} = 'true'; my $form = $self->{state}->{form}; Zymonic::Exception::Decryptor::Action::SendKeys::NoForm->throw() unless $form && $form->{records}->[0]; my @kpc_field_refs = grep { $_->{zname} =~ /^kpc/ } values %{ $form->get_fields( $form->{records}->[0], '', 'refs_only' ) }; # Work out which key group the user is in. my $keygroup = $self->{DB}->run_query( { string => 'SELECT keygroup FROM zz_keyholders WHERE username = ?', params => [ $self->{auth}->{user} ], } ); if ( ref($keygroup) ne 'ARRAY' and scalar( @{$keygroup} ) > 0 ) { $self->{success} = 'true'; return; } my $response = $self->decryptor_client()->call_decryptor( { messagetype => 'SendKEKPart', username => $self->{auth}->{user}, kek_part_number => $keygroup->[0]->{keygroup}, kek_parts => { map { substr( $_->{zname}, 4, 1 ) => $form->get_field_ref_value($_), } @kpc_field_refs } }, 'all', 'nokey' ); Zymonic::Exception::Decryptor::Action::SendKeys::Decryptor->throw( extras => $response, decryptor_error => $response->{error}, catchable => 'true', ) unless $response->{ok}; $self->{success} = 'true'; } } #################### subroutine header begin #################### =head2 decyptor_client Usage : $form->decryptor_client; Purpose : TODO Returns : nothing Argument : nothing Throws : TODO Comment : See Also : =cut #################### subroutine header end #################### sub decryptor_client { my $self = shift; $self->{decryptor_client} = Zymonic::Decryptor::Client->new( parent => $self, config => $self->{config}, db => $self->{DB} ) unless ( defined( $self->{decryptor_client} ) ); return $self->{decryptor_client}; } 1;