oauth2-server/tests/Stubs/ClientEntity.php

93 lines
1.5 KiB
PHP
Raw Normal View History

2015-04-05 18:33:25 +05:30
<?php
2016-02-20 04:39:39 +05:30
2016-03-15 05:40:47 +05:30
namespace LeagueTests\Stubs;
2015-04-05 18:33:25 +05:30
2016-04-09 19:55:45 +05:30
use League\OAuth2\Server\Entities\ClientEntityInterface;
2016-03-15 05:40:47 +05:30
use League\OAuth2\Server\Entities\Traits\EntityTrait;
class ClientEntity implements ClientEntityInterface
2015-04-05 18:33:25 +05:30
{
2016-03-15 05:40:47 +05:30
use EntityTrait;
2015-04-05 18:33:25 +05:30
/**
* @var string
*/
protected $name;
/**
* @var string
*/
protected $secret;
/**
* @var string
*/
protected $redirectUri;
/**
2016-02-20 04:39:39 +05:30
* {@inheritdoc}
2015-04-05 18:33:25 +05:30
*/
public function getName()
{
return $this->name;
}
/**
2016-02-20 04:39:39 +05:30
* {@inheritdoc}
2015-04-05 18:33:25 +05:30
*/
public function setName($name)
{
$this->name = $name;
}
/**
2016-02-20 04:39:39 +05:30
* {@inheritdoc}
*/
public function canKeepASecret()
{
2016-02-18 17:37:36 +05:30
return $this->secret !== null;
}
/**
2016-02-20 04:39:39 +05:30
* {@inheritdoc}
*/
public function setSecret($secret)
{
2016-03-16 02:59:45 +05:30
$this->secret = password_hash($secret, PASSWORD_DEFAULT);
}
/**
2016-02-20 04:39:39 +05:30
* {@inheritdoc}
*/
public function validateSecret($submittedSecret)
{
return strcmp((string) $submittedSecret, $this->secret) === 0;
}
/**
2016-02-20 04:39:39 +05:30
* {@inheritdoc}
*/
public function setRedirectUri($redirectUri)
{
$this->redirectUri = $redirectUri;
}
/**
2016-02-20 04:39:39 +05:30
* {@inheritdoc}
*/
public function getRedirectUri()
{
return $this->redirectUri;
}
2016-03-16 02:59:45 +05:30
/**
* Get the hashed client secret
*
* @return string
*/
public function getSecret()
{
return $this->secret;
}
}