@@ -30,62 +30,62 @@ |
||
| 30 | 30 | |
| 31 | 31 | class ClientMapper extends QBMapper { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param IDBConnection $db |
|
| 35 | - */ |
|
| 36 | - public function __construct(IDBConnection $db) { |
|
| 37 | - parent::__construct($db, 'oauth2_clients'); |
|
| 38 | - } |
|
| 33 | + /** |
|
| 34 | + * @param IDBConnection $db |
|
| 35 | + */ |
|
| 36 | + public function __construct(IDBConnection $db) { |
|
| 37 | + parent::__construct($db, 'oauth2_clients'); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param string $clientIdentifier |
|
| 42 | - * @return Client |
|
| 43 | - * @throws ClientNotFoundException |
|
| 44 | - */ |
|
| 45 | - public function getByIdentifier(string $clientIdentifier): Client { |
|
| 46 | - $qb = $this->db->getQueryBuilder(); |
|
| 47 | - $qb |
|
| 48 | - ->select('*') |
|
| 49 | - ->from($this->tableName) |
|
| 50 | - ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier))); |
|
| 40 | + /** |
|
| 41 | + * @param string $clientIdentifier |
|
| 42 | + * @return Client |
|
| 43 | + * @throws ClientNotFoundException |
|
| 44 | + */ |
|
| 45 | + public function getByIdentifier(string $clientIdentifier): Client { |
|
| 46 | + $qb = $this->db->getQueryBuilder(); |
|
| 47 | + $qb |
|
| 48 | + ->select('*') |
|
| 49 | + ->from($this->tableName) |
|
| 50 | + ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier))); |
|
| 51 | 51 | |
| 52 | - try { |
|
| 53 | - $client = $this->findEntity($qb); |
|
| 54 | - } catch (IMapperException $e) { |
|
| 55 | - throw new ClientNotFoundException('could not find client '.$clientIdentifier, 0, $e); |
|
| 56 | - } |
|
| 57 | - return $client; |
|
| 58 | - } |
|
| 52 | + try { |
|
| 53 | + $client = $this->findEntity($qb); |
|
| 54 | + } catch (IMapperException $e) { |
|
| 55 | + throw new ClientNotFoundException('could not find client '.$clientIdentifier, 0, $e); |
|
| 56 | + } |
|
| 57 | + return $client; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @param int $id internal id of the client |
|
| 62 | - * @return Client |
|
| 63 | - * @throws ClientNotFoundException |
|
| 64 | - */ |
|
| 65 | - public function getByUid(int $id): Client { |
|
| 66 | - $qb = $this->db->getQueryBuilder(); |
|
| 67 | - $qb |
|
| 68 | - ->select('*') |
|
| 69 | - ->from($this->tableName) |
|
| 70 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
| 60 | + /** |
|
| 61 | + * @param int $id internal id of the client |
|
| 62 | + * @return Client |
|
| 63 | + * @throws ClientNotFoundException |
|
| 64 | + */ |
|
| 65 | + public function getByUid(int $id): Client { |
|
| 66 | + $qb = $this->db->getQueryBuilder(); |
|
| 67 | + $qb |
|
| 68 | + ->select('*') |
|
| 69 | + ->from($this->tableName) |
|
| 70 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
| 71 | 71 | |
| 72 | - try { |
|
| 73 | - $client = $this->findEntity($qb); |
|
| 74 | - } catch (IMapperException $e) { |
|
| 75 | - throw new ClientNotFoundException('could not find client with id '.$id, 0, $e); |
|
| 76 | - } |
|
| 77 | - return $client; |
|
| 78 | - } |
|
| 72 | + try { |
|
| 73 | + $client = $this->findEntity($qb); |
|
| 74 | + } catch (IMapperException $e) { |
|
| 75 | + throw new ClientNotFoundException('could not find client with id '.$id, 0, $e); |
|
| 76 | + } |
|
| 77 | + return $client; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @return Client[] |
|
| 82 | - */ |
|
| 83 | - public function getClients(): array { |
|
| 84 | - $qb = $this->db->getQueryBuilder(); |
|
| 85 | - $qb |
|
| 86 | - ->select('*') |
|
| 87 | - ->from($this->tableName); |
|
| 80 | + /** |
|
| 81 | + * @return Client[] |
|
| 82 | + */ |
|
| 83 | + public function getClients(): array { |
|
| 84 | + $qb = $this->db->getQueryBuilder(); |
|
| 85 | + $qb |
|
| 86 | + ->select('*') |
|
| 87 | + ->from($this->tableName); |
|
| 88 | 88 | |
| 89 | - return $this->findEntities($qb); |
|
| 90 | - } |
|
| 89 | + return $this->findEntities($qb); |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -30,44 +30,44 @@ |
||
| 30 | 30 | |
| 31 | 31 | class AccessTokenMapper extends QBMapper { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param IDBConnection $db |
|
| 35 | - */ |
|
| 36 | - public function __construct(IDBConnection $db) { |
|
| 37 | - parent::__construct($db, 'oauth2_access_tokens'); |
|
| 38 | - } |
|
| 33 | + /** |
|
| 34 | + * @param IDBConnection $db |
|
| 35 | + */ |
|
| 36 | + public function __construct(IDBConnection $db) { |
|
| 37 | + parent::__construct($db, 'oauth2_access_tokens'); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param string $code |
|
| 42 | - * @return AccessToken |
|
| 43 | - * @throws AccessTokenNotFoundException |
|
| 44 | - */ |
|
| 45 | - public function getByCode(string $code): AccessToken { |
|
| 46 | - $qb = $this->db->getQueryBuilder(); |
|
| 47 | - $qb |
|
| 48 | - ->select('*') |
|
| 49 | - ->from($this->tableName) |
|
| 50 | - ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code)))); |
|
| 40 | + /** |
|
| 41 | + * @param string $code |
|
| 42 | + * @return AccessToken |
|
| 43 | + * @throws AccessTokenNotFoundException |
|
| 44 | + */ |
|
| 45 | + public function getByCode(string $code): AccessToken { |
|
| 46 | + $qb = $this->db->getQueryBuilder(); |
|
| 47 | + $qb |
|
| 48 | + ->select('*') |
|
| 49 | + ->from($this->tableName) |
|
| 50 | + ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code)))); |
|
| 51 | 51 | |
| 52 | - try { |
|
| 53 | - $token = $this->findEntity($qb); |
|
| 54 | - } catch (IMapperException $e) { |
|
| 55 | - throw new AccessTokenNotFoundException('Could not find access token', 0, $e); |
|
| 56 | - } |
|
| 52 | + try { |
|
| 53 | + $token = $this->findEntity($qb); |
|
| 54 | + } catch (IMapperException $e) { |
|
| 55 | + throw new AccessTokenNotFoundException('Could not find access token', 0, $e); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - return $token; |
|
| 59 | - } |
|
| 58 | + return $token; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * delete all access token from a given client |
|
| 63 | - * |
|
| 64 | - * @param int $id |
|
| 65 | - */ |
|
| 66 | - public function deleteByClientId(int $id) { |
|
| 67 | - $qb = $this->db->getQueryBuilder(); |
|
| 68 | - $qb |
|
| 69 | - ->delete($this->tableName) |
|
| 70 | - ->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
| 71 | - $qb->execute(); |
|
| 72 | - } |
|
| 61 | + /** |
|
| 62 | + * delete all access token from a given client |
|
| 63 | + * |
|
| 64 | + * @param int $id |
|
| 65 | + */ |
|
| 66 | + public function deleteByClientId(int $id) { |
|
| 67 | + $qb = $this->db->getQueryBuilder(); |
|
| 68 | + $qb |
|
| 69 | + ->delete($this->tableName) |
|
| 70 | + ->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
| 71 | + $qb->execute(); |
|
| 72 | + } |
|
| 73 | 73 | } |