%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2023 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) %# %# %# LICENSE: %# %# This work is made available to you under the terms of Version 2 of %# the GNU General Public License. A copy of that license should have %# been provided with this software, but in any event can be snarfed %# from www.gnu.org. %# %# This work is distributed in the hope that it will be useful, but %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA %# 02110-1301 or visit their web page on the internet at %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: %# %# (The following paragraph is not intended to limit the rights granted %# to you to modify and distribute this software under the terms of %# the GNU General Public License and is only of importance to you if %# you choose to contribute your changes and enhancements to the %# community by submitting them to Best Practical Solutions, LLC.) %# %# By intentionally submitting any modifications, corrections or %# derivatives to this work, or any other work intended for use with %# Request Tracker, to Best Practical Solutions, LLC, you confirm that %# you are the copyright holder for those contributions and you grant %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, %# royalty-free, perpetual, license to use, copy, create derivative %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# %# END BPS TAGGED BLOCK }}} <& /Admin/Elements/Header, Title => $title &> <& /Elements/Tabs &> <& /Elements/ListActions &> <&|/Widgets/TitleBox, title => loc('Import Keys') &>
% my %options = RT->Config->Get('GnuPGOptions'); % if ( $options{'keyserver'} ) { % if ( @search_results ) { % for my $item ( @search_results ) { % } % } % }
<&|/l&>Check All
<&|/l&>Key: <% $item->{Summary} %>
<&|/l&>Content:
<& /Elements/Submit, Name => 'Import', Label => loc('Import') &>
<&|/Widgets/TitleBox, title => loc('GnuPG Public Keys') &> % if ( $public{info} && @{$public{info}} ) {
% for my $item ( @{$public{info}} ) { % }
<% loc('Summary') %> <% loc('Trust Level') %>
{Fingerprint}} ? 'checked="checked"' : '' |n %> /> <% $item->{Formatted} %> <% $owner_trust_level{$item->{OwnerTrustChar}} || loc('Not set') %>

<% loc('Trust Level' ) %>
<& /Elements/Submit, Label => loc('Delete'), Name => 'DeletePublic', CheckboxNameRegex => '/^PublicKey(All)?$/', CheckAll => 1, ClearAll => 1 &> <& /Elements/Submit, Label => loc('Save Changes'), Name => 'TrustPublic' &>
% } else {

<&|/l&>No public keys found.

% } <&|/Widgets/TitleBox, title => loc('GnuPG Private Keys') &> % if ( $private{info} && @{$private{info}} ) {
% for my $item ( @{$private{info}} ) { % }
<% loc('Summary') %>
{Fingerprint}} ? 'checked="checked"' : '' |n %> /> <% $item->{Formatted} %>

<& /Elements/Submit, Label => loc('Delete'), Name => 'DeletePrivate', CheckboxNameRegex => '/^PrivateKey(All)?$/', CheckAll => 1, ClearAll => 1 &>
% } else {

<&|/l&>No private keys found.

% } <%INIT> my $title = loc('Manage GnuPG Keys'); unless ( $session{'CurrentUser'}->HasRight( Object => $RT::System, Right => 'SuperUser' ) ) { Abort( loc('This feature is only available to system administrators.') ); } my @results; my %delete; my %owner_trust_level = ( 1 => loc("I don't know or won't say"), 2 => loc("I do NOT trust"), 3 => loc("I trust marginally"), 4 => loc("I trust fully"), 5 => loc("I trust ultimately"), q => loc("I don't know or won't say"), n => loc("I do NOT trust"), m => loc("I trust marginally"), f => loc("I trust fully"), u => loc("I trust ultimately"), ); require RT::Crypt::GnuPG; my @search_results; if ( $ARGS{Search} ) { if ( $ARGS{Query} ) { my %ret = RT::Crypt::GnuPG->SearchKey( $ARGS{Query} ); @search_results = @{$ret{results}}; push @results, split /\n+/, $ret{logger} unless @search_results; } } elsif ( $ARGS{Import} ) { # show admin detailed imported messages if ( $ARGS{Key} ) { for my $key ( ref $ARGS{Key} ? @{ $ARGS{Key} } : $ARGS{Key} ) { my %ret = RT::Crypt::GnuPG->ReceiveKey( $key ); push @results, split /\n+/, $ret{logger}; } } if ( $ARGS{Content} ) { my %ret = RT::Crypt::GnuPG->ImportKey( $ARGS{Content} ); push @results, split /\n+/, $ret{logger}; } } elsif ( $ARGS{TrustPublic} ) { if ( length $ARGS{OwnerTrustLevel} && $ARGS{PublicKey} ) { for my $key ( ref $ARGS{PublicKey} ? @{ $ARGS{PublicKey} } : $ARGS{PublicKey} ) { my %ret = RT::Crypt::GnuPG->TrustKey( $key, $ARGS{OwnerTrustLevel} ); if ( $ret{exit_code} == 0 ) { if ( $ret{logger} ) { # success messages are like "changing ownertrust # from 6 to 4", which is useless and misleading to # end users, so we hide them here. RT->Logger->debug( $ret{logger} ); push @results, loc( "Key [_1] trust level is updated", substr( $key, -8 ) ); } } elsif ( $ret{logger} ) { push @results, split /\n+/, $ret{logger}; } } } } else { for my $type (qw/Public Private/) { next unless $ARGS{"Delete$type"}; my $value = $ARGS{"${type}Key"}; for my $key ( ref $value ? @$value : $value ) { $delete{$key} ||= 1; my %ret = RT::Crypt::GnuPG->DeleteKey($key); if ( $ret{exit_code} == 0 ) { # delete is silent, no extra debug messages push @results, loc( "Key [_1] is deleted", substr( $key, -8 ) ); } elsif ( $ret{logger} ) { push @results, split /\n+/, $ret{logger}; } } } } MaybeRedirectForResults( Actions => \@results, Path => '/Admin/Tools/GnuPG.html', ); my %public = RT::Crypt::GnuPG->GetKeysInfo( Force => 1 ); my %private = RT::Crypt::GnuPG->GetKeysInfo( Force => 1, Type => 'private' ); <%ARGS> $OwnerTrustLevel => ''