eideasy / simplysign
There is no license information available for the latest version (v3.0.0) of this package.
Certum SimplySign Client
v3.0.0
2023-12-15 09:02 UTC
Requires
- php: >=8.2
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- monolog/monolog: >=1.23
- psr/log: >=1.0
- ramsey/uuid: >=3.7
Requires (Dev)
- phpunit/phpunit: >=7.5
- dev-master
- v3.0.0
- v2.0
- v1.4
- v1.3
- v1.2
- v1.1
- v1.0
- dev-EID-1493-improve-simply-sign-php-library-to-support-multiple-hashes-2
- dev-EID-1493-improve-simply-sign-php-library-to-support-multiple-hashes
- dev-improve-softcard-service
- dev-improve-soft-card-service
- dev-add-cert-failure-message
- dev-add-signature-service
This package is auto-updated.
Last update: 2024-11-15 13:21:58 UTC
README
SimplySign webservice client
Installation
composer require eideasy/simplysign
Usage
1. Configuration
use Webinv\SimplySign\Connection;
use Webinv\SimplySign\Client\Authorization;
$connection = new Connection([
'client_id' => '**client_id**',
'client_secret' => '**client_secret**',
'domain' => Connection::DOMAIN_TEST
]);
2. Authorization
2.1 Authorization Code
use Webinv\SimplySign\Client\Authorization;
$client = new Authorization($connection);
$redirectUrl = 'http://example.com/02-authorization-grant-token.php';
if (isset($_GET['code'])) {
$token = $client->getAccessTokenByAuthorizationCode($redirectUrl, $_GET['code']);
print_r($token);
} else {
header(sprintf('Location: %s', $client->getAuthorizationUrl($redirectUrl)));
}
2.2 Resource Owner Password Credentials
use Webinv\SimplySign\Client\Authorization;
$client = new Authorization($connection);
$token = $client->getAccessTokenByEmailPassword('example@domain.com', '******');
2. Signing PDF document
use Webinv\SimplySign\Client\SignatureFormatServicePades;
use Webinv\SimplySign\Model\Pades\SigningRequest;
use Webinv\SimplySign\Model\Pades\Signing\Credentials;
$client = new SignatureFormatServicePades($connection);
// Create token or you can obrain a new one
$token = new \Webinv\SimplySign\Model\Token([
'access_token' => '*******************************************',
'token_type' => 'bearer',
'expires_in' => 7200,
'refresh_token' => '*******************************************'
]);
$credentials = new Credentials();
$credentials->setCard('*******');
$credentials->setPin('*******');
$credentials->setToken($token->getAccessToken());
$signingRequest = new SigningRequest();
$signingRequest->setCertificateFile(__DIR__ . '/example.pem');
$signingRequest->setFile(__DIR__ . '/example.pdf');
$signingRequest->setCredentials($credentials);
$signed = $client->sign($signingRequest, $token);
file_put_contents(__DIR__ . '/signed_document.pdf', base64_decode($signed));
3. Certificates list
use Webinv\SimplySign\Connection;
use Webinv\SimplySign\Client\SoftCardService;
$connection = new Connection([
'client_id' => '**client_id**',
'client_secret' => '**client_secret**',
'domain' => Connection::DOMAIN_TEST
]);
$client = new SoftCardService($connection);
$token = new \Webinv\SimplySign\Model\Token([
'access_token' => '*******************************************',
'token_type' => 'bearer',
'expires_in' => 7200,
'refresh_token' => '*******************************************'
]);
$certificates = $client->getCertificates('**card***', $token);
foreach ($certificates as $certificate) {
echo 'File: ' . $certificate->getFilename() . "\n\n";
echo $certificate->getContent() . "\n\n";
}