Alternc  latest
Alternc logiel libre pour l'hébergement
Policy.php
Go to the documentation of this file.
1 <?php
2 
3 /**
4  * Passowrd Policy Api of AlternC, used by alternc-api package
5  */
7 
8  /** API Method from legacy class method admin->editPolicy($policy,$minsize,$maxsize,$classcount,$allowlogin)
9  * @param $options a hash with parameters transmitted to legacy call
10  * mandatory parameters: policy minsize maxsize classcount allowlogin
11  * @return Alternc_Api_Response TRUE if the password policy has been updated
12  */
13  function update($options) {
14  $mandatory = array("policy", "minsize", "maxsize", "classcount", "allowlogin");
15  $missing = "";
16  foreach ($mandatory as $key) {
17  if (!isset($options[$key])) {
18  $missing.=$key . " ";
19  }
20  }
21  if ($missing) {
22  return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
23  }
24  $result = $this->admin->editPolicy($options["policy"], $options["minsize"], $options["maxsize"], $options["classcount"], $options["allowlogin"]);
25  if (!$result) {
26  return $this->alterncLegacyErrorManager();
27  } else {
28  return new Alternc_Api_Response(array("content" => true));
29  }
30  }
31 
32  /** API Method from legacy class method admin->listPasswordPolicies()
33  * @param $options a hash with parameters transmitted to legacy call
34  * no options is used.
35  * @return Alternc_Api_Response An array with all password policies
36  */
37  function find($options) {
38  $result = $this->admin->listPasswordPolicies();
39 
40  if (!$result) {
41  return $this->alterncLegacyErrorManager();
42  } else {
43  return new Alternc_Api_Response(array("content" => $result));
44  }
45  }
46 
47  /** API Method from legacy class method admin->checkPolicy($policy,$login,$password)
48  * @param $options a hash with parameters transmitted to legacy call
49  * mandatory parameters: policy login password
50  * @return Alternc_Api_Response TRUE if the password match the policy
51  */
52  function check($options) {
53  $mandatory = array("policy", "login", "password");
54  $missing = "";
55  foreach ($mandatory as $key) {
56  if (!isset($options[$key])) {
57  $missing.=$key . " ";
58  }
59  }
60  if ($missing) {
61  return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
62  }
63  $result = $this->admin->checkPolicy($options["policy"], $options["login"], $options["password"]);
64  if (!$result) {
65  return $this->alterncLegacyErrorManager();
66  } else {
67  return new Alternc_Api_Response(array("content" => true));
68  }
69  }
70 
71 }
72 
73 // class Alternc_Api_Object_Account
Any Legacy AlternC Api should use this class as a parent to be able to handle properly the access rig...
Definition: Legacyobject.php:9
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class
Passowrd Policy Api of AlternC, used by alternc-api package.
Definition: Policy.php:6
update($options)
API Method from legacy class method admin->editPolicy($policy,$minsize,$maxsize,$classcount,...
Definition: Policy.php:13
find($options)
API Method from legacy class method admin->listPasswordPolicies()
Definition: Policy.php:37
check($options)
API Method from legacy class method admin->checkPolicy($policy,$login,$password)
Definition: Policy.php:52
Standard Response object for the AlternC API.
Definition: Response.php:7
if(empty($_POST['key'])||empty($_POST['val'])) $key
Definition: tempovars.php:14