KumbiaPHP  beta2
Framework PHP
 Todo Estructuras de Datos Namespaces Archivos Funciones Variables Páginas
kerberos5_auth.php
Ir a la documentación de este archivo.
1 <?php
30 class Kerberos5Auth implements AuthInterface
31 {
32 
38  private $filename;
44  private $server;
50  private $username;
56  private $password;
60  private $resource;
66  private $realm;
72  private $principal;
73 
80  public function __construct($auth, $extra_args)
81  {
82 
83  if (!extension_loaded("kadm5")) {
84  throw new KumbiaException("Debe cargar la extensi�n de php llamada kadm5");
85  }
86 
87  foreach (array('server', 'username', 'principal', 'password') as $param) {
88  if (isset($extra_args[$param])) {
89  $this->$param = $extra_args[$param];
90  } else {
91  throw new KumbiaException("Debe especificar el par�metro '$param' en los par�metros");
92  }
93  }
94  }
95 
100  public function get_identity()
101  {
102  if (!$this->resource) {
103  new KumbiaException("La conexi�n al servidor kerberos5 es inv�lida");
104  }
105  $identity = array("username" => $this->username, "realm" => $this->username);
106  return $identity;
107  }
108 
114  public function authenticate()
115  {
116  $this->resource = kadm5_init_with_password($this->server, $this->realm, $this->principal, $this->password);
117  if ($this->resource === false) {
118  return false;
119  } else {
120  return true;
121  }
122  }
123 
128  public function get_principals()
129  {
130  if (!$this->resource) {
131  new KumbiaException("La conexi�n al servidor kerberos5 es inv�lida");
132  }
133  return kadm5_get_principals($this->resource);
134  }
135 
140  public function get_policies()
141  {
142  if (!$this->resource) {
143  new KumbiaException("La conexi�n al servidor kerberos5 es inv�lida");
144  }
145  return kadm5_get_policies($this->resource);
146  }
147 
152  public function __destruct()
153  {
154  if ($this->resource) {
155  kadm5_destroy($this->resource);
156  }
157  }
158 
164  public function set_params($extra_args)
165  {
166  foreach (array('server', 'principal', 'username', 'password') as $param) {
167  if (isset($extra_args[$param])) {
168  $this->$param = $extra_args[$param];
169  }
170  }
171  }
172 
173 }