Example #1
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 private function getTestServer()
 {
     $storage = OAuth2_Storage_Bootstrap::getInstance()->getMemoryStorage();
     $server = new OAuth2_Server($storage);
     $server->addGrantType(new OAuth2_GrantType_UserCredentials($storage));
     return $server;
 }
 private function getTestServer()
 {
     $storage = OAuth2_Storage_Bootstrap::getInstance()->getMemoryStorage();
     $server = new OAuth2_Server($storage);
     $server->addGrantType(new OAuth2_GrantType_AuthorizationCode($storage));
     // or some other grant type.  This is the simplest
     return $server;
 }
Example #4
0
 private function getTestServer($config = array())
 {
     $storage = OAuth2_Storage_Bootstrap::getInstance()->getMemoryStorage();
     $server = new OAuth2_Server($storage, $config);
     // Add the two types supported for authorization grant
     $server->addGrantType(new OAuth2_GrantType_AuthorizationCode($storage));
     return $server;
 }
 public function testCustomClientAssertionType()
 {
     $request = OAuth2_Request_TestRequest::createPost(array('grant_type' => 'authorization_code', 'client_id' => 'Test Client ID', 'code' => 'testcode'));
     // verify the mock clientAssertionType was called as expected
     $clientAssertionType = $this->getMock('OAuth2_ClientAssertionTypeInterface', array('validateRequest', 'getClientId'));
     $clientAssertionType->expects($this->once())->method('validateRequest')->will($this->returnValue(true));
     $clientAssertionType->expects($this->once())->method('getClientId')->will($this->returnValue('Test Client ID'));
     // create mock storage
     $storage = OAuth2_Storage_Bootstrap::getInstance()->getMemoryStorage();
     $server = new OAuth2_Server(array($storage), array(), array(), array(), null, null, $clientAssertionType);
     $server->handleTokenRequest($request, $response = new OAuth2_Response());
 }
 public function provideStorage()
 {
     $memory = OAuth2_Storage_Bootstrap::getInstance()->getMemoryStorage();
     $mysql = OAuth2_Storage_Bootstrap::getInstance()->getMysqlPdo();
     $sqlite = OAuth2_Storage_Bootstrap::getInstance()->getSqlitePdo();
     $mongo = OAuth2_Storage_Bootstrap::getInstance()->getMongo();
     $redis = OAuth2_Storage_Bootstrap::getInstance()->getRedisStorage();
     // will add multiple storage types later
     return array(array($sqlite), array($mysql), array($mongo), array($redis));
 }
Example #7
0
 public function provideStorage()
 {
     $mysql = OAuth2_Storage_Bootstrap::getInstance()->getMysqlPdo();
     $sqlite = OAuth2_Storage_Bootstrap::getInstance()->getSqlitePdo();
     // will add multiple storage types later
     return array(array($sqlite), array($mysql));
 }
 private function getTestServer($audience = 'http://myapp.com/oauth/auth')
 {
     $storage = OAuth2_Storage_Bootstrap::getInstance()->getMemoryStorage();
     $server = new OAuth2_Server($storage);
     $server->addGrantType(new OAuth2_GrantType_JWTBearer($storage, $audience));
     return $server;
 }
 private function getTestServer()
 {
     $this->storage = OAuth2_Storage_Bootstrap::getInstance()->getMemoryStorage();
     $server = new OAuth2_Server($this->storage);
     return $server;
 }