You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+73-39Lines changed: 73 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# SetaPDF-Signer component modules for the GlobalSign Digital Signing Service.
2
2
3
-
This package offers modules for the [SetaPDF-Signer](https://www.setasign.com/signer) component that allow you to use the [Cloud-based Digital Signing Service](https://www.globalsign.com/en/digital-signatures/cloud/) by [GlobalSign](https://www.globalsign.com) to **digital sign and timestamp PDF documents in pure PHP**.
3
+
This package offers modules for the [SetaPDF-Signer](https://www.setasign.com/signer) component that allow you
4
+
to use the [Cloud-based Digital Signing Service](https://www.globalsign.com/en/digital-signatures/cloud/) by
5
+
[GlobalSign](https://www.globalsign.com) to **digital sign and timestamp PDF documents in pure PHP**.
4
6
5
7
## Requirements
6
8
@@ -12,15 +14,37 @@ To use this package you need credentials for the GlobalSign Digital Signing Serv
12
14
13
15
See "GlobalSign-Digital-Signing-Service-Guide 1.3.pdf" (or newer) for details. Ask a GlobalSign contact for this document.
14
16
15
-
This package is developed and tested on PHP >= 7.1. Requirements of the [SetaPDF-Signer](https://www.setasign.com/signer) component can be found [here](https://manuals.setasign.com/setapdf-signer-manual/getting-started/#index-1).
17
+
This package is developed and tested on PHP >= 7.1. Requirements of the [SetaPDF-Signer](https://www.setasign.com/signer)
18
+
component can be found [here](https://manuals.setasign.com/setapdf-signer-manual/getting-started/#index-1).
19
+
20
+
We're using [PSR-17 (HTTP Factories)](https://www.php-fig.org/psr/psr-17/) and
21
+
[PSR-18 (HTTP Client)](https://www.php-fig.org/psr/psr-18/) for the requests. So you'll need an implementation of
@@ -31,10 +55,13 @@ Add following to your composer.json:
31
55
}
32
56
```
33
57
34
-
and execute `composer update`. You need to define the `repository` to evaluate the dependency to the [SetaPDF-Signer](https://www.setasign.com/signer) component (see [here](https://getcomposer.org/doc/faqs/why-can%27t-composer-load-repositories-recursively.md) for more details).
58
+
and execute `composer update`. You need to define the `repository` to evaluate the dependency to the
59
+
[SetaPDF-Signer](https://www.setasign.com/signer) component (see
60
+
[here](https://getcomposer.org/doc/faqs/why-can%27t-composer-load-repositories-recursively.md) for more details).
35
61
36
62
### Evaluation version
37
-
By default this packages depends on a licensed version of the [SetaPDF-Signer](https://www.setasign.com/signer) component. If you want to use it with an evaluation version please use following in your composer.json:
63
+
By default, this packages depends on a licensed version of the [SetaPDF-Signer](https://www.setasign.com/signer) component.
64
+
If you want to use it with an evaluation version please use following in your composer.json:
38
65
39
66
```json
40
67
{
@@ -50,46 +77,42 @@ By default this packages depends on a licensed version of the [SetaPDF-Signer](h
50
77
}
51
78
```
52
79
53
-
### Without Composer
54
-
55
-
Make sure, that the [SetaPDF-Signer](https://www.setasign.com/signer) component is [installed](https://manuals.setasign.com/setapdf-core-manual/installation/#index-2) and its [autoloader is registered](https://manuals.setasign.com/setapdf-core-manual/getting-started/#index-1) correctly.
56
-
57
-
Then simply require the `src/autoload.php` file or register this package in your own PSR-4 compatible autoload implementation:
All classes in this package are located in the namespace `setasign\SetaPDF\Signer\Module\GlobalSign\Dss`.
68
83
69
84
### The `Client` class
70
85
71
-
There's a simple `Client` class which wraps the [REST API](https://downloads.globalsign.com/acton/media/2674/digital-signing-service-api-documentation) into simple PHP methods. It handles the authentication, requests and responses internally. For the communication with the API it uses [Guzzle](http://guzzlephp.org/).
86
+
There's a simple `Client` class which wraps the [REST API](https://downloads.globalsign.com/acton/media/2674/digital-signing-service-api-documentation)
87
+
into simple PHP methods. It handles the authentication, requests and responses internally.
72
88
73
-
The constructor of this class requires 3 arguments:
89
+
The constructor of this class requires the following arguments:
74
90
75
-
`$options` which are the [request options](http://docs.guzzlephp.org/en/stable/request-options.html) for Guzzle. To authenticate to the API endpoint it requires the `cert` (the client certificated issued by GlobalSign) and `ssl_key` (your private key) options. The `headers` and `body` options are set/overwritten internally.
76
-
77
-
`$apiKey` is your API key received from GlobalSign.
78
-
79
-
`$apiSecret` is the secret to your API key received from GlobalSign.
To create a digital signature you need to create a signing certificate first which can be done with the `getIdentity()` method. The argument to this method can be an associative array as defined [here](https://downloads.globalsign.com/acton/media/2674/digital-signing-service-api-documentation#identity_post). The method will return an `Identity` instance which is nothing more than a data wrapper of the returned id, signing certificate and OCSP response.
126
+
To create a digital signature you need to create a signing certificate first which can be done with the `getIdentity()`
127
+
method. The argument to this method can be an associative array as defined
The method will return an `Identity` instance which is nothing more than a data wrapper of the returned id, signing
130
+
certificate and OCSP response.
104
131
105
132
```php
106
133
$identity = $client->getIdentity();
107
134
```
108
135
109
-
This `Identity` needs to be forward to the signature module which internally passes it back to the `Dss\Client\sign()` method to get the final signature. It is also possible to use this method individually (just for completion):
136
+
This `Identity` needs to be forward to the signature module which internally passes it back to the `Dss\Client\sign()`
137
+
method to get the final signature. It is also possible to use this method individually (just for completion):
This is the main signature module which can be used with the [SetaPDF-Signer](https://www.setasign.com/signer) component. Its constructor requires 4 arguments:
118
-
119
-
`$signer` is the instance of the `\SetaPDF_Signer` class to which the module is passed afterwards. Internally [`$signer->setAllowSignatureContentLengthChange(false)`](https://manuals.setasign.com/api-reference/setapdf/c/SetaPDF.Signer#method_setAllowSignatureContentLengthChange) is called to prohibit redundant signature requests.
120
-
121
-
`$client` needs to be the `Dss\Client` instance.
145
+
This is the main signature module which can be used with the [SetaPDF-Signer](https://www.setasign.com/signer) component.
146
+
Its constructor requires these arguments:
122
147
123
-
`$identity` a `Dss\Identity` instance.
124
-
125
-
`$module` needs to be a [CMS](https://manuals.setasign.com/api-reference/setapdf/c/SetaPDF.Signer.Signature.Module.Cms) or [PAdES](https://manuals.setasign.com/api-reference/setapdf/c/SetaPDF.Signer.Signature.Module.Pades) signature module instance. It is used internally to create the CMS container.
148
+
-`$signer` is the instance of the `\SetaPDF_Signer` class to which the module is passed afterwards. Internally [`$signer->setAllowSignatureContentLengthChange(false)`](https://manuals.setasign.com/api-reference/setapdf/c/SetaPDF.Signer#method_setAllowSignatureContentLengthChange) is called to prohibit redundant signature requests.
149
+
-`$client` needs to be the `Dss\Client` instance.
150
+
-`$identity` a `Dss\Identity` instance.
151
+
-`$module` needs to be a [CMS](https://manuals.setasign.com/api-reference/setapdf/c/SetaPDF.Signer.Signature.Module.Cms) or [PAdES](https://manuals.setasign.com/api-reference/setapdf/c/SetaPDF.Signer.Signature.Module.Pades) signature module instance. It is used internally to create the CMS container.
126
152
127
153
A simple complete signature process would look like this:
$client = new Dss\Client($options, $apiKey, $apiSecret);
166
+
$httpClient = new GuzzleHttp\Client($options);
167
+
// if you are using php 7.0 or 7.1
168
+
//$httpClient = new Mjelamanov\GuzzlePsr18\Client($httpClient);
169
+
$requestFactory = new Http\Factory\Guzzle\RequestFactory();
170
+
$streamFactory = new Http\Factory\Guzzle\StreamFactory();
171
+
172
+
$client = new Dss\Client($httpClient, $requestFactory, $streamFactory, $apiKey, $apiSecret);
140
173
$identity = $client->getIdentity();
141
174
142
175
// now start the signature process
@@ -178,7 +211,8 @@ $signer->timestamp();
178
211
179
212
## Information about Tests
180
213
181
-
The test suite currently only comes with functional tests, which invoke **real service calls**! Keep in mind that these calls are deducted from your signature contingent and you should not execute these tests in an automated environment!
214
+
The test suite currently only comes with functional tests, which invoke **real service calls**! Keep in mind that these
215
+
calls are deducted from your signature contingent. You should not execute these tests in an automated environment!!
182
216
183
217
To execute the tests, you need to create a folder in the root of this package with the following file:
184
218
@@ -201,4 +235,4 @@ return [
201
235
202
236
## License
203
237
204
-
This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
238
+
This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
0 commit comments