You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/06/25 20:52:30 UTC
svn commit: r671636 -
/incubator/shindig/trunk/php/src/common/samplecontainer/BasicSecurityToken.php
Author: chabotc
Date: Wed Jun 25 11:52:30 2008
New Revision: 671636
URL: http://svn.apache.org/viewvc?rev=671636&view=rev
Log:
Some formatting errors were hiding in this file
Modified:
incubator/shindig/trunk/php/src/common/samplecontainer/BasicSecurityToken.php
Modified: incubator/shindig/trunk/php/src/common/samplecontainer/BasicSecurityToken.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/samplecontainer/BasicSecurityToken.php?rev=671636&r1=671635&r2=671636&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/common/samplecontainer/BasicSecurityToken.php (original)
+++ incubator/shindig/trunk/php/src/common/samplecontainer/BasicSecurityToken.php Wed Jun 25 11:52:30 2008
@@ -22,114 +22,119 @@
* Primitive token implementation that uses stings as tokens.
*/
class BasicSecurityToken extends SecurityToken {
- /** serialized form of the token */
- private $token;
-
- /** data from the token */
- private $tokenData;
-
- /** tool to use for signing and encrypting the token */
- private $crypter;
-
- private $OWNER_KEY = "o";
- private $APP_KEY = "a";
- private $VIEWER_KEY = "v";
- private $DOMAIN_KEY = "d";
- private $APPURL_KEY = "u";
- private $MODULE_KEY = "m";
-
- /**
- * {@inheritDoc}
- */
- public function toSerialForm()
- {
- return urlencode($this->token);
- }
-
- /**
- * Generates a token from an input string
- * @param token String form of token
- * @param maxAge max age of the token (in seconds)
- * @throws BlobCrypterException
- */
- static public function createFromToken($token, $maxAge)
- {
- return new BasicSecurityToken($token, $maxAge, null, null, null, null, null, null);
- }
-
- /**
- * Generates a token from an input array of values
- * @param owner owner of this gadget
- * @param viewer viewer of this gadget
- * @param app application id
- * @param domain domain of the container
- * @param appUrl url where the application lives
- * @param moduleId module id of this gadget
- * @throws BlobCrypterException
- */
- static public function createFromValues($owner, $viewer, $app, $domain, $appUrl, $moduleId)
- {
- return new BasicSecurityToken(null, null, $owner, $viewer, $app, $domain, $appUrl, $moduleId);
- }
-
-
- public function __construct($token, $maxAge, $owner, $viewer, $app, $domain, $appUrl, $moduleId)
- {
- $this->crypter = new BasicBlobCrypter();
- if (!empty($token)) {
- $this->token = $token;
- $this->tokenData = $this->crypter->unwrap($token, $maxAge);
- } else {
- $this->tokenData = array();
- $this->tokenData[$this->OWNER_KEY] = $owner;
- $this->tokenData[$this->VIEWER_KEY] = $viewer;
- $this->tokenData[$this->APP_KEY] = $app;
- $this->tokenData[$this->DOMAIN_KEY] = $domain;
- $this->tokenData[$this->APPURL_KEY] = $appUrl;
- $this->tokenData[$this->MODULE_KEY] = $moduleId;
- $this->token = $this->crypter->wrap($this->tokenData);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public function getAppId() {
- return $this->tokenData[$this->APP_KEY];
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDomain() {
- return $this->tokenData[$this->DOMAIN_KEY];
- }
-
- /**
- * {@inheritDoc}
- */
- public function getOwnerId() {
- return $this->tokenData[$this->OWNER_KEY];
- }
-
- /**
- * {@inheritDoc}
- */
- public function getViewerId() {
- return $this->tokenData[$this->VIEWER_KEY];
- }
-
- /**
- * {@inheritDoc}
- */
- public function getAppUrl() {
- return $this->tokenData[$this->APPURL_KEY];
- }
-
- /**
- * {@inheritDoc}
- */
- public function getModuleId() {
- return intval($this->tokenData[$this->MODULE_KEY]);
- }
+ /** serialized form of the token */
+ private $token;
+
+ /** data from the token */
+ private $tokenData;
+
+ /** tool to use for signing and encrypting the token */
+ private $crypter;
+
+ private $OWNER_KEY = "o";
+ private $APP_KEY = "a";
+ private $VIEWER_KEY = "v";
+ private $DOMAIN_KEY = "d";
+ private $APPURL_KEY = "u";
+ private $MODULE_KEY = "m";
+
+ /**
+ * {@inheritDoc}
+ */
+ public function toSerialForm()
+ {
+ return urlencode($this->token);
+ }
+
+ /**
+ * Generates a token from an input string
+ * @param token String form of token
+ * @param maxAge max age of the token (in seconds)
+ * @throws BlobCrypterException
+ */
+ static public function createFromToken($token, $maxAge)
+ {
+ return new BasicSecurityToken($token, $maxAge, null, null, null, null, null, null);
+ }
+
+ /**
+ * Generates a token from an input array of values
+ * @param owner owner of this gadget
+ * @param viewer viewer of this gadget
+ * @param app application id
+ * @param domain domain of the container
+ * @param appUrl url where the application lives
+ * @param moduleId module id of this gadget
+ * @throws BlobCrypterException
+ */
+ static public function createFromValues($owner, $viewer, $app, $domain, $appUrl, $moduleId)
+ {
+ return new BasicSecurityToken(null, null, $owner, $viewer, $app, $domain, $appUrl, $moduleId);
+ }
+
+ public function __construct($token, $maxAge, $owner, $viewer, $app, $domain, $appUrl, $moduleId)
+ {
+ $this->crypter = new BasicBlobCrypter();
+ if (! empty($token)) {
+ $this->token = $token;
+ $this->tokenData = $this->crypter->unwrap($token, $maxAge);
+ } else {
+ $this->tokenData = array();
+ $this->tokenData[$this->OWNER_KEY] = $owner;
+ $this->tokenData[$this->VIEWER_KEY] = $viewer;
+ $this->tokenData[$this->APP_KEY] = $app;
+ $this->tokenData[$this->DOMAIN_KEY] = $domain;
+ $this->tokenData[$this->APPURL_KEY] = $appUrl;
+ $this->tokenData[$this->MODULE_KEY] = $moduleId;
+ $this->token = $this->crypter->wrap($this->tokenData);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getAppId()
+ {
+ return $this->tokenData[$this->APP_KEY];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getDomain()
+ {
+ return $this->tokenData[$this->DOMAIN_KEY];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getOwnerId()
+ {
+ return $this->tokenData[$this->OWNER_KEY];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getViewerId()
+ {
+ return $this->tokenData[$this->VIEWER_KEY];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getAppUrl()
+ {
+ return $this->tokenData[$this->APPURL_KEY];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getModuleId()
+ {
+ return intval($this->tokenData[$this->MODULE_KEY]);
+ }
}