summaryrefslogtreecommitdiff
path: root/vendor/OAuth/Common/Token
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/OAuth/Common/Token')
-rwxr-xr-xvendor/OAuth/Common/Token/AbstractToken.php121
-rwxr-xr-xvendor/OAuth/Common/Token/Exception/ExpiredTokenException.php12
-rwxr-xr-xvendor/OAuth/Common/Token/TokenInterface.php64
3 files changed, 197 insertions, 0 deletions
diff --git a/vendor/OAuth/Common/Token/AbstractToken.php b/vendor/OAuth/Common/Token/AbstractToken.php
new file mode 100755
index 00000000..8d448a18
--- /dev/null
+++ b/vendor/OAuth/Common/Token/AbstractToken.php
@@ -0,0 +1,121 @@
+<?php
+
+namespace OAuth\Common\Token;
+
+/**
+ * Base token implementation for any OAuth version.
+ */
+abstract class AbstractToken implements TokenInterface
+{
+ /**
+ * @var string
+ */
+ protected $accessToken;
+
+ /**
+ * @var string
+ */
+ protected $refreshToken;
+
+ /**
+ * @var int
+ */
+ protected $endOfLife;
+
+ /**
+ * @var array
+ */
+ protected $extraParams = array();
+
+ /**
+ * @param string $accessToken
+ * @param string $refreshToken
+ * @param int $lifetime
+ * @param array $extraParams
+ */
+ public function __construct($accessToken = null, $refreshToken = null, $lifetime = null, $extraParams = array())
+ {
+ $this->accessToken = $accessToken;
+ $this->refreshToken = $refreshToken;
+ $this->setLifetime($lifetime);
+ $this->extraParams = $extraParams;
+ }
+
+ /**
+ * @return string
+ */
+ public function getAccessToken()
+ {
+ return $this->accessToken;
+ }
+
+ /**
+ * @return string
+ */
+ public function getRefreshToken()
+ {
+ return $this->refreshToken;
+ }
+
+ /**
+ * @return int
+ */
+ public function getEndOfLife()
+ {
+ return $this->endOfLife;
+ }
+
+ /**
+ * @param array $extraParams
+ */
+ public function setExtraParams(array $extraParams)
+ {
+ $this->extraParams = $extraParams;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExtraParams()
+ {
+ return $this->extraParams;
+ }
+
+ /**
+ * @param string $accessToken
+ */
+ public function setAccessToken($accessToken)
+ {
+ $this->accessToken = $accessToken;
+ }
+
+ /**
+ * @param int $endOfLife
+ */
+ public function setEndOfLife($endOfLife)
+ {
+ $this->endOfLife = $endOfLife;
+ }
+
+ /**
+ * @param int $lifetime
+ */
+ public function setLifetime($lifetime)
+ {
+ if (0 === $lifetime || static::EOL_NEVER_EXPIRES === $lifetime) {
+ $this->endOfLife = static::EOL_NEVER_EXPIRES;
+ } elseif (null !== $lifetime) {
+ $this->endOfLife = intval($lifetime) + time();
+ } else {
+ $this->endOfLife = static::EOL_UNKNOWN;
+ }
+ }
+
+ /**
+ * @param string $refreshToken
+ */
+ public function setRefreshToken($refreshToken)
+ {
+ $this->refreshToken = $refreshToken;
+ }
+}
diff --git a/vendor/OAuth/Common/Token/Exception/ExpiredTokenException.php b/vendor/OAuth/Common/Token/Exception/ExpiredTokenException.php
new file mode 100755
index 00000000..26ad6cc5
--- /dev/null
+++ b/vendor/OAuth/Common/Token/Exception/ExpiredTokenException.php
@@ -0,0 +1,12 @@
+<?php
+
+namespace OAuth\Common\Token\Exception;
+
+use OAuth\Common\Exception\Exception;
+
+/**
+ * Exception thrown when an expired token is attempted to be used.
+ */
+class ExpiredTokenException extends Exception
+{
+}
diff --git a/vendor/OAuth/Common/Token/TokenInterface.php b/vendor/OAuth/Common/Token/TokenInterface.php
new file mode 100755
index 00000000..84a41092
--- /dev/null
+++ b/vendor/OAuth/Common/Token/TokenInterface.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace OAuth\Common\Token;
+
+/**
+ * Base token interface for any OAuth version.
+ */
+interface TokenInterface
+{
+ /**
+ * Denotes an unknown end of life time.
+ */
+ const EOL_UNKNOWN = -9001;
+
+ /**
+ * Denotes a token which never expires, should only happen in OAuth1.
+ */
+ const EOL_NEVER_EXPIRES = -9002;
+
+ /**
+ * @return string
+ */
+ public function getAccessToken();
+
+ /**
+ * @return int
+ */
+ public function getEndOfLife();
+
+ /**
+ * @return array
+ */
+ public function getExtraParams();
+
+ /**
+ * @param string $accessToken
+ */
+ public function setAccessToken($accessToken);
+
+ /**
+ * @param int $endOfLife
+ */
+ public function setEndOfLife($endOfLife);
+
+ /**
+ * @param int $lifetime
+ */
+ public function setLifetime($lifetime);
+
+ /**
+ * @param array $extraParams
+ */
+ public function setExtraParams(array $extraParams);
+
+ /**
+ * @return string
+ */
+ public function getRefreshToken();
+
+ /**
+ * @param string $refreshToken
+ */
+ public function setRefreshToken($refreshToken);
+}