-
Notifications
You must be signed in to change notification settings - Fork 0
/
teste.php
67 lines (49 loc) · 2.56 KB
/
teste.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace aafw\php;
error_reporting(E_ALL);
require_once '/home/giovani/Softwares/thrift-0.9.0/lib/php/lib/Thrift/ClassLoader/ThriftClassLoader.php';
//require_once 'C:\\Desenvolvimento\\thrift-0.9.1\\lib\\php\\lib\\Thrift\\ClassLoader\\ThriftClassLoader.php';
use Thrift\ClassLoader\ThriftClassLoader;
$GEN_DIR = '/home/giovani/workspace-kepler/aafw/gen-php';
//$GEN_DIR = 'C:\\Users\\Gica\\Desktop\\gen-php';
$loader = new ThriftClassLoader();
$loader->registerNamespace('Thrift', '/home/giovani/Softwares/thrift-0.9.0/lib/php/lib');
//$loader->registerNamespace('Thrift', 'C:\\Desenvolvimento\\thrift-0.9.1\\lib\\php\\lib');
$loader->registerDefinition('aafw', $GEN_DIR);
$loader->register();
use Thrift\Protocol\TBinaryProtocol;
use Thrift\Transport\TSocket;
use Thrift\Transport\THttpClient;
use Thrift\Transport\TBufferedTransport;
use Thrift\Exception\TException;
try {
$socket = new TSocket('localhost', 9090);
$transport = new TBufferedTransport($socket, 1024, 1024);
$protocol = new TBinaryProtocol($transport);
$client = new \aafw\AAServiceClient($protocol);
$transport->open();
$entityName["2.5.4.3"] = "testee"; // Common Name
$entityName["2.16.76.1.10.1"] = "1"; // Common Name
$holder = new \aafw\ACHolder(array("entityName" => $entityName));
// REQUEST TO SEARCH FOR ATTRIBUTE CERTIFICATES ISSUED FOR 'Giovani Milanez'
// $searchInfo = new \aafw\ACSearchInfo(array("holder" => $holder));
// $req = new \aafw\ACReq(array("searchInfo" => $searchInfo));
// REQUEST TO ISSUE AN ATTRIBUTE CERTIFICATE TO 'Giovani Milanez'
// USING TAMPLATE ID 2
// $templateId = 10;
// $reqInfo = new \aafw\ACIssueInfo(array("holder" => $holder, "templateId" => $templateId));
// $req = new \aafw\ACReq(array("issueInfo" => $reqInfo));
// REQUEST TO ISSUE AN ATTRIBUTE CERTIFICATE TO 'Giovani Milanez'
// USING SPECIFIC VALIDITY AND ATTRIBUTE
$validity = new \aafw\ACValidity(array("notBeforeEpoch" => time(), "notAfterEpoch" => time() + 60 * 60 * 24 * 100 )); // 100 days validity from now
$attributes[] = new \aafw\Attribute(array("oid" => "1.2.3.4.5", "values" => array("Cinema 3D - Senhor dos Anéis. SALA 5")));
$reqInfo = new \aafw\ACIssueInfo(array("holder" => $holder, "attributes" => $attributes, "validity" => $validity));
$req = new \aafw\ACReq(array("issueInfo" => $reqInfo));
$resp = $client->request($req);
var_dump($resp);
//file_put_contents("C:\\Users\\Gica\\Desktop\\ac.pem", $resp->acs[0]["pem"], FILE_APPEND | LOCK_EX);
$transport->close();
} catch (TException $tx) {
print 'TException: '.$tx->getMessage()."\n";
}
?>