コード例 #1
0
 public static function create($privateKey, $publicKey, $privateKeyPassword = null)
 {
     $userData = new UserData();
     $userData->class = Constants::VIRGIL_USER_DATA_CLASS;
     $userData->type = Constants::VIRGIL_USER_DATA_TYPE;
     $userData->value = Constants::VIRGIL_USER_DATA_VALUE1;
     $userDataCollection = new UserDataCollection();
     $userDataCollection->add($userData);
     $keysClient = self::getKeysClient();
     return $keysClient->getPublicKeysClient()->createKey($publicKey, $userDataCollection, $privateKey, $privateKeyPassword);
 }
コード例 #2
0
 * POSSIBILITY OF SUCH DAMAGE.
 */
require_once '../vendor/autoload.php';
use Virgil\SDK\Keys\Models\UserData, Virgil\SDK\Keys\Models\UserDataCollection, Virgil\SDK\Keys\Client as KeysClient;
const VIRGIL_APPLICATION_TOKEN = '17da4b6d03fad06954b5dccd82439b10';
const VIRGIL_USER_DATA_CLASS = 'user_id';
const VIRGIL_USER_DATA_TYPE = 'email';
const VIRGIL_USER_DATA_VALUE = '*****@*****.**';
const VIRGIL_PRIVATE_KEY_PASSWORD = '******';
try {
    // Create Keys Service HTTP Client
    $keysClient = new KeysClient(VIRGIL_APPLICATION_TOKEN);
    $userData = new UserData();
    $userData->class = VIRGIL_USER_DATA_CLASS;
    $userData->type = VIRGIL_USER_DATA_TYPE;
    $userData->value = VIRGIL_USER_DATA_VALUE;
    $userDataCollection = new UserDataCollection();
    $userDataCollection->add($userData);
    echo 'Reading Public Key.' . PHP_EOL;
    $publicKey = file_get_contents('../data/public.key');
    echo 'Public Key data successfully read.' . PHP_EOL;
    echo 'Reading Private Key.' . PHP_EOL;
    $privateKey = file_get_contents('../data/private.key');
    echo 'Private Key data successfully read.' . PHP_EOL;
    // Do service call
    echo 'Call Keys service to create Public Key instance.' . PHP_EOL;
    $publicKey = $keysClient->getPublicKeysClient()->createKey($publicKey, $userDataCollection, $privateKey, VIRGIL_PRIVATE_KEY_PASSWORD);
    echo 'Public Key instance successfully created in Public Keys service.' . PHP_EOL;
} catch (Exception $e) {
    echo 'Error:' . $e->getMessage();
}