This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Sausin\Signere; |
||
4 | |||
5 | use BadMethodCallException; |
||
6 | use UnexpectedValueException; |
||
7 | |||
8 | class ExternalSign extends BaseClass |
||
9 | { |
||
10 | /** The URI of the action */ |
||
11 | const URI = 'https://api.signere.no/api/externalsign'; |
||
12 | |||
13 | /** |
||
14 | * Return the login information from the login. |
||
15 | * |
||
16 | * @param string $documentId |
||
17 | * @return object |
||
18 | */ |
||
19 | 1 | public function getUrlForSign(string $documentId) |
|
20 | { |
||
21 | // make the URL for this request |
||
22 | 1 | $url = sprintf('%s/%s', $this->getBaseUrl(), $documentId); |
|
23 | |||
24 | // get the headers for this request |
||
25 | 1 | $headers = $this->headers->make('GET', $url, [], true); |
|
26 | |||
27 | // get the response |
||
28 | 1 | $response = $this->client->get($url, [ |
|
29 | 1 | 'headers' => $headers, |
|
30 | ]); |
||
31 | |||
32 | // return the response |
||
33 | 1 | return $response; |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * Get the URLs to a viewerapplet showing |
||
38 | * documents in an iframe on website. |
||
39 | * |
||
40 | * @param string $documentId |
||
41 | * @param array $params |
||
42 | * @return object |
||
43 | */ |
||
44 | 1 | public function getUrlForApplet(string $documentId, array $params) |
|
45 | { |
||
46 | 1 | if (! isset($params['Domain']) || ! isset($params['Language'])) { |
|
47 | 1 | throw new BadMethodCallException('Params should contain "Domain" and "Language" keys'); |
|
48 | } |
||
49 | |||
50 | // make the URL for this request |
||
51 | 1 | $url = sprintf( |
|
52 | 1 | '%s/ViewerUrl/%s/%s/%s', |
|
53 | 1 | $this->getBaseUrl(), |
|
54 | 1 | $documentId, |
|
55 | 1 | $params['Domain'], |
|
56 | 1 | $params['Language'] |
|
57 | ); |
||
58 | |||
59 | // get the headers for this request |
||
60 | 1 | $headers = $this->headers->make('GET', $url, [], true); |
|
61 | |||
62 | // get the response |
||
63 | 1 | $response = $this->client->get($url, [ |
|
64 | 1 | 'headers' => $headers, |
|
65 | ]); |
||
66 | |||
67 | // return the response |
||
68 | 1 | return $response; |
|
69 | } |
||
70 | |||
71 | /** |
||
72 | * Get status of BankId mobile sign session. |
||
73 | * |
||
74 | * @param string $signeeRefId |
||
75 | * @return object |
||
76 | */ |
||
77 | 1 | public function getSessionStatus(string $signeeRefId) |
|
78 | { |
||
79 | // make the URL for this request |
||
80 | 1 | $url = sprintf('%s/BankIDMobileSign/Status/%s', $this->getBaseUrl(), $signeeRefId); |
|
81 | |||
82 | // get the headers for this request |
||
83 | 1 | $headers = $this->headers->make('GET', $url, [], true); |
|
84 | |||
85 | // get the response |
||
86 | 1 | $response = $this->client->get($url, [ |
|
87 | 1 | 'headers' => $headers, |
|
88 | ]); |
||
89 | |||
90 | // return the response |
||
91 | 1 | return $response; |
|
92 | } |
||
93 | |||
94 | /** |
||
95 | * Creates a externalsign request to integrate |
||
96 | * signing of documents in a website. |
||
97 | * |
||
98 | * @param array $body |
||
99 | * @return object |
||
100 | */ |
||
101 | 3 | public function createRequest(array $body) |
|
102 | { |
||
103 | // keys that are mandatory for this request |
||
104 | $needKeys = [ |
||
105 | 3 | 'Description', |
|
106 | 'ExternalDocumentId', |
||
107 | 'FileContent', |
||
108 | 'Filename', |
||
109 | 'ReturnUrlError', |
||
110 | 'ReturnUrlSuccess', |
||
111 | 'ReturnUrlUserAbort', |
||
112 | 'SigneeRefs', |
||
113 | 'Title', |
||
114 | ]; |
||
115 | |||
116 | // keys that need to be present in each signeeref |
||
117 | $needSubKeys = [ |
||
118 | 3 | 'UniqueRef', |
|
119 | 'FirstName', |
||
120 | 'LastName', |
||
121 | 'Email', |
||
122 | ]; |
||
123 | |||
124 | // if the body doesn't have needed fields, throw an exception |
||
125 | 3 | $this->validateHasKeys($body, $needKeys); |
|
126 | |||
127 | 1 | if (! is_array($body['SigneeRefs'])) { |
|
128 | throw new UnexpectedValueException('SigneeRefs key in input should be an array'); |
||
129 | } |
||
130 | |||
131 | 1 | foreach ($body['SigneeRefs'] as $ref) { |
|
132 | 1 | if (! is_array($ref)) { |
|
133 | throw new UnexpectedValueException('Each item in SigneeRefs should be an array'); |
||
134 | } |
||
135 | |||
136 | 1 | $this->validateHasKeys($ref, $needSubKeys); |
|
137 | } |
||
138 | |||
139 | // make the URL for this request |
||
140 | 1 | $url = $this->getBaseUrl(); |
|
141 | |||
142 | // get the headers for this request |
||
143 | 1 | $headers = $this->headers->make('POST', $url, $body, true); |
|
144 | |||
145 | // get the response |
||
146 | 1 | $response = $this->client->post($url, [ |
|
147 | 1 | 'headers' => $headers, |
|
148 | 1 | 'json' => $body, |
|
149 | ]); |
||
150 | |||
151 | // return the response |
||
152 | 1 | return $response; |
|
153 | } |
||
154 | |||
155 | /** |
||
156 | * Creates a app launch uri for the BankID app. |
||
157 | * |
||
158 | * @param array $body |
||
159 | * @return object |
||
160 | */ |
||
161 | 1 | View Code Duplication | public function createAppUrl(array $body) |
0 ignored issues
–
show
|
|||
162 | { |
||
163 | // keys that are mandatory for this request |
||
164 | 1 | $needKeys = ['DocumentId', 'SigneeRefId', 'UserAgent']; |
|
165 | |||
166 | // if the body doesn't have needed fields, throw an exception |
||
167 | 1 | $this->validateHasKeys($body, $needKeys); |
|
168 | |||
169 | // make the URL for this request |
||
170 | 1 | $url = sprintf('%s/BankIDAppUrl', $this->getBaseUrl()); |
|
171 | |||
172 | // get the headers for this request |
||
173 | 1 | $headers = $this->headers->make('PUT', $url, $body, true); |
|
174 | |||
175 | // get the response |
||
176 | 1 | $response = $this->client->put($url, [ |
|
177 | 1 | 'headers' => $headers, |
|
178 | 1 | 'json' => $body, |
|
179 | ]); |
||
180 | |||
181 | // return the response |
||
182 | 1 | return $response; |
|
183 | } |
||
184 | |||
185 | /** |
||
186 | * Starts a BankID mobile sign session for the given document |
||
187 | * with given mobilenumber and date of birth. |
||
188 | * |
||
189 | * @param array $body |
||
190 | * @return object |
||
191 | */ |
||
192 | 1 | View Code Duplication | public function startMobile(array $body) |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
193 | { |
||
194 | // keys that are mandatory for this request |
||
195 | 1 | $needKeys = ['DateOfBirth', 'DocumentId', 'Mobile', 'SigneeRefId']; |
|
196 | |||
197 | // if the body doesn't have needed fields, throw an exception |
||
198 | 1 | $this->validateHasKeys($body, $needKeys); |
|
199 | |||
200 | // make the URL for this request |
||
201 | 1 | $url = sprintf('%s/BankIDMobileSign', $this->getBaseUrl()); |
|
202 | |||
203 | // get the headers for this request |
||
204 | 1 | $headers = $this->headers->make('PUT', $url, $body, true); |
|
205 | |||
206 | // get the response |
||
207 | 1 | $response = $this->client->put($url, [ |
|
208 | 1 | 'headers' => $headers, |
|
209 | 1 | 'json' => $body, |
|
210 | ]); |
||
211 | |||
212 | // return the response |
||
213 | 1 | return $response; |
|
214 | } |
||
215 | } |
||
216 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.