3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Authentication
;
20 * Failure due to identity not being found.
22 const FAILURE_IDENTITY_NOT_FOUND
= -1;
25 * Failure due to identity being ambiguous.
27 const FAILURE_IDENTITY_AMBIGUOUS
= -2;
30 * Failure due to invalid credential being supplied.
32 const FAILURE_CREDENTIAL_INVALID
= -3;
35 * Failure due to uncategorized reasons.
37 const FAILURE_UNCATEGORIZED
= -4;
40 * Authentication success.
45 * Authentication result code
52 * The identity used in the authentication attempt
59 * An array of string reasons why the authentication attempt was unsuccessful
61 * If authentication was successful, this should be an empty array.
68 * Sets the result code, identity, and failure messages
71 * @param mixed $identity
72 * @param array $messages
74 public function __construct($code, $identity, array $messages = array())
76 $this->code
= (int) $code;
77 $this->identity
= $identity;
78 $this->messages
= $messages;
82 * Returns whether the result represents a successful authentication attempt
86 public function isValid()
88 return ($this->code
> 0) ?
true : false;
92 * getCode() - Get the result code for this authentication attempt
96 public function getCode()
102 * Returns the identity used in the authentication attempt
106 public function getIdentity()
108 return $this->identity
;
112 * Returns an array of string reasons why the authentication attempt was unsuccessful
114 * If authentication was successful, this method returns an empty array.
118 public function getMessages()
120 return $this->messages
;