|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace org\gocdb\security\authentication; |
| 4 | + |
| 5 | +require_once __DIR__ . '/../IAuthentication.php'; |
| 6 | + |
| 7 | +abstract class OIDCAuthToken implements IAuthentication |
| 8 | +{ |
| 9 | + private $userDetails = null; |
| 10 | + private $authorities = array(); |
| 11 | + private $principal; |
| 12 | + |
| 13 | + /** |
| 14 | + * {@see IAuthentication::eraseCredentials()} |
| 15 | + */ |
| 16 | + public function eraseCredentials() |
| 17 | + { |
| 18 | + } |
| 19 | + |
| 20 | + /** |
| 21 | + * {@see IAuthentication::getAuthorities()} |
| 22 | + */ |
| 23 | + public function getAuthorities() |
| 24 | + { |
| 25 | + return $this->authorities; |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * {@see IAuthentication::getCredentials()} |
| 30 | + * @return string An empty string as passwords are not used by this token. |
| 31 | + */ |
| 32 | + public function getCredentials() |
| 33 | + { |
| 34 | + return ""; // none used in this token, handled by IdP |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * A custom object used to store additional user details. |
| 39 | + * Allows non-security related user information (such as email addresses, |
| 40 | + * telephone numbers etc) to be stored in a convenient location. |
| 41 | + * {@see IAuthentication::getDetails()} |
| 42 | + * |
| 43 | + * @return Object or null if not used |
| 44 | + */ |
| 45 | + public function getDetails() |
| 46 | + { |
| 47 | + return $this->userDetails; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * {@see IAuthentication::getPrinciple()} |
| 52 | + * @return string unique principle string of user |
| 53 | + */ |
| 54 | + public function getPrinciple() |
| 55 | + { |
| 56 | + return $this->principal; |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * {@see IAuthentication::setAuthorities($authorities)} |
| 61 | + */ |
| 62 | + public function setAuthorities($authorities) |
| 63 | + { |
| 64 | + $this->authorities = $authorities; |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * {@see IAuthentication::setDetails($userDetails)} |
| 69 | + * @param Object $userDetails |
| 70 | + */ |
| 71 | + public function setDetails($userDetails) |
| 72 | + { |
| 73 | + $this->userDetails = $userDetails; |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * {@see IAuthentication::validate()} |
| 78 | + */ |
| 79 | + public function validate() |
| 80 | + { |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * {@see IAuthentication::isPreAuthenticating()} |
| 85 | + */ |
| 86 | + public static function isPreAuthenticating() |
| 87 | + { |
| 88 | + return true; |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Returns true, this token reads the session attributes and so |
| 93 | + * does not need to be stateful itself. |
| 94 | + * {@see IAuthentication::isStateless()} |
| 95 | + */ |
| 96 | + public static function isStateless() |
| 97 | + { |
| 98 | + return true; |
| 99 | + } |
| 100 | +} |
0 commit comments