|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Laravel\Forge\Certificates; |
|
4
|
|
|
|
|
5
|
|
|
use Laravel\Forge\Certificates\Commands\GetCertificateCommand; |
|
6
|
|
|
use Laravel\Forge\Certificates\Commands\CloneCertificateCommand; |
|
7
|
|
|
use Laravel\Forge\Certificates\Commands\ListCertificatesCommand; |
|
8
|
|
|
use Laravel\Forge\Certificates\Commands\CreateCertificateCommand; |
|
9
|
|
|
use Laravel\Forge\Certificates\Commands\InstallCertificateCommand; |
|
10
|
|
|
use Laravel\Forge\Certificates\Commands\ObtainLetsEncryptCertificateCommand; |
|
11
|
|
|
|
|
12
|
|
|
class CertificatesManager |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* Initialize new create certificate command. |
|
16
|
|
|
* |
|
17
|
|
|
* @param string $domain |
|
18
|
|
|
* |
|
19
|
|
|
* @return \Laravel\Forge\Certificates\Commands\CreateCertificateCommand |
|
20
|
|
|
*/ |
|
21
|
|
|
public function create(string $domain) |
|
22
|
|
|
{ |
|
23
|
|
|
return (new CreateCertificateCommand()) |
|
24
|
|
|
->operationType('new') |
|
25
|
|
|
->identifiedAs($domain); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Initialize new install certificate command. |
|
30
|
|
|
* |
|
31
|
|
|
* @param string $privateKey |
|
32
|
|
|
* @param string $certificate |
|
33
|
|
|
* |
|
34
|
|
|
* @return \Laravel\Forge\Certificates\Commands\InstallCertificateCommand |
|
35
|
|
|
*/ |
|
36
|
|
|
public function install(string $privateKey, string $certificate) |
|
37
|
|
|
{ |
|
38
|
|
|
return (new InstallCertificateCommand()) |
|
39
|
|
|
->operationType('existing') |
|
40
|
|
|
->usingPivateKey($privateKey) |
|
41
|
|
|
->usingCertificate($certificate); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Initialize new clone certificate command. |
|
46
|
|
|
* |
|
47
|
|
|
* @param int $certificateId |
|
48
|
|
|
* |
|
49
|
|
|
* @return \Laravel\Forge\Certificates\Commands\CloneCertificateCommand |
|
50
|
|
|
*/ |
|
51
|
|
|
public function clone(int $certificateId) |
|
52
|
|
|
{ |
|
53
|
|
|
return (new CloneCertificateCommand()) |
|
54
|
|
|
->operationType('clone') |
|
55
|
|
|
->usingCertificateId($certificateId); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Initialize new obtain Let's Encrypt certificate command. |
|
60
|
|
|
* |
|
61
|
|
|
* @param string|array $domains |
|
62
|
|
|
* |
|
63
|
|
|
* @return \Laravel\Forge\Certificates\Commands\ObtainLetsEncryptCertificateCommand |
|
64
|
|
|
*/ |
|
65
|
|
|
public function obtain($domains) |
|
66
|
|
|
{ |
|
67
|
|
|
return (new ObtainLetsEncryptCertificateCommand()) |
|
68
|
|
|
->usingDomains($domains); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Initialize new list certificates command. |
|
73
|
|
|
* |
|
74
|
|
|
* @return \Laravel\Forge\Certificates\Commands\ListCertificatesCommand |
|
75
|
|
|
*/ |
|
76
|
|
|
public function list() |
|
77
|
|
|
{ |
|
78
|
|
|
return new ListCertificatesCommand(); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Initialize new get certificate command. |
|
83
|
|
|
* |
|
84
|
|
|
* @param int $certificateId |
|
85
|
|
|
* |
|
86
|
|
|
* @return \Laravel\Forge\Certificates\Commands\GetCertificateCommand |
|
87
|
|
|
*/ |
|
88
|
|
|
public function get(int $certificateId) |
|
89
|
|
|
{ |
|
90
|
|
|
return (new GetCertificateCommand())->setResourceId($certificateId); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|