Skip to content

Instantly share code, notes, and snippets.

@tad3j
Created July 3, 2014 11:44
Show Gist options
  • Save tad3j/5e539e81f188c6467dca to your computer and use it in GitHub Desktop.
Save tad3j/5e539e81f188c6467dca to your computer and use it in GitHub Desktop.
Apigility Oauth Entites
<?php
namespace RacApi\V1\Entity\Oauth;
use Doctrine\ORM\Mapping as ORM;
/**
* OauthAccessToken
*
* @ORM\Table(name="oauth_access_tokens")
* @ORM\Entity()
*/
class OauthAccessToken
{
/**
* @var string
*
* @ORM\Id
* @ORM\Column(name="access_token", type="string", length=40, nullable=false)
*/
private $accessToken;
/**
* @var string
*
* @ORM\Column(name="client_id", type="string", length=80, nullable=false)
*/
private $clientId;
/**
* @var string
*
* @ORM\Column(name="user_id", type="string", length=255, nullable=true)
*/
private $userId;
/**
* @var \DateTime
*
* @ORM\Column(name="expires", type="datetime", nullable=false)
*/
private $expires;
/**
* @var string
*
* @ORM\Column(name="scope", type="string", length=2000, nullable=true)
*/
private $scope;
/**
* Set token
*
* @param string $token
* @return OauthAccessToken
*/
public function setAccessToken($token)
{
$this->accessToken = $token;
return $this;
}
/**
* Get token
*
* @return string
*/
public function getAccessToken()
{
return $this->accessToken;
}
/**
* Set client
*
* @param string $client
* @return OauthAccessToken
*/
public function setClientId($client = null)
{
$this->clientId = $client;
return $this;
}
/**
* Get client
*
* @return \RacApi\V1\Entity\Oauth\OauthClient
*/
public function getClientId()
{
return $this->clientId;
}
/**
* Set user_id
*
* @param string $userId
* @return OauthAccessToken
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get user_id
*
* @return string
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set expires
*
* @param \DateTime $expires
* @return OauthAccessToken
*/
public function setExpires($expires)
{
$this->expires = $expires;
return $this;
}
/**
* Get expires
*
* @return \DateTime
*/
public function getExpires()
{
return $this->expires;
}
/**
* Set scope
*
* @param string $scope
* @return OauthAccessToken
*/
public function setScope($scope)
{
$this->scope = $scope;
return $this;
}
/**
* Get scope
*
* @return string
*/
public function getScope()
{
return $this->scope;
}
}
<?php
namespace RacApi\V1\Entity\Oauth;
use Doctrine\ORM\Mapping as ORM;
/**
* OauthAuthorizationCode
*
* @ORM\Table(name="oauth_authorization_codes")
* @ORM\Entity()
*/
class OauthAuthorizationCode
{
/**
* @var string
*
* @ORM\Id
* @ORM\Column(name="authorization_code", type="string", length=40, nullable=false)
*/
private $authorizationCode;
/**
* @var \RacApi\V1\Entity\Oauth\OauthClient
*
* @ORM\Column(name="client_id", type="string", length=80, nullable=false)
*/
private $clientId;
/**
* @var string
*
* @ORM\Column(name="user_id", type="string", length=255, nullable=true)
*/
private $userId;
/**
* @var string
*
* @ORM\Column(name="redirect_uri", type="string", length=2000, nullable=true)
*/
private $redirectUri;
/**
* @var \DateTime
*
* @ORM\Column(name="expires", type="datetime", nullable=false)
*/
private $expires;
/**
* @var string
*
* @ORM\Column(name="scope", type="string", length=2000, nullable=true)
*/
private $scope;
/**
* @var string
*
* @ORM\Column(name="id_token", type="string", length=2000, nullable=true)
*/
private $idToken;
/**
* Set code
*
* @param string $code
* @return OauthAuthorizationCode
*/
public function setAuthorizationCode($code)
{
$this->authorizationCode = $code;
return $this;
}
/**
* Get code
*
* @return string
*/
public function getAuthorizationCode()
{
return $this->authorizationCode;
}
/**
* Set client
*
* @param string $client
* @return OauthAuthorizationCode
*/
public function setClientId($client = null)
{
$this->clientId = $client;
return $this;
}
/**
* Get client
*
* @return string
*/
public function getClientId()
{
return $this->clientId;
}
/**
* Set user_id
*
* @param string $userId
* @return OauthAuthorizationCode
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get user_id
*
* @return string
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set redirect_uri
*
* @param string $redirectUri
* @return OauthAuthorizationCode
*/
public function setRedirectUri($redirectUri)
{
$this->redirectUri = explode(' ', $redirectUri);
return $this;
}
/**
* Get redirect_uri
*
* @return array
*/
public function getRedirectUri()
{
return $this->redirectUri;
}
/**
* Set expires
*
* @param \DateTime $expires
* @return OauthAuthorizationCode
*/
public function setExpires($expires)
{
$this->expires = $expires;
return $this;
}
/**
* Get expires
*
* @return \DateTime
*/
public function getExpires()
{
return $this->expires;
}
/**
* Set scope
*
* @param string $scope
* @return OauthAuthorizationCode
*/
public function setScope($scope)
{
$this->scope = $scope;
return $this;
}
/**
* Get scope
*
* @return string
*/
public function getScope()
{
return $this->scope;
}
/**
* Set idToken
*
* @param string $idToken
* @return OauthAuthorizationCode
*/
public function setIdToken($idToken)
{
$this->idToken = $idToken;
return $this;
}
/**
* Get idToken
*
* @return string
*/
public function getIdToken()
{
return $this->idToken;
}
}
<?php
namespace RacApi\V1\Entity\Oauth;
use Doctrine\ORM\Mapping as ORM;
/**
* OauthClient
*
* @ORM\Table(name="oauth_clients")
* @ORM\Entity()
*/
class OauthClient
{
/**
* @var string
*
* @ORM\Id
* @ORM\Column(name="client_id", type="string", length=80, nullable=false)
*/
private $clientId;
/**
* @var string
*
* @ORM\Column(name="client_secret", type="string", length=80, nullable=false)
*/
private $clientSecret;
/**
* @var string
*
* @ORM\Column(name="redirect_uri", type="string", length=2000, nullable=false)
*/
private $redirectUri;
/**
* @var string
*
* @ORM\Column(name="grant_types", type="string", length=80, nullable=true)
*/
private $grantTypes;
/**
* @var string
*
* @ORM\Column(name="scope", type="string", length=2000, nullable=true)
*/
private $scope;
/**
* @var string
*
* @ORM\Column(name="user_id", type="string", length=255, nullable=true)
*/
private $userId;
/**
* @var \RacApi\V1\Entity\Oauth\OauthUser
*
* @ORM\ManyToOne(targetEntity="RacApi\V1\Entity\Oauth\OauthUser")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="user", referencedColumnName="username", nullable=true)
* })
*/
private $user;
/**
* Set client_id
*
* @param string $clientId
* @return OauthClient
*/
public function setClientId($clientId)
{
$this->clientId = $clientId;
return $this;
}
/**
* Get client_id
*
* @return string
*/
public function getClientId()
{
return $this->clientId;
}
/**
* Set client_secret
*
* @param string $clientSecret
* @return OauthClient
*/
public function setClientSecret($clientSecret)
{
$this->clientSecret = $clientSecret;
return $this;
}
/**
* Get client_secret
*
* @return string
*/
public function getClientSecret()
{
return $this->clientSecret;
}
/**
* Set redirect_uri
*
* @param array $redirectUri
* @return OauthClient
*/
public function setRedirectUri($redirectUri)
{
$this->redirectUri = $redirectUri;
return $this;
}
/**
* Get redirect_uri
*
* @return array
*/
public function getRedirectUri()
{
return $this->redirectUri;
}
/**
* Set grant_types
*
* @param array $grantTypes
* @return OauthClient
*/
public function setGrantTypes($grantTypes)
{
$this->grantTypes = $grantTypes;
return $this;
}
/**
* Get grant_types
*
* @return array
*/
public function getGrantTypes()
{
return $this->grantTypes;
}
/**
* Set scope
*
* @param string $scope
* @return OauthClient
*/
public function setScope($scope)
{
$this->scope = $scope;
return $this;
}
/**
* Get scope
*
* @return string
*/
public function getScope()
{
return $this->scope;
}
/**
* Set user_id
*
* @param string $userId
* @return OauthClient
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get user_id
*
* @return string
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set user
*
* @param \RacApi\V1\Entity\Oauth\OauthUser $user
* @return OauthClient
*/
public function setUser(OauthUser $user)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return \RacApi\V1\Entity\Oauth\OauthUser
*/
public function getUser()
{
return $this->user;
}
}
<?php
namespace RacApi\V1\Entity\Oauth;
use Doctrine\ORM\Mapping as ORM;
/**
* OauthJsonWebToken
*
* @ORM\Table(name="oauth_jwt")
* @ORM\Entity()
*/
class OauthJsonWebToken
{
/**
* @var string
*
* @ORM\Id
* @ORM\Column(name="client_id", type="string", length=80, nullable=false)
*/
private $client;
/**
* @var string
*
* @ORM\Column(name="subject", type="string", length=80, nullable=true)
*/
private $subject;
/**
* @var string
*
* @ORM\Column(name="public_key", type="string", length=2000, nullable=true)
*/
private $publicKey;
/**
* Set client
*
* @param string
* @return OauthRefreshToken
*/
public function setClient($client = null)
{
$this->client = $client;
return $this;
}
/**
* Get client
*
* @return string
*/
public function getClient()
{
return $this->client;
}
/**
* Set subject
*
* @param string $subject
* @return OauthRefreshToken
*/
public function setSubject($subject)
{
$this->subject = $subject;
return $this;
}
/**
* Get subject
*
* @return string
*/
public function getSubject()
{
return $this->subject;
}
/**
* Set publicKey
*
* @param string $publicKey
* @return OauthRefreshToken
*/
public function setPublicKey($publicKey)
{
$this->publicKey = $publicKey;
return $this;
}
/**
* Get publicKey
*
* @return string
*/
public function getPublicKey()
{
return $this->publicKey;
}
}
<?php
namespace RacApi\V1\Entity\Oauth;
use Doctrine\ORM\Mapping as ORM;
/**
* OauthRefreshToken
*
* @ORM\Table(name="oauth_refresh_tokens")
* @ORM\Entity()
*/
class OauthRefreshToken
{
/**
* @var string
*
* @ORM\Id
* @ORM\Column(name="refresh_token", type="string", length=40, nullable=false)
*/
private $refreshToken;
/**
* @var string
*
* @ORM\Column(name="client_id", type="string", length=80, nullable=false)
*/
private $clientId;
/**
* @var string
*
* @ORM\Column(name="user_id", type="string", length=255, nullable=true)
*/
private $userId;
/**
* @var \DateTime
*
* @ORM\Column(name="expires", type="datetime", nullable=false)
*/
private $expires;
/**
* @var string
*
* @ORM\Column(name="scope", type="string", length=2000, nullable=true)
*/
private $scope;
/**
* Set token
*
* @param string $token
* @return OauthRefreshToken
*/
public function setRefreshToken($token)
{
$this->refreshToken = $token;
return $this;
}
/**
* Get token
*
* @return string
*/
public function getRefreshToken()
{
return $this->refreshToken;
}
/**
* Set user_id
*
* @param string $userId
* @return OauthRefreshToken
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get user_id
*
* @return string
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set expires
*
* @param \DateTime $expires
* @return OauthRefreshToken
*/
public function setExpires($expires)
{
$this->expires = $expires;
return $this;
}
/**
* Get expires
*
* @return \DateTime
*/
public function getExpires()
{
return $this->expires;
}
/**
* Set scope
*
* @param string $scope
* @return OauthRefreshToken
*/
public function setScope($scope)
{
$this->scope = $scope;
return $this;
}
/**
* Get scope
*
* @return string
*/
public function getScope()
{
return $this->scope;
}
/**
* Set client
*
* @param string $client
* @return OauthRefreshToken
*/
public function setClientId($client = null)
{
$this->clientId = $client;
return $this;
}
/**
* Get client
*
* @return string
*/
public function getClientId()
{
return $this->clientId;
}
}
<?php
namespace RacApi\V1\Entity\Oauth;
use Doctrine\ORM\Mapping as ORM;
/**
* OauthScope
*
* @ORM\Table(name="oauth_scopes")
* @ORM\Entity()
*/
class OauthScope
{
/**
* @var int
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="type", type="string", length=255, nullable=false)
*/
private $type;
/**
* @var string
* @ORM\Column(name="scope", type="string", length=2000, nullable=true)
*/
private $scope;
/**
* @var string
*
* @ORM\Column(name="client_id", type="string", length=80, nullable=true)
*/
private $client;
/**
* @var integer
*
* @ORM\Column(name="is_default", type="smallint", nullable=true)
*/
private $isDefault;
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set id.
*
* @param int $id
*
* @return OauthScope
*/
public function setId($id)
{
$this->id = (int)$id;
return $this;
}
/**
* Set type
*
* @param string $type
* @return OauthScope
*/
public function setType($type = 'supported')
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Set scope
*
* @param string $scope
* @return OauthScope
*/
public function setScope($scope)
{
$this->scope = $scope;
return $this;
}
/**
* Get scope
*
* @return string
*/
public function getScope()
{
return $this->scope;
}
/**
* Set client
*
* @param string $client
* @return OauthScope
*/
public function setClient($client = null)
{
$this->client = $client;
return $this;
}
/**
* Get client
*
* @return string
*/
public function getClient()
{
return $this->client;
}
/**
* Set isDefault
*
* @param int $isDefault
* @return OauthScope
*/
public function setIsDefault($isDefault = null)
{
$this->isDefault = $isDefault;
return $this;
}
/**
* Get isDefault
*
* @return int
*/
public function getIsDefault()
{
return $this->isDefault;
}
}
<?php
namespace RacApi\V1\Entity\Oauth;
use Doctrine\ORM\Mapping as ORM;
/**
* OauthUser
*
* @ORM\Table(name="oauth_users")
* @ORM\Entity()
*/
class OauthUser
{
/**
* @var string
*
* @ORM\Id
* @ORM\Column(name="username", type="string", length=255, nullable=false)
*/
protected $username;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=2000, nullable=true)
*/
protected $password;
/**
* @var string
*
* @ORM\Column(name="first_name", type="string", length=255, nullable=true)
*/
protected $firstName;
/**
* @var string
*
* @ORM\Column(name="last_name", type="string", length=255, nullable=true)
*/
protected $lastName;
/**
* Get username.
*
* @return string
*/
public function getUsername()
{
return $this->username;
}
/**
* Set username.
*
* @param string $username
*
* @return OauthUser
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* Get password.
*
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Set password.
*
* @param string $password
*
* @return OauthUser
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Get firstName.
*
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* Set firstName.
*
* @param string $firstName
*
* @return OauthUser
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
return $this;
}
/**
* Get lastName.
*
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* Set lastName.
*
* @param string $lastName
*
* @return OauthUser
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment