@@ -15,36 +15,36 @@ |
||
15 | 15 | |
16 | 16 | final class Payment extends Response |
17 | 17 | { |
18 | - /** |
|
19 | - * @var \DOMElement |
|
20 | - */ |
|
21 | - protected $PaymentId; |
|
22 | - |
|
23 | - /** |
|
24 | - * Payment constructor |
|
25 | - * |
|
26 | - * @param string $paymentid |
|
27 | - */ |
|
28 | - public function __construct($paymentid) |
|
29 | - { |
|
30 | - parent::__construct(); |
|
31 | - |
|
32 | - $this->setElementValue('StatusCode', 0); |
|
33 | - $this->setElementValue('StatusDetail', 'checked'); |
|
34 | - |
|
35 | - $this->create_PaymentId($paymentid); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * Create PaymentId node |
|
40 | - * |
|
41 | - * @param string $paymentid |
|
42 | - */ |
|
43 | - public function create_PaymentId($paymentid) |
|
44 | - { |
|
45 | - if (isset($this->PaymentId)) return; |
|
46 | - |
|
47 | - $this->PaymentId = $this->createElement('PaymentId', $paymentid); |
|
48 | - $this->Response->appendChild($this->PaymentId); |
|
49 | - } |
|
18 | + /** |
|
19 | + * @var \DOMElement |
|
20 | + */ |
|
21 | + protected $PaymentId; |
|
22 | + |
|
23 | + /** |
|
24 | + * Payment constructor |
|
25 | + * |
|
26 | + * @param string $paymentid |
|
27 | + */ |
|
28 | + public function __construct($paymentid) |
|
29 | + { |
|
30 | + parent::__construct(); |
|
31 | + |
|
32 | + $this->setElementValue('StatusCode', 0); |
|
33 | + $this->setElementValue('StatusDetail', 'checked'); |
|
34 | + |
|
35 | + $this->create_PaymentId($paymentid); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * Create PaymentId node |
|
40 | + * |
|
41 | + * @param string $paymentid |
|
42 | + */ |
|
43 | + public function create_PaymentId($paymentid) |
|
44 | + { |
|
45 | + if (isset($this->PaymentId)) return; |
|
46 | + |
|
47 | + $this->PaymentId = $this->createElement('PaymentId', $paymentid); |
|
48 | + $this->Response->appendChild($this->PaymentId); |
|
49 | + } |
|
50 | 50 | } |
@@ -42,7 +42,9 @@ |
||
42 | 42 | */ |
43 | 43 | public function create_PaymentId($paymentid) |
44 | 44 | { |
45 | - if (isset($this->PaymentId)) return; |
|
45 | + if (isset($this->PaymentId)) { |
|
46 | + return; |
|
47 | + } |
|
46 | 48 | |
47 | 49 | $this->PaymentId = $this->createElement('PaymentId', $paymentid); |
48 | 50 | $this->Response->appendChild($this->PaymentId); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @var array list of possible operations |
47 | 47 | */ |
48 | - protected $operations = array('Check','Payment','Confirm','Cancel'); |
|
48 | + protected $operations = array('Check', 'Payment', 'Confirm', 'Cancel'); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * General constructor |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $doc = new \DOMDocument(); |
116 | 116 | if ( ! $doc->loadXML($this->raw_request)) |
117 | 117 | { |
118 | - foreach(libxml_get_errors() as $e){ |
|
118 | + foreach (libxml_get_errors() as $e) { |
|
119 | 119 | Log::instance()->error($e->message); |
120 | 120 | } |
121 | 121 | throw new Exception\Structure('The wrong XML is received', -51); |
@@ -313,9 +313,9 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @return array nodes with the name |
315 | 315 | */ |
316 | - protected function getNodes($dom, $name, $ret=array()) |
|
316 | + protected function getNodes($dom, $name, $ret = array()) |
|
317 | 317 | { |
318 | - foreach($dom->childNodes as $child) |
|
318 | + foreach ($dom->childNodes as $child) |
|
319 | 319 | { |
320 | 320 | if ($child->nodeName == $name) |
321 | 321 | { |
@@ -18,108 +18,108 @@ discard block |
||
18 | 18 | |
19 | 19 | class General |
20 | 20 | { |
21 | - /** |
|
22 | - * @var string raw request |
|
23 | - */ |
|
24 | - protected $raw_request; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var string 'DateTime' node |
|
28 | - */ |
|
29 | - protected $DateTime; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var string 'Sign' node |
|
33 | - */ |
|
34 | - protected $Sign; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var string 'Operation' type |
|
38 | - */ |
|
39 | - protected $Operation; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var string 'ServiceId' node |
|
43 | - */ |
|
44 | - protected $ServiceId; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var array list of possible operations |
|
48 | - */ |
|
49 | - protected $operations = array('Check','Payment','Confirm','Cancel'); |
|
50 | - |
|
51 | - /** |
|
52 | - * General constructor |
|
53 | - * |
|
54 | - * @param string $raw Raw request data |
|
55 | - */ |
|
56 | - public function __construct($raw) |
|
57 | - { |
|
21 | + /** |
|
22 | + * @var string raw request |
|
23 | + */ |
|
24 | + protected $raw_request; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var string 'DateTime' node |
|
28 | + */ |
|
29 | + protected $DateTime; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var string 'Sign' node |
|
33 | + */ |
|
34 | + protected $Sign; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var string 'Operation' type |
|
38 | + */ |
|
39 | + protected $Operation; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var string 'ServiceId' node |
|
43 | + */ |
|
44 | + protected $ServiceId; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var array list of possible operations |
|
48 | + */ |
|
49 | + protected $operations = array('Check','Payment','Confirm','Cancel'); |
|
50 | + |
|
51 | + /** |
|
52 | + * General constructor |
|
53 | + * |
|
54 | + * @param string $raw Raw request data |
|
55 | + */ |
|
56 | + public function __construct($raw) |
|
57 | + { |
|
58 | 58 | $this->raw_request = strval($raw); |
59 | 59 | |
60 | 60 | $this->parse_request_data(); |
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Get DateTime |
|
65 | - * |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function DateTime() |
|
69 | - { |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Get DateTime |
|
65 | + * |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function DateTime() |
|
69 | + { |
|
70 | 70 | return $this->DateTime; |
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Get Sign |
|
75 | - * |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function Sign() |
|
79 | - { |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Get Sign |
|
75 | + * |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function Sign() |
|
79 | + { |
|
80 | 80 | return $this->Sign; |
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Get Operation type |
|
85 | - * |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - public function Operation() |
|
89 | - { |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Get Operation type |
|
85 | + * |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + public function Operation() |
|
89 | + { |
|
90 | 90 | return $this->Operation; |
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Get ServiceId |
|
95 | - * |
|
96 | - * @return string |
|
97 | - */ |
|
98 | - public function ServiceId() |
|
99 | - { |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Get ServiceId |
|
95 | + * |
|
96 | + * @return string |
|
97 | + */ |
|
98 | + public function ServiceId() |
|
99 | + { |
|
100 | 100 | return $this->ServiceId; |
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Parse xml-request, which was previously "extracted" from the body of the http request |
|
105 | - * |
|
106 | - * @throws Exception\Structure |
|
107 | - */ |
|
108 | - protected function parse_request_data() |
|
109 | - { |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Parse xml-request, which was previously "extracted" from the body of the http request |
|
105 | + * |
|
106 | + * @throws Exception\Structure |
|
107 | + */ |
|
108 | + protected function parse_request_data() |
|
109 | + { |
|
110 | 110 | if (empty($this->raw_request)) |
111 | 111 | { |
112 | - throw new Exception\Structure('An empty xml request', -50); |
|
112 | + throw new Exception\Structure('An empty xml request', -50); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | libxml_use_internal_errors(true); |
116 | 116 | $doc = new \DOMDocument(); |
117 | 117 | if ( ! $doc->loadXML($this->raw_request)) |
118 | 118 | { |
119 | - foreach(libxml_get_errors() as $e){ |
|
119 | + foreach(libxml_get_errors() as $e){ |
|
120 | 120 | Log::instance()->error($e->message); |
121 | - } |
|
122 | - throw new Exception\Structure('The wrong XML is received', -51); |
|
121 | + } |
|
122 | + throw new Exception\Structure('The wrong XML is received', -51); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | // process <Request> group |
@@ -127,35 +127,35 @@ discard block |
||
127 | 127 | |
128 | 128 | if (count($r) < 1) |
129 | 129 | { |
130 | - throw new Exception\Structure('The xml-query does not contain any element Request!', -52); |
|
130 | + throw new Exception\Structure('The xml-query does not contain any element Request!', -52); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | foreach ($r[0]->childNodes as $child) |
134 | 134 | { |
135 | - if ($child->nodeName == 'DateTime') |
|
136 | - { |
|
135 | + if ($child->nodeName == 'DateTime') |
|
136 | + { |
|
137 | 137 | $this->parse_request_node($child, 'DateTime'); |
138 | - } |
|
139 | - elseif ($child->nodeName == 'Sign') |
|
140 | - { |
|
138 | + } |
|
139 | + elseif ($child->nodeName == 'Sign') |
|
140 | + { |
|
141 | 141 | $this->parse_request_node($child, 'Sign'); |
142 | - } |
|
143 | - elseif (in_array($child->nodeName, $this->operations)) |
|
144 | - { |
|
142 | + } |
|
143 | + elseif (in_array($child->nodeName, $this->operations)) |
|
144 | + { |
|
145 | 145 | if ( ! isset($this->Operation)) |
146 | 146 | { |
147 | - $this->Operation = $child->nodeName; |
|
147 | + $this->Operation = $child->nodeName; |
|
148 | 148 | } |
149 | 149 | else |
150 | 150 | { |
151 | - throw new Exception\Structure('There is more than one Operation type element in the xml-query!', -53); |
|
151 | + throw new Exception\Structure('There is more than one Operation type element in the xml-query!', -53); |
|
152 | + } |
|
152 | 153 | } |
153 | - } |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | if ( ! isset($this->Operation)) |
157 | 157 | { |
158 | - throw new Exception\Structure('There is no Operation type element in the xml request!', -55); |
|
158 | + throw new Exception\Structure('There is no Operation type element in the xml request!', -55); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | // process <Operation> group |
@@ -163,42 +163,42 @@ discard block |
||
163 | 163 | |
164 | 164 | foreach ($r[0]->childNodes as $child) |
165 | 165 | { |
166 | - if ($child->nodeName == 'ServiceId') |
|
167 | - { |
|
166 | + if ($child->nodeName == 'ServiceId') |
|
167 | + { |
|
168 | 168 | $this->parse_request_node($child, 'ServiceId'); |
169 | - } |
|
169 | + } |
|
170 | + } |
|
170 | 171 | } |
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Parse node of request |
|
175 | - * |
|
176 | - * @param \DOMNode $n |
|
177 | - * @param string $name |
|
178 | - * |
|
179 | - * @throws Exception\Structure |
|
180 | - */ |
|
181 | - protected function parse_request_node($n, $name) |
|
182 | - { |
|
172 | + |
|
173 | + /** |
|
174 | + * Parse node of request |
|
175 | + * |
|
176 | + * @param \DOMNode $n |
|
177 | + * @param string $name |
|
178 | + * |
|
179 | + * @throws Exception\Structure |
|
180 | + */ |
|
181 | + protected function parse_request_node($n, $name) |
|
182 | + { |
|
183 | 183 | if ( ! isset($this->$name)) |
184 | 184 | { |
185 | - $this->$name = $n->nodeValue; |
|
185 | + $this->$name = $n->nodeValue; |
|
186 | 186 | } |
187 | 187 | else |
188 | 188 | { |
189 | - throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56); |
|
189 | + throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56); |
|
190 | 190 | } |
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * "Rough" validation of the received xml request |
|
195 | - * |
|
196 | - * @param array $options |
|
197 | - * @throws Exception\Data |
|
198 | - * @throws Exception\Structure |
|
199 | - */ |
|
200 | - public function validate_request($options) |
|
201 | - { |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * "Rough" validation of the received xml request |
|
195 | + * |
|
196 | + * @param array $options |
|
197 | + * @throws Exception\Data |
|
198 | + * @throws Exception\Structure |
|
199 | + */ |
|
200 | + public function validate_request($options) |
|
201 | + { |
|
202 | 202 | $this->validate_element('DateTime'); |
203 | 203 | $this->validate_element('Sign'); |
204 | 204 | $this->validate_element('ServiceId'); |
@@ -206,104 +206,104 @@ discard block |
||
206 | 206 | // compare received value ServiceId with option ServiceId |
207 | 207 | if (intval($options['ServiceId']) != intval($this->ServiceId)) |
208 | 208 | { |
209 | - throw new Exception\Data('This request is not for our ServiceId!', -58); |
|
209 | + throw new Exception\Data('This request is not for our ServiceId!', -58); |
|
210 | + } |
|
210 | 211 | } |
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Validation of xml-element |
|
215 | - * |
|
216 | - * @param string $name |
|
217 | - */ |
|
218 | - public function validate_element($name) |
|
219 | - { |
|
212 | + |
|
213 | + /** |
|
214 | + * Validation of xml-element |
|
215 | + * |
|
216 | + * @param string $name |
|
217 | + */ |
|
218 | + public function validate_element($name) |
|
219 | + { |
|
220 | 220 | if ( ! isset($this->$name)) |
221 | 221 | { |
222 | - throw new Exception\Structure('There is no '.$name.' element in the xml request!', -57); |
|
222 | + throw new Exception\Structure('There is no '.$name.' element in the xml request!', -57); |
|
223 | + } |
|
223 | 224 | } |
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * Verify signature of request |
|
228 | - * |
|
229 | - * @param array $options |
|
230 | - */ |
|
231 | - public function verify_sign($options) |
|
232 | - { |
|
225 | + |
|
226 | + /** |
|
227 | + * Verify signature of request |
|
228 | + * |
|
229 | + * @param array $options |
|
230 | + */ |
|
231 | + public function verify_sign($options) |
|
232 | + { |
|
233 | 233 | if (isset($options['UseSign']) && ($options['UseSign'] === true)) |
234 | 234 | { |
235 | - $this->check_verify_sign_result( |
|
235 | + $this->check_verify_sign_result( |
|
236 | 236 | $result = (new OpenSSL())->verify( |
237 | - str_replace($this->Sign, '', $this->raw_request), |
|
238 | - pack("H*", $this->Sign), |
|
239 | - (new OpenSSL())->get_pub_key($this->get_pub_key($options)) |
|
237 | + str_replace($this->Sign, '', $this->raw_request), |
|
238 | + pack("H*", $this->Sign), |
|
239 | + (new OpenSSL())->get_pub_key($this->get_pub_key($options)) |
|
240 | 240 | ) |
241 | - ); |
|
241 | + ); |
|
242 | + } |
|
242 | 243 | } |
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * load file with easysoft public key |
|
247 | - * |
|
248 | - * @param array $options |
|
249 | - * @throws Exception\Runtime |
|
250 | - * @return string |
|
251 | - */ |
|
252 | - protected function get_pub_key($options) |
|
253 | - { |
|
244 | + |
|
245 | + /** |
|
246 | + * load file with easysoft public key |
|
247 | + * |
|
248 | + * @param array $options |
|
249 | + * @throws Exception\Runtime |
|
250 | + * @return string |
|
251 | + */ |
|
252 | + protected function get_pub_key($options) |
|
253 | + { |
|
254 | 254 | if ( ! isset($options['EasySoftPKey'])) |
255 | 255 | { |
256 | - throw new Exception\Runtime('The parameter EasySoftPKey is not set!', -94); |
|
256 | + throw new Exception\Runtime('The parameter EasySoftPKey is not set!', -94); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | return (new Key())->get($options['EasySoftPKey'], 'public'); |
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * check result of openssl verify signature |
|
264 | - * |
|
265 | - * @param integer $result |
|
266 | - * @throws Exception\Sign |
|
267 | - */ |
|
268 | - protected function check_verify_sign_result($result) |
|
269 | - { |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * check result of openssl verify signature |
|
264 | + * |
|
265 | + * @param integer $result |
|
266 | + * @throws Exception\Sign |
|
267 | + */ |
|
268 | + protected function check_verify_sign_result($result) |
|
269 | + { |
|
270 | 270 | if ($result == -1) |
271 | 271 | { |
272 | - throw new Exception\Sign('Error verify signature of request!', -96); |
|
272 | + throw new Exception\Sign('Error verify signature of request!', -96); |
|
273 | 273 | } |
274 | 274 | elseif ($result == 0) |
275 | 275 | { |
276 | - throw new Exception\Sign('Signature of request is incorrect!', -95); |
|
276 | + throw new Exception\Sign('Signature of request is incorrect!', -95); |
|
277 | 277 | } |
278 | - } |
|
279 | - |
|
280 | - /** |
|
281 | - * Selects nodes by name |
|
282 | - * |
|
283 | - * @param \DOMDocument $dom |
|
284 | - * @param string $name |
|
285 | - * @param array $ret |
|
286 | - * |
|
287 | - * @return array nodes with the name |
|
288 | - */ |
|
289 | - protected function getNodes($dom, $name, $ret=array()) |
|
290 | - { |
|
278 | + } |
|
279 | + |
|
280 | + /** |
|
281 | + * Selects nodes by name |
|
282 | + * |
|
283 | + * @param \DOMDocument $dom |
|
284 | + * @param string $name |
|
285 | + * @param array $ret |
|
286 | + * |
|
287 | + * @return array nodes with the name |
|
288 | + */ |
|
289 | + protected function getNodes($dom, $name, $ret=array()) |
|
290 | + { |
|
291 | 291 | foreach($dom->childNodes as $child) |
292 | 292 | { |
293 | - if ($child->nodeName == $name) |
|
294 | - { |
|
293 | + if ($child->nodeName == $name) |
|
294 | + { |
|
295 | 295 | array_push($ret, $child); |
296 | - } |
|
297 | - else |
|
298 | - { |
|
296 | + } |
|
297 | + else |
|
298 | + { |
|
299 | 299 | if (count($child->childNodes) > 0) |
300 | 300 | { |
301 | - $ret = $this->getNodes($child, $name, $ret); |
|
301 | + $ret = $this->getNodes($child, $name, $ret); |
|
302 | + } |
|
302 | 303 | } |
303 | - } |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | return $ret; |
307 | - } |
|
307 | + } |
|
308 | 308 | |
309 | 309 | } |
@@ -135,18 +135,15 @@ discard block |
||
135 | 135 | if ($child->nodeName == 'DateTime') |
136 | 136 | { |
137 | 137 | $this->parse_request_node($child, 'DateTime'); |
138 | - } |
|
139 | - elseif ($child->nodeName == 'Sign') |
|
138 | + } elseif ($child->nodeName == 'Sign') |
|
140 | 139 | { |
141 | 140 | $this->parse_request_node($child, 'Sign'); |
142 | - } |
|
143 | - elseif (in_array($child->nodeName, $this->operations)) |
|
141 | + } elseif (in_array($child->nodeName, $this->operations)) |
|
144 | 142 | { |
145 | 143 | if ( ! isset($this->Operation)) |
146 | 144 | { |
147 | 145 | $this->Operation = $child->nodeName; |
148 | - } |
|
149 | - else |
|
146 | + } else |
|
150 | 147 | { |
151 | 148 | throw new Exception\Structure('There is more than one Operation type element in the xml-query!', -53); |
152 | 149 | } |
@@ -183,8 +180,7 @@ discard block |
||
183 | 180 | if ( ! isset($this->$name)) |
184 | 181 | { |
185 | 182 | $this->$name = $n->nodeValue; |
186 | - } |
|
187 | - else |
|
183 | + } else |
|
188 | 184 | { |
189 | 185 | throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56); |
190 | 186 | } |
@@ -270,8 +266,7 @@ discard block |
||
270 | 266 | if ($result == -1) |
271 | 267 | { |
272 | 268 | throw new Exception\Sign('Error verify signature of request!', -96); |
273 | - } |
|
274 | - elseif ($result == 0) |
|
269 | + } elseif ($result == 0) |
|
275 | 270 | { |
276 | 271 | throw new Exception\Sign('Signature of request is incorrect!', -95); |
277 | 272 | } |
@@ -293,8 +288,7 @@ discard block |
||
293 | 288 | if ($child->nodeName == $name) |
294 | 289 | { |
295 | 290 | array_push($ret, $child); |
296 | - } |
|
297 | - else |
|
291 | + } else |
|
298 | 292 | { |
299 | 293 | if (count($child->childNodes) > 0) |
300 | 294 | { |
@@ -4,76 +4,76 @@ |
||
4 | 4 | |
5 | 5 | class OpenSSL |
6 | 6 | { |
7 | - public function __construct() {} |
|
7 | + public function __construct() {} |
|
8 | 8 | |
9 | - /** |
|
10 | - * verify signature of xml |
|
11 | - * |
|
12 | - * @param string $xml |
|
13 | - * @param string $bin_sign |
|
14 | - * @param resource $pub_key |
|
15 | - * |
|
16 | - * @return integer result of checking |
|
17 | - */ |
|
18 | - public function verify($xml, $bin_sign, $pub_key) |
|
19 | - { |
|
9 | + /** |
|
10 | + * verify signature of xml |
|
11 | + * |
|
12 | + * @param string $xml |
|
13 | + * @param string $bin_sign |
|
14 | + * @param resource $pub_key |
|
15 | + * |
|
16 | + * @return integer result of checking |
|
17 | + */ |
|
18 | + public function verify($xml, $bin_sign, $pub_key) |
|
19 | + { |
|
20 | 20 | return @openssl_verify($xml, $bin_sign, $pub_key); |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * generate signature of xml |
|
25 | - * |
|
26 | - * @param string $xml |
|
27 | - * @param string $sign |
|
28 | - * @param resource $priv_key |
|
29 | - * |
|
30 | - * @return bool result of signing |
|
31 | - */ |
|
32 | - public function sign($xml, &$sign, $priv_key) |
|
33 | - { |
|
23 | + /** |
|
24 | + * generate signature of xml |
|
25 | + * |
|
26 | + * @param string $xml |
|
27 | + * @param string $sign |
|
28 | + * @param resource $priv_key |
|
29 | + * |
|
30 | + * @return bool result of signing |
|
31 | + */ |
|
32 | + public function sign($xml, &$sign, $priv_key) |
|
33 | + { |
|
34 | 34 | return @openssl_sign($xml, $sign, $priv_key); |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * get public key |
|
39 | - * |
|
40 | - * @param mixed $certificate |
|
41 | - * @return resource |
|
42 | - */ |
|
43 | - public function get_pub_key($certificate) |
|
44 | - { |
|
37 | + /** |
|
38 | + * get public key |
|
39 | + * |
|
40 | + * @param mixed $certificate |
|
41 | + * @return resource |
|
42 | + */ |
|
43 | + public function get_pub_key($certificate) |
|
44 | + { |
|
45 | 45 | $pub_key = @openssl_pkey_get_public($certificate); |
46 | 46 | $this->is_key($pub_key); |
47 | 47 | |
48 | 48 | return $pub_key; |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * get private key |
|
53 | - * |
|
54 | - * @param mixed $certificate |
|
55 | - * @return resource |
|
56 | - */ |
|
57 | - public function get_priv_key($certificate) |
|
58 | - { |
|
51 | + /** |
|
52 | + * get private key |
|
53 | + * |
|
54 | + * @param mixed $certificate |
|
55 | + * @return resource |
|
56 | + */ |
|
57 | + public function get_priv_key($certificate) |
|
58 | + { |
|
59 | 59 | $priv_key = @openssl_pkey_get_private($certificate); |
60 | 60 | $this->is_key($priv_key); |
61 | 61 | |
62 | 62 | return $priv_key; |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * check key |
|
67 | - * |
|
68 | - * @param resource $key |
|
69 | - * @throws Exception\Runtime |
|
70 | - */ |
|
71 | - public function is_key($key) |
|
72 | - { |
|
65 | + /** |
|
66 | + * check key |
|
67 | + * |
|
68 | + * @param resource $key |
|
69 | + * @throws Exception\Runtime |
|
70 | + */ |
|
71 | + public function is_key($key) |
|
72 | + { |
|
73 | 73 | if ($key === FALSE) |
74 | 74 | { |
75 | - throw new Exception\Runtime('Can not extract key from certificate!', -97); |
|
75 | + throw new Exception\Runtime('Can not extract key from certificate!', -97); |
|
76 | + } |
|
76 | 77 | } |
77 | - } |
|
78 | 78 | |
79 | 79 | } |