|
1 | 1 | <?php |
2 | | - |
| 2 | +/** |
| 3 | + * This file is part of php-saml. |
| 4 | + * |
| 5 | + * (c) OneLogin Inc |
| 6 | + * |
| 7 | + * For the full copyright and license information, please view the LICENSE |
| 8 | + * file that was distributed with this source code. |
| 9 | + * |
| 10 | + * @package OneLogin |
| 11 | + * @author OneLogin Inc <saml-info@onelogin.com> |
| 12 | + * @license MIT https://github.com/onelogin/php-saml/blob/master/LICENSE |
| 13 | + * @link https://github.com/onelogin/php-saml |
| 14 | + */ |
| 15 | + |
| 16 | +namespace OneLogin\Saml2; |
| 17 | + |
| 18 | +use Exception; |
| 19 | + |
3 | 20 | /** |
4 | 21 | * Error class of OneLogin PHP Toolkit |
5 | 22 | * |
6 | 23 | * Defines the Error class |
7 | 24 | */ |
8 | | -class OneLogin_Saml2_Error extends Exception |
| 25 | +class Error extends Exception |
9 | 26 | { |
10 | 27 | // Errors |
11 | 28 | const SETTINGS_FILE_NOT_FOUND = 0; |
@@ -33,88 +50,16 @@ class OneLogin_Saml2_Error extends Exception |
33 | 50 | * @param int $code The code error (defined in the error class). |
34 | 51 | * @param array|null $args Arguments used in the message that describes the error. |
35 | 52 | */ |
36 | | - public function __construct($msg, $code = 0, $args = null) |
37 | | - { |
38 | | - assert('is_string($msg)'); |
39 | | - assert('is_int($code)'); |
40 | | - |
41 | | - $message = OneLogin_Saml2_Utils::t($msg, $args); |
42 | | - |
43 | | - parent::__construct($message, $code); |
44 | | - } |
45 | | -} |
46 | | - |
47 | | -/** |
48 | | - * This class implements another custom Exception handler, |
49 | | - * related to exceptions that happens during validation process. |
50 | | - */ |
51 | | -class OneLogin_Saml2_ValidationError extends Exception |
52 | | -{ |
53 | | - # Validation Errors |
54 | | - const UNSUPPORTED_SAML_VERSION = 0; |
55 | | - const MISSING_ID = 1; |
56 | | - const WRONG_NUMBER_OF_ASSERTIONS = 2; |
57 | | - const MISSING_STATUS = 3; |
58 | | - const MISSING_STATUS_CODE = 4; |
59 | | - const STATUS_CODE_IS_NOT_SUCCESS = 5; |
60 | | - const WRONG_SIGNED_ELEMENT = 6; |
61 | | - const ID_NOT_FOUND_IN_SIGNED_ELEMENT = 7; |
62 | | - const DUPLICATED_ID_IN_SIGNED_ELEMENTS = 8; |
63 | | - const INVALID_SIGNED_ELEMENT = 9; |
64 | | - const DUPLICATED_REFERENCE_IN_SIGNED_ELEMENTS = 10; |
65 | | - const UNEXPECTED_SIGNED_ELEMENTS = 11; |
66 | | - const WRONG_NUMBER_OF_SIGNATURES_IN_RESPONSE = 12; |
67 | | - const WRONG_NUMBER_OF_SIGNATURES_IN_ASSERTION = 13; |
68 | | - const INVALID_XML_FORMAT = 14; |
69 | | - const WRONG_INRESPONSETO = 15; |
70 | | - const NO_ENCRYPTED_ASSERTION = 16; |
71 | | - const NO_ENCRYPTED_NAMEID = 17; |
72 | | - const MISSING_CONDITIONS = 18; |
73 | | - const ASSERTION_TOO_EARLY = 19; |
74 | | - const ASSERTION_EXPIRED = 20; |
75 | | - const WRONG_NUMBER_OF_AUTHSTATEMENTS = 21; |
76 | | - const NO_ATTRIBUTESTATEMENT = 22; |
77 | | - const ENCRYPTED_ATTRIBUTES = 23; |
78 | | - const WRONG_DESTINATION = 24; |
79 | | - const EMPTY_DESTINATION = 25; |
80 | | - const WRONG_AUDIENCE = 26; |
81 | | - const ISSUER_MULTIPLE_IN_RESPONSE = 27; |
82 | | - const ISSUER_NOT_FOUND_IN_ASSERTION = 28; |
83 | | - const WRONG_ISSUER = 29; |
84 | | - const SESSION_EXPIRED = 30; |
85 | | - const WRONG_SUBJECTCONFIRMATION = 31; |
86 | | - const NO_SIGNED_MESSAGE = 32; |
87 | | - const NO_SIGNED_ASSERTION = 33; |
88 | | - const NO_SIGNATURE_FOUND = 34; |
89 | | - const KEYINFO_NOT_FOUND_IN_ENCRYPTED_DATA = 35; |
90 | | - const CHILDREN_NODE_NOT_FOUND_IN_KEYINFO = 36; |
91 | | - const UNSUPPORTED_RETRIEVAL_METHOD = 37; |
92 | | - const NO_NAMEID = 38; |
93 | | - const EMPTY_NAMEID = 39; |
94 | | - const SP_NAME_QUALIFIER_NAME_MISMATCH = 40; |
95 | | - const DUPLICATED_ATTRIBUTE_NAME_FOUND = 41; |
96 | | - const INVALID_SIGNATURE = 42; |
97 | | - const WRONG_NUMBER_OF_SIGNATURES = 43; |
98 | | - const RESPONSE_EXPIRED = 44; |
99 | | - const UNEXPECTED_REFERENCE = 45; |
100 | | - const NOT_SUPPORTED = 46; |
101 | | - const KEY_ALGORITHM_ERROR = 47; |
102 | | - const MISSING_ENCRYPTED_ELEMENT = 48; |
103 | | - |
104 | | - |
105 | | - /** |
106 | | - * Constructor |
107 | | - * |
108 | | - * @param string $msg Describes the error. |
109 | | - * @param int $code The code error (defined in the error class). |
110 | | - * @param array|null $args Arguments used in the message that describes the error. |
111 | | - */ |
112 | | - public function __construct($msg, $code = 0, $args = null) |
| 53 | + public function __construct($msg, $code = 0, $args = array()) |
113 | 54 | { |
114 | | - assert('is_string($msg)'); |
115 | | - assert('is_int($code)'); |
| 55 | + assert(is_string($msg)); |
| 56 | + assert(is_int($code)); |
116 | 57 |
|
117 | | - $message = OneLogin_Saml2_Utils::t($msg, $args); |
| 58 | + if (!isset($args)) { |
| 59 | + $args = array(); |
| 60 | + } |
| 61 | + $params = array_merge(array($msg), $args); |
| 62 | + $message = call_user_func_array('sprintf', $params); |
118 | 63 |
|
119 | 64 | parent::__construct($message, $code); |
120 | 65 | } |
|
0 commit comments