Alternc  latest
Alternc logiel libre pour l'h├ębergement
 All Classes Namespaces Files Functions Variables Pages
Alternc_Api_Object_Ssl Class Reference

SSL Api of AlternC, used by alternc-api package. More...

+ Inheritance diagram for Alternc_Api_Object_Ssl:

Public Member Functions

 __construct ($service)
 
 getList ($options)
 API Method from legacy class get_list() More...
 
 newCsr ($options)
 API Method from legacy class new_csr() More...
 
 getCertificate ($options)
 API Method from legacy class get_certificate() More...
 
 share ($options)
 API Method from legacy class share() More...
 
 importCert ($options)
 API Method from legacy class import_cert() More...
 
 finalize ($options)
 API Method from legacy class finalize() More...
 
 aliasAdd ($options)
 API Method from legacy class alias_add() More...
 
 aliasDel ($options)
 API Method from legacy class alias_del() More...
 

Public Attributes

const ERR_INVALID_ARGUMENT = 111201
 
const ERR_ALTERNC_FUNCTION = 111202
 
const ERR_NOT_FOUND = 111203
 

Protected Member Functions

 alterncLegacyErrorManager ()
 return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class More...
 
 offsetAndCount ($options, $max)
 ensure that offset & count are set properly from $options. More...
 

Protected Attributes

 $ssl
 
 $admin
 
 $cuid
 
 $isAdmin
 
 $db
 

Detailed Description

SSL Api of AlternC, used by alternc-api package.

Definition at line 6 of file Ssl.php.

Constructor & Destructor Documentation

Alternc_Api_Object_Ssl::__construct (   $service)

Definition at line 10 of file Ssl.php.

References $ssl.

10  {
11  global $ssl;
12  parent::__construct($service);
13  // We use the global $ssl from AlternC legacy classes
14  $this->ssl=$ssl;
15  }

Member Function Documentation

Alternc_Api_Object_Ssl::aliasAdd (   $options)

API Method from legacy class alias_add()

Parameters
$optionsa hash with parameters transmitted to legacy call add the alias 'name' with the content value 'value' in the global apache configuration
Returns
Alternc_Api_Response true

Definition at line 152 of file Ssl.php.

References Alternc_Api_Legacyobject\alterncLegacyErrorManager().

152  {
153  if (!isset($options["name"]) || !is_string($options["name"])) {
154  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: NAME") );
155  }
156  if (!isset($options["content"]) || !is_string($options["content"])) {
157  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: CONTENT") );
158  }
159 
160  $isok=$this->ssl->alias_add($options["name"],$options["content"]);
161  if ($isok===false) {
162  return $this->alterncLegacyErrorManager();
163  }
164  return new Alternc_Api_Response( array("content" => $isok) );
165  }
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class ...
Standard Response object for the AlternC API.
Definition: Response.php:7
Alternc_Api_Object_Ssl::aliasDel (   $options)

API Method from legacy class alias_del()

Parameters
$optionsa hash with parameters transmitted to legacy call del the alias 'name' in the global apache configuration
Returns
Alternc_Api_Response true

Definition at line 173 of file Ssl.php.

References Alternc_Api_Legacyobject\alterncLegacyErrorManager().

173  {
174  if (!isset($options["name"]) || !is_string($options["name"])) {
175  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: NAME") );
176  }
177 
178  $isok=$this->ssl->alias_del($options["name"]);
179  if ($isok===false) {
180  return $this->alterncLegacyErrorManager();
181  }
182  return new Alternc_Api_Response( array("content" => $isok) );
183  }
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class ...
Standard Response object for the AlternC API.
Definition: Response.php:7
Alternc_Api_Legacyobject::alterncLegacyErrorManager ( )
protectedinherited

return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class

Definition at line 38 of file Legacyobject.php.

References $err.

Referenced by Alternc_Api_Object_Mail\account(), Alternc_Api_Object_Account\add(), Alternc_Api_Object_Ftp\add(), Alternc_Api_Object_Mysql\add(), Alternc_Api_Object_Domain\add(), aliasAdd(), aliasDel(), Alternc_Api_Object_Policy\check(), Alternc_Api_Object_Mail\create(), Alternc_Api_Object_Ftp\del(), Alternc_Api_Object_Account\del(), Alternc_Api_Object_Mysql\del(), Alternc_Api_Object_Domain\del(), Alternc_Api_Object_Mail\delete(), Alternc_Api_Object_Mail\disable(), Alternc_Api_Object_Mail\enable(), finalize(), Alternc_Api_Object_Policy\find(), Alternc_Api_Object_Ftp\find(), Alternc_Api_Object_Account\find(), Alternc_Api_Object_Mysql\find(), Alternc_Api_Object_Subdomain\get(), Alternc_Api_Object_Domain\get(), Alternc_Api_Object_Mail\get(), Alternc_Api_Object_Mail\getAll(), getCertificate(), importCert(), Alternc_Api_Object_Mail\isAvailable(), Alternc_Api_Object_Ftp\isFtp(), Alternc_Api_Object_Mail\listDomains(), Alternc_Api_Object_Account\lock(), Alternc_Api_Object_Mysql\lock(), newCsr(), Alternc_Api_Object_Mail\passwd(), Alternc_Api_Object_Subdomain\set(), Alternc_Api_Object_Account\setAdmin(), Alternc_Api_Object_Mysql\setAdmin(), share(), Alternc_Api_Object_Mail\undelete(), Alternc_Api_Object_Account\unlock(), Alternc_Api_Object_Mysql\unlock(), Alternc_Api_Object_Account\unsetAdmin(), Alternc_Api_Object_Mysql\unsetAdmin(), Alternc_Api_Object_Policy\update(), Alternc_Api_Object_Ftp\update(), Alternc_Api_Object_Account\update(), Alternc_Api_Object_Mysql\update(), Alternc_Api_Object_Domain\update(), and Alternc_Api_Object_Mail\update().

38  {
39  global $err;
40  return new Alternc_Api_Response(array("code" => self::ERR_ALTERNC_FUNCTION, "message" => "[" . $err->clsid . "] " . $err->error));
41  }
$err
Definition: bootstrap.php:72
Standard Response object for the AlternC API.
Definition: Response.php:7
Alternc_Api_Object_Ssl::finalize (   $options)

API Method from legacy class finalize()

Parameters
$optionsa hash with parameters transmitted to legacy call second part of the new_csr() call, finalize a certificate creation id = ID of the certificate to finalize in the table. crt = Certificate data chain = Chained Certificate date (not mandatory)
Returns
Alternc_Api_Response the ID of the updated certificate in the table.

Definition at line 124 of file Ssl.php.

References Alternc_Api_Legacyobject\alterncLegacyErrorManager().

124  {
125  if (!isset($options["id"]) || !intval($options["id"])) {
126  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: ID") );
127  }
128  if (!isset($options["crt"]) || !is_string($options["crt"])) {
129  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: CRT") );
130  }
131  if (isset($options["chain"])) {
132  if (!is_string($options["chain"])) {
133  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Invalid argument: CHAIN") );
134  }
135  } else {
136  $options["chain"]="";
137  }
138 
139  $certid=$this->ssl->finalize(intval($options["id"]),$options["crt"],$options["chain"]);
140  if ($certid===false) {
141  return $this->alterncLegacyErrorManager();
142  }
143  return new Alternc_Api_Response( array("content" => $certid) );
144  }
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class ...
Standard Response object for the AlternC API.
Definition: Response.php:7
Alternc_Api_Object_Ssl::getCertificate (   $options)

API Method from legacy class get_certificate()

Parameters
$optionsa hash with parameters transmitted to legacy call id = the ID of the certificate in the certifiate table to get
Returns
Alternc_Api_Response whose content is a hash with all informations for that certificate

Definition at line 55 of file Ssl.php.

References Alternc_Api_Legacyobject\alterncLegacyErrorManager().

55  {
56  if (!isset($options["id"]) || !intval($options["id"])) {
57  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: ID") );
58  }
59  $certinfo=$this->ssl->get_certificate(intval($options["id"]));
60  if ($certinfo===false) {
61  return $this->alterncLegacyErrorManager();
62  }
63  return new Alternc_Api_Response( array("content" => $certinfo) );
64  }
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class ...
Standard Response object for the AlternC API.
Definition: Response.php:7
Alternc_Api_Object_Ssl::getList (   $options)

API Method from legacy class get_list()

Parameters
$optionsa hash with parameters transmitted to legacy call filter = the kind of ssl certificates to show or not show
Returns
Alternc_Api_Response whose content is an array of hashes containing all corresponding certificates informations

Definition at line 22 of file Ssl.php.

References null.

22  {
23  if (isset($options["filter"]) && intval($options["filter"])) {
24  $filter=intval($options["filter"]);
25  } else {
26  $filter=null;
27  }
28  $ssllist=$this->ssl->get_list($filter);
29  return new Alternc_Api_Response( array("content" => $ssllist) );
30  }
PR null
Definition: lang-css.js:1
Standard Response object for the AlternC API.
Definition: Response.php:7
Alternc_Api_Object_Ssl::importCert (   $options)

API Method from legacy class import_cert()

Parameters
$optionsa hash with parameters transmitted to legacy call key, crt, chain = key and crt (both mandatory) and chain (not mandatory) to import
Returns
Alternc_Api_Response the ID of the newly created certificate in the table.

Definition at line 93 of file Ssl.php.

References Alternc_Api_Legacyobject\alterncLegacyErrorManager().

93  {
94  if (!isset($options["key"]) || !is_string($options["key"])) {
95  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: KEY") );
96  }
97  if (!isset($options["crt"]) || !is_string($options["crt"])) {
98  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: CRT") );
99  }
100  if (isset($options["chain"])) {
101  if (!is_string($options["chain"])) {
102  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Invalid argument: CHAIN") );
103  }
104  } else {
105  $options["chain"]="";
106  }
107 
108  $certid=$this->ssl->import_cert($options["key"],$options["crt"],$options["chain"]);
109  if ($certid===false) {
110  return $this->alterncLegacyErrorManager();
111  }
112  return new Alternc_Api_Response( array("content" => $certid) );
113  }
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class ...
Standard Response object for the AlternC API.
Definition: Response.php:7
Alternc_Api_Object_Ssl::newCsr (   $options)

API Method from legacy class new_csr()

Parameters
$optionsa hash with parameters transmitted to legacy call fqdn = the DNS name to create a CSR to
Returns
Alternc_Api_Response whose content is the CSR ID in the certificate database

Definition at line 38 of file Ssl.php.

References Alternc_Api_Legacyobject\alterncLegacyErrorManager().

38  {
39  if (!isset($options["fqdn"]) || !is_string($options["fqdn"])) {
40  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: FQDN") );
41  }
42  $certid=$this->ssl->new_csr($options["fqdn"]);
43  if ($certid===false) {
44  return $this->alterncLegacyErrorManager();
45  }
46  return new Alternc_Api_Response( array("content" => $certid) );
47  }
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class ...
Standard Response object for the AlternC API.
Definition: Response.php:7
Alternc_Api_Legacyobject::offsetAndCount (   $options,
  $max 
)
protectedinherited

ensure that offset & count are set properly from $options.

Definition at line 45 of file Legacyobject.php.

Referenced by Alternc_Api_Object_Domain\find(), Alternc_Api_Object_Ftp\find(), Alternc_Api_Object_Account\find(), and Alternc_Api_Object_Mysql\find().

45  {
46  $offset = -1;
47  $count = -1;
48  if (isset($options["count"]))
49  $count = intval($options["count"]);
50  if (isset($options["offset"]))
51  $offset = intval($options["offset"]);
52  if ($offset != -1 || $count != -1) {
53  if ($offset < 0 || $offset > $max)
54  $offset = 0;
55  if ($count < 0 || $count > 1000)
56  $count = 1000;
57  }
58  return array($offset, $count);
59  }
Alternc_Api_Object_Ssl::share (   $options)

API Method from legacy class share()

Parameters
$optionsa hash with parameters transmitted to legacy call id = the ID of the certificate to share or unshare action = boolean telling to share(true) or unshare(false) this certificate
Returns
Alternc_Api_Response true.

Definition at line 73 of file Ssl.php.

References Alternc_Api_Legacyobject\alterncLegacyErrorManager().

73  {
74  if (!isset($options["id"]) || !intval($options["id"])) {
75  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: ID") );
76  }
77  if (!isset($options["action"]) ) {
78  return new Alternc_Api_Response( array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: ACTION") );
79  }
80  $isok=$this->ssl->share(intval($options["id"]), (intval($options["action"]))? true : false );
81  if ($isok===false) {
82  return $this->alterncLegacyErrorManager();
83  }
84  return new Alternc_Api_Response( array("content" => $isok) );
85  }
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class ...
Standard Response object for the AlternC API.
Definition: Response.php:7

Member Data Documentation

Alternc_Api_Legacyobject::$admin
protectedinherited

Definition at line 11 of file Legacyobject.php.

Referenced by Alternc_Api_Legacyobject\__construct().

Alternc_Api_Legacyobject::$db
protectedinherited

Definition at line 14 of file Legacyobject.php.

Alternc_Api_Legacyobject::$isAdmin
protectedinherited

Definition at line 13 of file Legacyobject.php.

Referenced by Alternc_Api_Legacyobject\__construct().

Alternc_Api_Object_Ssl::$ssl
protected

Definition at line 8 of file Ssl.php.

Referenced by __construct().

const Alternc_Api_Legacyobject::ERR_ALTERNC_FUNCTION = 111202
inherited

Definition at line 17 of file Legacyobject.php.

const Alternc_Api_Legacyobject::ERR_INVALID_ARGUMENT = 111201
inherited

Definition at line 16 of file Legacyobject.php.

const Alternc_Api_Legacyobject::ERR_NOT_FOUND = 111203
inherited

Definition at line 18 of file Legacyobject.php.


The documentation for this class was generated from the following file: