#################### main pod documentation begin ################### =head1 NAME Zymonic::Action::NewKeyReset Zymonic Workflow System Action module =head1 SYNOPSIS use Zymonic::Action::NewKeyReset; Resets the new key (in case part of it was not seen or recorded). =head1 DESCRIPTION Resets the new key (in case part of it was not seen or recorded). =head1 USAGE Include the class in the XML. =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::NewKeyReset; 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::NewKeyReset' => { isa => 'Zymonic::Exception::Decryptor::Action', fields => ['decryptor'], description => 'Decryptor related exception', }, 'Zymonic::Exception::Decryptor::Action::NewKeyReset::FindKeyGroup' => { isa => 'Zymonic::Exception::Decryptor::Action::NewKeyReset', fields => [], description => 'Could not find keygroup for user', }, 'Zymonic::Exception::Decryptor::Action::NewKeyReset::DecryptorError' => { isa => 'Zymonic::Exception::Decryptor::Action::NewKeyReset', fields => ['decryptor_error'], description => 'Error from decryptor [[decryptor_error]]', }, ); #################### 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'; # 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} ], } ); Zymonic::Exception::Decryptor::Action::NewKeyReset::FindKeyGroup->throw() unless ref($keygroup) and ref($keygroup) eq 'ARRAY' and scalar( @{$keygroup} ); # Unflag the seen/confirmed. my $form = $self->{state}->{form}; $form->set_field_value( 'zz_df_kek_part1_recorded', 'N' ); $form->set_field_value( 'zz_df_kek_part2_recorded', 'N' ); $form->set_field_value( 'zz_df_backed_up', 'N' ); $form->save( '', 'force' ); my $response = $self->decryptor_client()->call_decryptor( { messagetype => 'NewKeyReset', username => $self->{auth}->{user}, }, '', 'nokey' ); Zymonic::Exception::Decryptor::Action::NewKeyReset::DecryptorError->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;