-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bui Sy Nguyen
committed
Apr 30, 2016
1 parent
ebcabe7
commit 03dc8a5
Showing
8 changed files
with
71 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
<?php | ||
/** | ||
* Zend Framework | ||
* | ||
* LICENSE | ||
* | ||
* This source file is subject to the new BSD license that is bundled | ||
* with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://framework.zend.com/license/new-bsd | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* @category Zend | ||
* @package Zend_Amf | ||
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @version $Id$ | ||
*/ | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// © Copyright f-project.net 2010-present. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
namespace fproject\amf; | ||
|
||
use fproject\amf\auth\AuthAbstract; | ||
use fproject\amf\loader\ResourceLoader; | ||
use fproject\amf\reflect\AbstractFunctionReflector; | ||
use fproject\amf\reflect\FunctionReflector; | ||
use fproject\amf\reflect\MethodReflector; | ||
use fproject\amf\AmfException; | ||
use fproject\amf\reflect\ClassReflector; | ||
use fproject\amf\reflect\ReflectorHelper; | ||
use fproject\amf\value\messaging\AcknowledgeMessage; | ||
|
@@ -34,24 +32,20 @@ | |
use fproject\amf\value\messaging\RemotingMessage; | ||
use fproject\amf\value\MessageHeader; | ||
use fproject\amf\value\MessageBody; | ||
use fproject\amf\Constants; | ||
use fproject\amf\parse\TypeLoader; | ||
use fproject\amf\Request; | ||
use fproject\amf\HttpRequest; | ||
use fproject\amf\Response; | ||
use fproject\amf\HttpResponse; | ||
use fproject\amf\acl\Acl; | ||
use fproject\amf\acl\Resource; | ||
use Exception; | ||
use fproject\amf\auth\Auth; | ||
use fproject\amf\auth\AuthResult; | ||
|
||
/** | ||
* An AMF gateway server implementation to allow the connection of the Adobe Flash Player to | ||
* Zend Framework | ||
* | ||
* @todo Make the reflection methods cache and autoload. | ||
* @package Zend_Amf | ||
* @subpackage Server | ||
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
class Zend_Amf_Server | ||
class Server | ||
{ | ||
/** | ||
* Array of dispatchables | ||
|
@@ -118,7 +112,7 @@ class Zend_Amf_Server | |
/** | ||
* ACL handler object | ||
* | ||
* @var \fproject\amf\acl\Acl | ||
* @var Acl | ||
*/ | ||
protected $_acl; | ||
/** | ||
|
@@ -136,7 +130,7 @@ public function __construct() | |
* the ACL of this instance with it (if none exists already). | ||
* | ||
* @param AuthAbstract $auth | ||
* @return Zend_Amf_Server | ||
* @return Server | ||
*/ | ||
public function setAuth(AuthAbstract $auth) | ||
{ | ||
|
@@ -159,18 +153,18 @@ public function getAuth() | |
/** | ||
* Set ACL adapter | ||
* | ||
* @param \fproject\amf\acl\Acl $acl | ||
* @return Zend_Amf_Server | ||
* @param Acl $acl | ||
* @return Server | ||
*/ | ||
public function setAcl(\fproject\amf\acl\Acl $acl) | ||
public function setAcl(Acl $acl) | ||
{ | ||
$this->_acl = $acl; | ||
return $this; | ||
} | ||
/** | ||
* Get ACL adapter | ||
* | ||
* @return \fproject\amf\acl\Acl | ||
* @return Acl | ||
*/ | ||
public function getAcl() | ||
{ | ||
|
@@ -181,7 +175,7 @@ public function getAcl() | |
* Set production flag | ||
* | ||
* @param bool $flag | ||
* @return Zend_Amf_Server | ||
* @return Server | ||
*/ | ||
public function setProduction($flag) | ||
{ | ||
|
@@ -201,7 +195,7 @@ public function isProduction() | |
|
||
/** | ||
* @param string $namespace | ||
* @return Zend_Amf_Server | ||
* @return Server | ||
* @internal param of $namespace all incoming sessions defaults to Zend_Amf | ||
*/ | ||
public function setSession($namespace = 'Zend_Amf') | ||
|
@@ -236,7 +230,7 @@ protected function _checkAcl($object, $function) | |
if($object) { | ||
$class = is_object($object)?get_class($object):$object; | ||
if(!$this->_acl->has($class)) { | ||
$this->_acl->addResource(new \fproject\amf\acl\Resource($class)); | ||
$this->_acl->addResource(new Resource($class)); | ||
} | ||
$call = array($object, "initAcl"); | ||
if(is_callable($call) && !call_user_func($call, $this->_acl)) { | ||
|
@@ -247,7 +241,7 @@ protected function _checkAcl($object, $function) | |
$class = null; | ||
} | ||
|
||
$auth = \fproject\amf\auth\Auth::getInstance(); | ||
$auth = Auth::getInstance(); | ||
if($auth->hasIdentity()) { | ||
$role = $auth->getIdentity()->role; | ||
} else { | ||
|
@@ -397,7 +391,7 @@ protected function _loadCommandMessage(CommandMessage $message) | |
break; | ||
case CommandMessage::LOGOUT_OPERATION : | ||
if($this->_auth) { | ||
\fproject\amf\auth\Auth::getInstance()->clearIdentity(); | ||
Auth::getInstance()->clearIdentity(); | ||
} | ||
$return = new AcknowledgeMessage($message); | ||
break; | ||
|
@@ -445,7 +439,7 @@ protected function _errorMessage($objectEncoding, $message, $description, $detai | |
* | ||
* @param string $userId | ||
* @param string $password | ||
* @return bool|\fproject\amf\auth\AuthResult | ||
* @return bool|AuthResult | ||
* @throws AmfException | ||
* | ||
*/ | ||
|
@@ -455,7 +449,7 @@ protected function _handleAuth( $userId, $password) | |
return true; | ||
} | ||
$this->_auth->setCredentials($userId, $password); | ||
$auth = \fproject\amf\auth\Auth::getInstance(); | ||
$auth = Auth::getInstance(); | ||
$result = $auth->authenticate($this->_auth); | ||
if ($result->isValid()) { | ||
if (!$this->isSession()) { | ||
|
@@ -503,7 +497,7 @@ protected function _handle(Request $request) | |
$headers[Constants::CREDENTIALS_HEADER]->userid, | ||
$headers[Constants::CREDENTIALS_HEADER]->password | ||
); | ||
if ($authResult === true || $authResult->getCode() == \fproject\amf\auth\AuthResult::SUCCESS) { | ||
if ($authResult === true || $authResult->getCode() == AuthResult::SUCCESS) { | ||
// use RequestPersistentHeader to clear credentials | ||
$response->addAmfHeader( | ||
new MessageHeader( | ||
|
@@ -661,7 +655,7 @@ public function handle($request = null) | |
* Set request object | ||
* | ||
* @param string|Request $request | ||
* @return Zend_Amf_Server | ||
* @return Server | ||
* @throws AmfException | ||
*/ | ||
public function setRequest($request) | ||
|
@@ -696,7 +690,7 @@ public function getRequest() | |
* Public access method to private Response reference | ||
* | ||
* @param string|Response $response | ||
* @return Zend_Amf_Server | ||
* @return Server | ||
* @throws AmfException | ||
*/ | ||
public function setResponse($response) | ||
|
@@ -738,7 +732,7 @@ public function getResponse() | |
* @param string|object $class | ||
* @param string $namespace Optional | ||
* @param mixed $argv Optional arguments to pass to a method | ||
* @return Zend_Amf_Server | ||
* @return Server | ||
* @throws AmfException on invalid input | ||
* @throws AmfException | ||
*/ | ||
|
@@ -777,7 +771,7 @@ public function setClass($class, $namespace = '', $argv = null) | |
* | ||
* @param string|array $function Valid callback | ||
* @param string $namespace Optional namespace prefix | ||
* @return Zend_Amf_Server | ||
* @return Server | ||
* @throws AmfException | ||
*/ | ||
public function addFunction($function, $namespace = '') | ||
|
@@ -867,14 +861,13 @@ protected function _buildDispatchTable() | |
} | ||
|
||
|
||
|
||
/** | ||
* Raise a server fault | ||
* | ||
* Unimplemented | ||
* | ||
* @param string|Exception $fault | ||
* @return void | ||
* @param int $code | ||
*/ | ||
public function fault($fault = null, $code = 404) | ||
{ | ||
|
@@ -922,7 +915,7 @@ public function loadFunctions($definition) | |
* | ||
* @param string $asClass | ||
* @param string $phpClass | ||
* @return Zend_Amf_Server | ||
* @return Server | ||
*/ | ||
public function setClassMap($asClass, $phpClass) | ||
{ | ||
|
@@ -948,7 +941,7 @@ public function listMethods() | |
* Takes the provided parameters from the request, and attempts to cast them | ||
* to objects, if the prototype defines any as explicit object types | ||
* | ||
* @param Reflection $reflectionMethod | ||
* @param MethodReflector $reflectionMethod | ||
* @param array $params | ||
* @return array | ||
* @updated 2014/05/24: Bui Sy Nguyen <[email protected]> modified to support typed array parameter | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.