<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package PGP::Certificate::Userid;

use strict;

use Carp;

sub new {
    my ($classname, $packet) = @_;

    bless {
	"packet" =&gt; $packet,
    }, $classname;
}

sub add_signature {
    my ($self, $sig, $keyid) = @_;

    if ($keyid eq $sig-&gt;issuer) {
	if (!$self-&gt;{"self_signature"} ||
	    $self-&gt;{"self_signature"}-&gt;created &lt; $sig-&gt;created) {
	    $self-&gt;{"self_signature"} = $sig;
	}
    } else {
	if (!$self-&gt;{"other_signatures"}-&gt;{$sig-&gt;issuer} ||
	    ($self-&gt;{"other_signatures"}-&gt;{$sig-&gt;issuer}-&gt;created &lt;
	     $sig-&gt;created)) {
	    $self-&gt;{"other_signatures"}-&gt;{$sig-&gt;issuer} = $sig;
	}
    }
}

sub packet {
    my ($this) = @_;
    $this-&gt;{"packet"};
}

sub name {
    my ($self) = @_;

    $self-&gt;{"packet"}-&gt;name;
}

sub self_signature {
    my ($self) = @_;

    $self-&gt;{"self_signature"};
}

sub primary_userid {
    my ($self) = @_;

    ($self-&gt;self_signature &amp;&amp;
     $self-&gt;self_signature-&gt;subpacket("primary_userid"));
}

sub other_signatures {
    my ($self) = @_;

    [ sort { $b-&gt;created &lt;=&gt; $a-&gt;created }
      (values %{$self-&gt;{"other_signatures"}}) ];
}

sub signatures {
    my ($self) = @_;

    if ($self-&gt;{"self_signature"}) {
	return ([ $self-&gt;{"self_signature"},
		  sort { $b-&gt;created &lt;=&gt; $a-&gt;created }
		  (values %{$self-&gt;{"other_signatures"}}) ]);
    } else {
	return ([ sort { $b-&gt;created &lt;=&gt; $a-&gt;created }
		  (values %{$self-&gt;{"other_signatures"}}) ]);
    }
};

1;
</pre></body></html>