1<?php 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 16namespace OneLogin\Saml2; 17 18use Exception; 19 20/** 21 * ValidationError class of OneLogin PHP Toolkit 22 * 23 * This class implements another custom Exception handler, 24 * related to exceptions that happens during validation process. 25 */ 26class ValidationError extends Exception 27{ 28 // Validation Errors 29 const UNSUPPORTED_SAML_VERSION = 0; 30 const MISSING_ID = 1; 31 const WRONG_NUMBER_OF_ASSERTIONS = 2; 32 const MISSING_STATUS = 3; 33 const MISSING_STATUS_CODE = 4; 34 const STATUS_CODE_IS_NOT_SUCCESS = 5; 35 const WRONG_SIGNED_ELEMENT = 6; 36 const ID_NOT_FOUND_IN_SIGNED_ELEMENT = 7; 37 const DUPLICATED_ID_IN_SIGNED_ELEMENTS = 8; 38 const INVALID_SIGNED_ELEMENT = 9; 39 const DUPLICATED_REFERENCE_IN_SIGNED_ELEMENTS = 10; 40 const UNEXPECTED_SIGNED_ELEMENTS = 11; 41 const WRONG_NUMBER_OF_SIGNATURES_IN_RESPONSE = 12; 42 const WRONG_NUMBER_OF_SIGNATURES_IN_ASSERTION = 13; 43 const INVALID_XML_FORMAT = 14; 44 const WRONG_INRESPONSETO = 15; 45 const NO_ENCRYPTED_ASSERTION = 16; 46 const NO_ENCRYPTED_NAMEID = 17; 47 const MISSING_CONDITIONS = 18; 48 const ASSERTION_TOO_EARLY = 19; 49 const ASSERTION_EXPIRED = 20; 50 const WRONG_NUMBER_OF_AUTHSTATEMENTS = 21; 51 const NO_ATTRIBUTESTATEMENT = 22; 52 const ENCRYPTED_ATTRIBUTES = 23; 53 const WRONG_DESTINATION = 24; 54 const EMPTY_DESTINATION = 25; 55 const WRONG_AUDIENCE = 26; 56 const ISSUER_MULTIPLE_IN_RESPONSE = 27; 57 const ISSUER_NOT_FOUND_IN_ASSERTION = 28; 58 const WRONG_ISSUER = 29; 59 const SESSION_EXPIRED = 30; 60 const WRONG_SUBJECTCONFIRMATION = 31; 61 const NO_SIGNED_MESSAGE = 32; 62 const NO_SIGNED_ASSERTION = 33; 63 const NO_SIGNATURE_FOUND = 34; 64 const KEYINFO_NOT_FOUND_IN_ENCRYPTED_DATA = 35; 65 const CHILDREN_NODE_NOT_FOUND_IN_KEYINFO = 36; 66 const UNSUPPORTED_RETRIEVAL_METHOD = 37; 67 const NO_NAMEID = 38; 68 const EMPTY_NAMEID = 39; 69 const SP_NAME_QUALIFIER_NAME_MISMATCH = 40; 70 const DUPLICATED_ATTRIBUTE_NAME_FOUND = 41; 71 const INVALID_SIGNATURE = 42; 72 const WRONG_NUMBER_OF_SIGNATURES = 43; 73 const RESPONSE_EXPIRED = 44; 74 const UNEXPECTED_REFERENCE = 45; 75 const NOT_SUPPORTED = 46; 76 const KEY_ALGORITHM_ERROR = 47; 77 const MISSING_ENCRYPTED_ELEMENT = 48; 78 79 80 /** 81 * Constructor 82 * 83 * @param string $msg Describes the error. 84 * @param int $code The code error (defined in the error class). 85 * @param array|null $args Arguments used in the message that describes the error. 86 */ 87 public function __construct($msg, $code = 0, $args = array()) 88 { 89 assert(is_string($msg)); 90 assert(is_int($code)); 91 92 if (!isset($args)) { 93 $args = array(); 94 } 95 $params = array_merge(array($msg), $args); 96 $message = call_user_func_array('sprintf', $params); 97 98 parent::__construct($message, $code); 99 } 100} 101