Smutty

MVC Framework

View Code: Smutty_GPG_ValidSignature

Browse: All · Classes · Plugins

1
<?php
2
3
/**
4
* represents a valid GPG signature, provides a few methods for
5
* extracting information about the sig.
6
*
7
*/
8
10
11
/** the signature text */
12
private $text;
13
14
/** owner of signature */
15
private $name;
16
17
/** sigs key id */
18
private $keyId;
19
20
/**
21
* constructor. the input should be an array of lines which
22
* are the output of a successful attempt to verify a pgp sig.
23
*
24
* @param array $results array of strings
25
* @return nothing
26
*
27
*/
28
29
public function __construct( $results ) {
30
31
$this->text = implode( "\n", $results );
32
33
// contains names of properties, and a regexp
34
// which will extract that prop from $results
35
$props = array(
36
'name' => '/signature from "(.+)"/',
37
'keyId' => '/key ID ([A-Z0-9]+)/'
38
);
39
40
// extract properties from results
41
foreach ( $props as $key => $regexp )
42
foreach ( $results as $line )
43
if ( preg_match($regexp,$line,$matches) )
44
$this->$key = $matches[1];
45
46
}
47
48
/**
49
* returns the complete text of the verify result
50
*
51
* @return String message text
52
*
53
*/
54
55
public function getText() {
56
return $this->text;
57
}
58
59
/**
60
* returns the name associated with the sig
61
*
62
* @return String user name
63
*
64
*/
65
66
public function getName() {
67
return $this->name;
68
}
69
70
/**
71
* returns the keys id
72
*
73
* @return String key id
74
*
75
*/
76
77
public function getKeyId() {
78
return $this->keyId;
79
}
80
81
}
82
83
?>

The code shown here is the code that is currently running this site. If you want to view the latest SVN version of the code then go to the Subversion repository.