[Rt-commit] r9914 - rt/branches/3.7-RTIR-RELENG/lib/RT
ruz at bestpractical.com
ruz at bestpractical.com
Wed Dec 12 11:49:02 EST 2007
Author: ruz
Date: Wed Dec 12 11:49:01 2007
New Revision: 9914
Modified:
rt/branches/3.7-RTIR-RELENG/lib/RT/User_Overlay.pm
Log:
* PrivateKey/SetPrivateKey pair in RT::User
Modified: rt/branches/3.7-RTIR-RELENG/lib/RT/User_Overlay.pm
==============================================================================
--- rt/branches/3.7-RTIR-RELENG/lib/RT/User_Overlay.pm (original)
+++ rt/branches/3.7-RTIR-RELENG/lib/RT/User_Overlay.pm Wed Dec 12 11:49:01 2007
@@ -1654,6 +1654,42 @@
return $prefkey;
}
+sub PrivateKey {
+ my $self = shift;
+
+ my $key = $self->FirstAttribute('PrivateKey') or return undef;
+ return $key->Content;
+}
+
+sub SetPrivateKey {
+ my $self = shift;
+ my $key = shift;
+ # XXX: ACL
+ unless ( $key ) {
+ my ($status, $msg) = $self->DeleteAttribute('PrivateKey');
+ unless ( $status ) {
+ $RT::Logger->error( "Couldn't delete attribute: $msg" );
+ return ($status, $self->loc("Couldn't unset private key"));
+ }
+ return ($status, $self->loc("Unset private key"));
+ }
+
+ # check that it's really private key
+ {
+ my %tmp = RT::Crypt::GnuPG::GetKeysForSigning( $key );
+ return (0, $self->loc("No such key or it's not suitable for signing"))
+ if $tmp{'exit_code'} || !$tmp{'info'};
+ }
+
+ my ($status, $msg) = $self->SetAttribute(
+ Name => 'PrivateKey',
+ Content => $key,
+ );
+ return ($status, $self->loc("Couldn't set private key"))
+ unless $status;
+ return ($status, $self->loc("Unset private key"));
+}
+
sub BasicColumns {
(
[ Name => 'User Id' ],
More information about the Rt-commit
mailing list