#################### main pod documentation begin ################### =head1 NAME Zymonic::Form::ShowKey; - Zymonic Workflow System Form 'ShowKey' module =head1 SYNOPSIS This is a module to show the KEK parts to the appropriate user(s). =head1 DESCRIPTION This is a module to show the KEK parts to the appropriate user(s). =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... Alfresco 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::ShowKey; 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; #################### 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; my $decryptor_status; # Work out which key group the user is in. my $keygroup = $self->{DB}->run_query( { string => 'SELECT keygroup FROM zz_keyholders WHERE username = ? AND (deleted <> \'Y\' OR deleted IS NULL)', params => [ $self->{auth}->{user} ], } ); # Get the decryptor key statuses. my $hosts = []; my $port = ''; if ( $record->{fields}->{zz_df_primary_decryptor_host}->{parent} ->get_object( $record->{fields}->{zz_df_primary_decryptor_host} )->value ) { push( @{$hosts}, $record->{fields}->{zz_df_primary_decryptor_host}->{parent} ->get_object( $record->{fields}->{zz_df_primary_decryptor_host} )->value ); $port = $record->{fields}->{zz_df_primary_decryptor_port}->{parent} ->get_object( $record->{fields}->{zz_df_primary_decryptor_port} )->value; } # Check if any records have been returned. if ( ref($keygroup) eq 'ARRAY' and scalar( @{$keygroup} ) > 0 ) { $decryptor_status = $self->decryptor_client()->call_decryptor( { messagetype => 'GetKEKPart', keygroup => $keygroup->[0]->{keygroup}, username => $self->{auth}->{user}, }, $port, 'nokey', $hosts ); Zymonic::Exception::Decryptor::KeyManagement->throw( error => 'Decryptor GetKEKPart returned error', extras => $decryptor_status, ) if $decryptor_status->{error}; # fill in the KEK part, make correct confirmation read only and set statuses. $record->{fields}->{zz_df_new_keyversion}->{parent}->get_object( $record->{fields}->{zz_df_new_keyversion} ) ->raw_value( $decryptor_status->{new_keyversion}, 'fromdb' ); $record->{fields}->{zz_df_has_kek1}->{parent}->get_object( $record->{fields}->{zz_df_has_kek1} ) ->raw_value( $decryptor_status->{has_kek_part1}, 'fromdb' ); $record->{fields}->{zz_df_has_kek2}->{parent}->get_object( $record->{fields}->{zz_df_has_kek2} ) ->raw_value( $decryptor_status->{has_kek_part2}, 'fromdb' ); unless ($port) { $record->{fields}->{zz_df_primary_decryptor_host}->{parent} ->get_object( $record->{fields}->{zz_df_primary_decryptor_host} ) ->raw_value( $decryptor_status->{primary_hostname}, 'fromdb' ); $record->{fields}->{zz_df_primary_decryptor_port}->{parent} ->get_object( $record->{fields}->{zz_df_primary_decryptor_port} ) ->raw_value( $decryptor_status->{primary_port}, 'fromdb' ); } } # update all fields on record foreach my $field ( map { $self->get_object($_) } values( %{ $self->{records}->[0]->{fields} } ) ) { $field->value( $field->raw_value ); } # Save the parameters now $self->save( '', 'force' ); # Set the non-stored fields if ( ref($keygroup) eq 'ARRAY' and scalar( @{$keygroup} ) > 0 ) { $record->{fields}->{zz_df_kek_part}->{parent}->get_object( $record->{fields}->{zz_df_kek_part} ) ->value( $decryptor_status->{kek_part}, 'fromdb' ); $record->{fields}->{zz_df_kek_part_number}->{parent}->get_object( $record->{fields}->{zz_df_kek_part_number} ) ->value( $keygroup->[0]->{keygroup}, 'fromdb' ); } if ( ref($keygroup) eq 'ARRAY' and scalar( @{$keygroup} ) > 0 and $keygroup->[0]->{keygroup} == 1 ) { $record->{fields}->{zz_df_kek_part2_recorded}->{parent} ->get_object( $record->{fields}->{zz_df_kek_part2_recorded} )->{displayonly} = 'true'; } else { $record->{fields}->{zz_df_kek_part2_recorded}->{parent} ->get_object( $record->{fields}->{zz_df_kek_part2_recorded} )->{displayonly} = 'false'; } if ( ref($keygroup) eq 'ARRAY' and scalar( @{$keygroup} ) > 0 and $keygroup->[0]->{keygroup} == 2 ) { $record->{fields}->{zz_df_kek_part1_recorded}->{parent} ->get_object( $record->{fields}->{zz_df_kek_part1_recorded} )->{displayonly} = 'true'; } else { $record->{fields}->{zz_df_kek_part1_recorded}->{parent} ->get_object( $record->{fields}->{zz_df_kek_part1_recorded} )->{displayonly} = 'false'; } } #################### subroutine header begin #################### =head2 pre_save Usage : $form->pre_save; Purpose : TODO Returns : nothing Argument : nothing Throws : TODO Comment : stub as this form has no table associated with it there is nothign to save on it. See Also : =cut #################### subroutine header end #################### sub pre_save { my $self = shift; # update all fields on record foreach my $field ( map { $_->{parent}->get_object($_) } values( %{ $self->{records}->[0]->{fields} } ) ) { $field->value( $field->raw_value ); } } #################### 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;