[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * This file is part of Lcobucci\JWT, a simple library to handle JWT and JWS 4 * 5 * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause 6 */ 7 8 namespace Lcobucci\JWT; 9 10 /** 11 * Class that wraps validation values 12 * 13 * @deprecated This component has been removed from the interface in v4.0 14 * @see \Lcobucci\JWT\Validation\Validator 15 * 16 * @author Luís Otávio Cobucci Oblonczyk <[email protected]> 17 * @since 2.0.0 18 */ 19 class ValidationData 20 { 21 /** 22 * The list of things to be validated 23 * 24 * @var array 25 */ 26 private $items; 27 28 /** 29 * The leeway (in seconds) to use when validating time claims 30 * @var int 31 */ 32 private $leeway; 33 34 /** 35 * Initializes the object 36 * 37 * @param int $currentTime 38 * @param int $leeway 39 */ 40 public function __construct($currentTime = null, $leeway = 0) 41 { 42 $currentTime = $currentTime ?: time(); 43 $this->leeway = (int) $leeway; 44 45 $this->items = [ 46 'jti' => null, 47 'iss' => null, 48 'aud' => null, 49 'sub' => null 50 ]; 51 52 $this->setCurrentTime($currentTime); 53 } 54 55 /** 56 * Configures the id 57 * 58 * @param string $id 59 */ 60 public function setId($id) 61 { 62 $this->items['jti'] = (string) $id; 63 } 64 65 /** 66 * Configures the issuer 67 * 68 * @param string $issuer 69 */ 70 public function setIssuer($issuer) 71 { 72 $this->items['iss'] = (string) $issuer; 73 } 74 75 /** 76 * Configures the audience 77 * 78 * @param string $audience 79 */ 80 public function setAudience($audience) 81 { 82 $this->items['aud'] = (string) $audience; 83 } 84 85 /** 86 * Configures the subject 87 * 88 * @param string $subject 89 */ 90 public function setSubject($subject) 91 { 92 $this->items['sub'] = (string) $subject; 93 } 94 95 /** 96 * Configures the time that "iat", "nbf" and "exp" should be based on 97 * 98 * @param int $currentTime 99 */ 100 public function setCurrentTime($currentTime) 101 { 102 $currentTime = (int) $currentTime; 103 104 $this->items['iat'] = $currentTime + $this->leeway; 105 $this->items['nbf'] = $currentTime + $this->leeway; 106 $this->items['exp'] = $currentTime - $this->leeway; 107 } 108 109 /** 110 * Returns the requested item 111 * 112 * @param string $name 113 * 114 * @return mixed 115 */ 116 public function get($name) 117 { 118 return isset($this->items[$name]) ? $this->items[$name] : null; 119 } 120 121 /** 122 * Returns if the item is present 123 * 124 * @param string $name 125 * 126 * @return boolean 127 */ 128 public function has($name) 129 { 130 return !empty($this->items[$name]); 131 } 132 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |