#################### main pod documentation begin ################### =head1 NAME Zymonic::Form::ReEncryptStatus; - Zymonic Workflow System Form 'ReEncryptStatus' module =head1 SYNOPSIS This is a module to show the status of re-encryption. =head1 DESCRIPTION This is a module to show the status of re-encryption. =head1 USAGE This module should not be called directly. =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 perl(1). =cut #################### main pod documentation end ################### package Zymonic::Form::ReEncryptStatus; 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::Form"; use Zymonic::Decryptor::Client; use Zymonic; use Exception::Class ( 'Zymonic::Exception::Decryptor' => { isa => 'Zymonic::Exception', fields => ['decryptor'], description => 'Decryptor related exception', }, 'Zymonic::Exception::Decryptor::Form' => { isa => 'Zymonic::Exception::Decryptor', fields => ['decryptor'], description => 'Decryptor related exception', }, 'Zymonic::Exception::Decryptor::Form::ReEncryptStatus' => { isa => 'Zymonic::Exception::Decryptor::Form', fields => [], description => 'Error from decryptor', }, 'Zymonic::Exception::Decryptor::Form::ReEncryptStatus::ReEncryptStatus' => { isa => 'Zymonic::Exception::Decryptor::Form::ReEncryptStatus', fields => ['extras'], description => 'Decryptor ReEncryptStatus returned error', }, 'Zymonic::Exception::Decryptor::Form::ReEncryptStatus::SwitchKeys' => { isa => 'Zymonic::Exception::Decryptor::Form::ReEncryptStatus', fields => ['response_error'], description => 'Unable to switch keys: [[response_error]]', }, ); #################### subroutine header begin #################### =head2 init Usage : N/A Purpose : This is a stub for the init. Returns : nothing Argument : nothing Throws : see the 'See Also' Comment : nothing See Also : =cut #################### subroutine header end #################### sub init { my $self = shift; $self->SUPER::init; $self->populate_record( $self->{records}->[0] ) unless $self->{config}->{building_documentation} && $self->{config}->{building_documentation} eq 'Y'; } #################### subroutine header begin #################### =head2 output_navigation Usage : $self->output_navigation; Purpose : This method returns the navigation ready for transformation to XML. Returns : a hashref containing navigation. Argument : nothing Throws : nothing Comment : This is a stub as the Login form has no navigation... See Also : =cut #################### subroutine header end #################### sub output_navigation { my $self = shift; return {}; } #################### subroutine header begin #################### =head2 populate_record Usage : $form->populate_record($record); Purpose : TODO Returns : nothing Argument : nothing Throws : TODO Comment : See Also : =cut #################### subroutine header end #################### sub populate_record { my $self = shift; my $record = shift; # Get the decryptor key statuses. my $decryptor_status = $self->decryptor_client()->call_decryptor( { messagetype => 'GetReEncryptStatus' }, '', 'nokey' ); Zymonic::Exception::Decryptor::Form::ReEncryptStatus::ReEncryptStatus->throw( extras => $decryptor_status, ) if $decryptor_status->{error}; # Add the re-encryption status $self->set_field_value( 'zz_df_left_to_reencrypt', $decryptor_status->{old_key_count} ); $self->set_field_value( 'zz_df_corrupt_entries', $decryptor_status->{corrupt_count} ); $self->save; } #################### 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}; } #################### subroutine header begin #################### =head2 output Usage : print XMLout($form->output); Purpose : This method generates the output for display/further use. Returns : a hashref suitable for conversion to XML. Argument : A flag indicating no display attributes to be sent. Throws : Zymonic::Exception::Decryptor::Form::ReEncryptStatus::SwitchKeys Comment : See Also : =cut #################### subroutine header end #################### sub output { my $self = shift; # Switch the keys my $decryptor_ks = $self->decryptor_client()->call_decryptor( { messagetype => 'SwitchKeys' }, 'all', 'nokey' ); Zymonic::Exception::Decryptor::Form::ReEncryptStatus::SwitchKeys->throw( response_error => $decryptor_ks->{error}, catchable => 'true' ) if $decryptor_ks->{error}; $self->populate_record( $self->{records}->[0] ) unless $self->{config}->{building_documentation} && $self->{config}->{building_documentation} eq 'Y'; return $self->SUPER::output(@_); } 1;