public function processDestination(ORBConfig $orbConfig, $destinationId, $xmlElement) { /*Element*/ $props = $xmlElement->getElementsByTagName("properties")->item(0); /*String*/ $source = $props->getElementsByTagName("source")->item(0)->textContent; /*String*/ $scope = null; if ($props->getElementsByTagName("scope")->length > 0) { $scope = $props->getElementsByTagName("scope")->item(0)->textContent; } //props.getAttributeValue( "scope" ); /*Hashtable*/ $context = null; if ($scope != null && strlen(trim($scope)) > 0) { $context = array(); $context[ORBConstants::ACTIVATION] = $scope; } if (LOGGING) { Log::log(LoggingConstants::INFO, "Registered Flex Remoting destination - " . $destinationId); } $orbConfig->getServiceRegistry()->_addMapping($destinationId, $source, $context); /*List*/ $securityNodes = $xmlElement->getElementsByTagName("security"); if ($securityNodes != null && $securityNodes->length > 0) { /*Element*/ $securityElement = $securityNodes->item(0); /*Element*/ $securityConstraintNode = $securityElement->getElementsByTagName("security-constraint")->item(0); /*Element*/ $rolesNode = $securityConstraintNode->getElementsByTagName("roles")->item(0); /*List*/ $rolesNodeList = $rolesNode->getElementsByTagName("role"); /*AccessConstraint*/ $constraint = new AccessConstraint($source . "_constraint", "grant"); for ($i = 0, $max = $rolesNodeList->length; $i < $max; $i++) { $constraint->addRole($rolesNodeList->item(0)->textContent); } $security = $orbConfig->getSecurity(); $constraintsList =& $security->getConstraintsList(); $constraintsList[$constraint->getName()] = $constraint; $constraints = array($constraint->getName()); $security->secureResource($source, $constraints, null); } array_push(self::$services, $destinationId); $remotingDestination = new RemotingDestination($destinationId, $source); return new RemotingDestination($destinationId, $source); }
public function execute(Request $message) { /*String*/ $dsId = $this->headers["DSId"]; /*String*/ $woId = $this->headers["WebORBClientId"]; /*IDestination*/ $destObj = ORBConfig::getInstance()->getDataServices()->getDestinationManager()->getDestination($this->destination); if ($destObj == null) { /*String*/ $error = "Unknown destination - " . $destination . ". Make sure the destination is properly configured."; if (LOGGING) { Log::log(LoggingConstants::ERROR, $error); } return new ErrMessage($this->messageId, new Exception($error)); } /*Object[]*/ $bodyParts = $this->body->body; if ($bodyParts != null && count($bodyParts) > 0) { for ($i = 0, $len = count($bodyParts); $i < $len; $i++) { $this->body->body[$i] = $bodyParts[$i]->defaultAdapt(); } $destObj->messagePublished($woId, $bodyParts[0]); $destObj->getServiceHandler()->addMessage($this->headers, $this); } return new AckMessage($this->messageId, $this->clientId, null, array()); }
public function dispatch(Request &$request) { $config = ORBConfig::getInstance(); for ($i = 0, $max = $request->getBodyCount(); $i < $max; $i++) { $request->setCurrentBody($i); $requestURI = $request->getRequestURI(); if (LOGGING) { Log::log(LoggingConstants::INFO, "requestURI = {$requestURI}"); } $serviceId = substr($requestURI, 0, strrpos($requestURI, ".")); $methodName = substr($requestURI, strlen($serviceId) + 1); $arg = $request->getRequestBodyData(); if (!is_array($arg)) { $arg = array($request->getRequestBodyData()); } try { $value = self::handleInvoke($request, $serviceId, $methodName, $arg); $namedObject = $arg[0]; $correlationId = $namedObject->defaultAdapt()->messageId; $ackMessage = new AckMessage($correlationId, null, $value); $request->setResponseBodyPart($ackMessage); $request->setResponseURI("/onResult"); } catch (Exception $e) { $request->setResponseBodyPart($e); $request->setResponseURI("/onStatus"); } } return true; }
public static function getInstance() { if (is_null(self::$s_instance)) { self::$s_instance = new ORBConfig(); self::$s_instance->initialize(); } return self::$s_instance; }
public static function getInstance() { if (self::$singleton == null) { self::$singleton = new ChannelRegistry(); self::$singleton->configure(ORBConfig::getInstance()->getFlexConfigPath()); } return self::$singleton; }
/** * If weborb setting "outputFolder" is empty returns "" * * @return output folder for generated PDF files */ public static function getOutputFolder() { /*String*/ $result = ORBConfig::getInstance()->getConfig("outputFolder"); if ($result != null && $result != "") { return $result; } return ""; }
public function getServiceRoles() { /*String[]*/ $roles = ORBConfig::getInstance()->getSecurity()->getRolesProvider()->getRoles(); /*ArrayList*/ $returnArray = array(); for ($i = 0; $i < count($roles); $i++) { $returnArray[] = $roles[$i]; } return $returnArray; }
public function processRequest() { if ($_SERVER["REQUEST_METHOD"] == "GET") { print "WebORB v3.5.0"; } $timeStart = microtime(true); ob_start(); $inputData = file_get_contents("php://input"); if (isset($_FILES['Filedata'])) { $config = ORBConfig::getInstance(); if (!defined("WebOrbServicesPath")) { define("WebOrbServicesPath", realpath(WebOrb . $config->getServicePath()) . DIRECTORY_SEPARATOR); if (LOGGING) { Log::log(LoggingConstants::DEBUG, "WebORB services path is - " . WebOrbServicesPath); } } require_once WebOrbServicesPath . "Weborb/Examples/Upload.php"; upload(); exit; } $startRead = microtime(true); try { $config = ORBConfig::getInstance(); if (!defined("WebOrbServicesPath")) { define("WebOrbServicesPath", realpath(WebOrb . $config->getServicePath()) . DIRECTORY_SEPARATOR); if (LOGGING) { Log::log(LoggingConstants::DEBUG, "WebORB services path is - " . WebOrbServicesPath); } } $contentType = "text/html"; if (stripos($_SERVER["CONTENT_TYPE"], "wolf/xml") !== false) { $contentType = "wolf/xml"; } elseif (stripos($_SERVER["CONTENT_TYPE"], "application/x-amf") !== false) { $contentType = "application/x-amf"; } $request = $config->getProtocolRegistry()->buildMessage($contentType, $inputData); } catch (Exception $e) { if (LOGGING) { Log::logException(LoggingConstants::ERROR, "Internal error", $e); } ob_clean(); return; } if (DrupalDispatcher::dispatch($request)) { $this->serializeResponse($request); } $logMessage = sprintf("Final Execute time: %0.3f", microtime(true) - $timeStart); if (LOGGING) { Log::log(LoggingConstants::PERFORMANCE, $logMessage); } }
public function configure($parent, $configContext, DOMNode $documentElement) { $this->setORBConfig($configContext); $section = $documentElement->getElementsByTagName("services")->item(0); // check required ! $this->m_configNode = $section; foreach ($section->childNodes as $element) { if (!$element instanceof DOMElement) { continue; } $nameElements = $element->getElementsByTagName("name"); $serviceName = trim($nameElements->item(0)->nodeValue); $idElements = $element->getElementsByTagName("serviceId"); $serviceId = trim($idElements->item(0)->nodeValue); ORBConfig::getInstance()->getServiceRegistry()->_addMapping($serviceName, $serviceId, array()); } }
public static function handleInvoke(Request $request, $targetObject, $function, &$arg) { $config = ORBConfig::getInstance(); $handlers = $config->getHandlers(); $resolvedName = ServiceRegistry::getMapping($targetObject); if (!$config->getSecurity()->canAccess($resolvedName)) { throw new ServiceException("WebORB security has rejected access to class " . $targetObject . ". see server log or contact system administrator", 401); } if (!$config->getSecurity()->canAccess($resolvedName . "#" . $function)) { throw new ServiceException("WebORB security has rejected access to method " . $targetObject . "." . $function . ". see server log or contact system administrator", 401); } $timeStart = microtime(true); $value = $handlers->invoke($resolvedName, $function, $arg); $logMessage = sprintf("Service \"{$resolvedName}::{$function}\" execute time: %0.3f", microtime(true) - $timeStart); if (LOGGING) { Log::log(LoggingConstants::PERFORMANCE, $logMessage); } return $value->getObject(); }
public function configure($parent, $configContext, DOMNode $documentElement) { $this->setORBConfig($configContext); $section = $documentElement->getElementsByTagName("classMappings")->item(0); // check required ! $this->m_configNode = $section; foreach ($section->childNodes as $element) { if (!$element instanceof DOMElement) { continue; } $elements = $element->getElementsByTagName("clientClass"); $clientClass = trim($elements->item(0)->nodeValue); $elements = $element->getElementsByTagName("serverClass"); $serverClass = trim($elements->item(0)->nodeValue); $type = TypeLoader::loadType($serverClass); if (LOGGING) { Log::log(LoggingConstants::DEBUG, $clientClass . " : " . $serverClass); } ORBConfig::getInstance()->getTypeMapper()->_addClientClassMapping($clientClass, $type); } }
public function pass() { $credentials = ThreadContext::currentCallerCredentials(); if ($credentials != null) { /*String[]*/ $userRoles = ORBConfig::getInstance()->getSecurity()->getRolesProvider()->getUserRoles($credentials->getUserId()); // print_r($userRoles); // Log::log(LoggingConstants::MYDEBUG, ob_get_contents()); for ($i = 0, $max = count($userRoles); $i < $max; $i++) { if ($userRoles[$i] == $this->m_roleName) { return true; } } } // Log::log(LoggingConstants::MYDEBUG, "No roles"); return false; // $credentials = ThreadContext::currentCallerCredentials(); // // Log::log( LoggingConstants::DEBUG, "got credentials - " . ($credentials == null)); // // if($credentials == null) // { // Log::log( LoggingConstants::DEBUG, "credentials are null "); // // return false, authorization is required // return false; // } // // $userName = $credentials->getUserId(); // $password = $credentials->getPassword(); // // $orbConfig = ORBConfig::getInstance(); // $security = $orbConfig->getSecurity(); // // Log::log( LoggingConstants::DEBUG, "username " . $userName . " password " . $password ." role " . $this->m_roleName); // // // return $security->isInRole($userName, $password, $this->m_roleName); }
/** * @param message * @return * @throws ServiceException */ public function dispatch(Request &$request) { $message = $request; if (!$this->isInspectionRequest($message)) { return false; } if (LOGGING) { Log::log(LoggingConstants::INFO, "Request is recognized as an inspection request. Handling service inspection"); } /*String*/ $requestURI = $message->getRequestURI(); /*String*/ $targetObject = substr($requestURI, 0, strrpos($requestURI, '.')); $targetObject = ServiceRegistry::getMapping($targetObject); if (LOGGING) { Log::log(LoggingConstants::DEBUG, "Request URI - " . $requestURI); Log::log(LoggingConstants::DEBUG, "Target Service - " . $targetObject); } $responseObject = ORBConfig::getInstance()->getHandlers()->inspect($targetObject); if ($responseObject == null || $responseObject->getObject() instanceof Exception) { if (LOGGING) { Log::log(LoggingConstants::ERROR, "None of the handlers were able to inspect the target service. The service may not be found"); } /*Exception*/ $exception = $responseObject != null ? $responseObject->getObject() : new InspectionException($targetObject); $message->setResponseBodyPart($exception); $message->setResponseURI("/onStatus"); } else { if (LOGGING) { Log::log(LoggingConstants::DEBUG, "Inspection response object is " . $responseObject->getName()); } $responseObject->setAddress($targetObject); $message->setResponseBodyPart($responseObject->getObject()); $message->setResponseURI("/onResult"); } return true; }
public function UnsecureResource($resource) { $orbconfig = ORBConfig::getInstance(); $configHandler = $orbconfig->getConfig("weborb/security"); $doc = $configHandler->m_securityNode->ownerDocument; $secureResources = $doc->getElementsByTagName("secure-resource"); $secureResourcesElement = $doc->getElementsByTagName("secure-resources")->item(0); foreach ($secureResources as $secureResource) { $resourceName = trim($secureResource->getElementsByTagName("resource")->item(0)->nodeValue); if ($resourceName == $resource) { $secureResourcesElement->removeChild($secureResource); } } $configHandler->saveConfig(); }
public static function getClientClassForServerType($serverClassName) { return ORBConfig::getInstance()->getTypeMapper()->_getClientClassForServerType($serverClassName); }
public static function getFullClassName(ReflectionClass $class) { $config = ORBConfig::getInstance(); $servicePath = realpath(WebOrb . $config->getServicePath()); $fileName = $class->getFileName(); $excludingServicePath = substr($fileName, strlen($servicePath) + 1); //$excludingServicePath = substr($excludingServicePath,strlen($servicePath)+1); $excludingServicePath = substr($excludingServicePath, 0, strlen($excludingServicePath) - 4); // removing .php $excludingServicePath = str_replace(DIRECTORY_SEPARATOR, '.', $excludingServicePath); return $excludingServicePath; }
public static function getORBConfig() { return ORBConfig::getInstance(); }
public function cancelSelection() { ORBConfig::getInstance()->getBusinessIntelligenceConfig()->validate(); return $this->getServices(); }
public function Configure($basePath, ORBConfig $orbConfig) { $this->orbConfig = $orbConfig; $this->basePath = $basePath; $this->preConfig(); /*Document*/ $configDoc = null; $dom = new DomDocument(); $dom->load($orbConfig->getFlexConfigPath() . $this->getConfigFileName()); $root = $dom->documentElement; /*String*/ $serviceHandlerClassName = $root->getAttribute("class"); //if( $serviceHandlerClassName == null || strlen($serviceHandlerClassName) == 0 ) $serviceHandlerClassName = $this->getDefaultServiceHandlerName(); /*IServiceHandler*/ $serviceHandler = null; if ($serviceHandlerClassName != null) { try { $serviceHandler = ObjectFactories::createServiceObject($serviceHandlerClassName); } catch (Exception $e) { $serviceHandler = null; } } /*DataServices*/ $dataServices = $orbConfig->getDataServices(); /*List*/ $adapters = $root->getElementsByTagName("adapters"); if ($adapters != null && $adapters->length > 0) { /*Element*/ $adaptersNode = $adapters->item(0); /*List*/ $adaptersDefNodes = $adaptersNode->getElementsByTagName("adapter-definition"); for ($i = 0, $max = count($adaptersDefNodes); $i < $max; $i++) { /*Element*/ $adapterDefinition = $adaptersDefNodes->item($i); /*String*/ $id = $adapterDefinition->getAttribute("id"); /*String*/ $type = $adapterDefinition->getAttribute("class"); if ($type == null) { $type = $adapterDefinition->getAttribute("type"); } if ($type == null || strlen(trim($type)) == 0) { continue; } /*String*/ $defaultAdapterStr = $adapterDefinition->getAttribute("default"); /*boolean*/ $defaultAdapter = $defaultAdapterStr != null && strtolower($defaultAdapterStr) == "true"; try { /*IAdapter*/ $adapter = ObjectFactories::createServiceObject($type); $dataServices->_AddAdapter($id, $adapter, $defaultAdapter); } catch (Exception $e) { if (LOGGING) { Log::log(LoggingConstants::ERROR, "unable to load service adapter " . $type); } } } } /*List*/ $destinationNodes = $root->getElementsByTagName("destination"); for ($i = 0, $max = $destinationNodes->length; $i < $max; $i++) { /*Element*/ $destElement = $destinationNodes->item($i); /*String*/ $destinationId = $destElement->getAttribute("id"); /*IDestination*/ $destination = $this->processDestination($orbConfig, $destinationId, $destElement); $destination->setName($destinationId); /*Element*/ $props = $destElement->getElementsByTagName("properties")->item(0); $destination->setProperties($this->parseProperties($props)); $destination->setConfigServiceHandler(); if ($destination->getServiceHandler() == null) { $destination->setServiceHandler($serviceHandler); } $dataServices->getDestinationManager()->addDestination($destinationId, $destination); } $this->postConfig(); }
public function getRoles() { return ORBConfig::getInstance()->getSecurity()->getRolesProvider()->getRoles(); }
public static function getContext($type) { return ORBConfig::getInstance()->getServiceRegistry()->_getContext($type); }
public function delete(ServiceDestination $serviceDestination) { /*Element*/ $serviceDestinationNode = $this->findService($serviceDestination); FlexRemotingServiceConfig::getConfigDoc()->documentElement->removeChild($serviceDestinationNode); FlexRemotingServiceConfig::saveConfig(); ORBConfig::getInstance()->getDataServices()->getDestinationManager()->removeDestination($serviceDestination->DestinationId); ORBConfig::getInstance()->getServiceRegistry()->removeMapping($serviceDestination->DestinationId); }
private function loadMethods($service) { $class = null; try { $class = new ReflectionClass($service->Name); } catch (Exception $e) { $service->IsError = true; $service->ErrorText = substr($e->__toString(), 0, min(300, strlen($e->__toString()))); return true; } if ($class->isInterface()) { return false; } $methods = $class->getMethods(); /*bool*/ $hasPublicMethod = false; if (count($methods) > 0) { foreach ($methods as $method) { $serviceMethod = new ServiceMethod($method->getName(), $service); $serviceMethod->ReturnDataType = $this->MappingTypes["Object"]; $serviceMethod->Selected = ORBConfig::getInstance()->getBusinessIntelligenceConfig()->getMonitoredClassRegistry()->isSelected($serviceMethod->getFullName()); $service->AddChildNode($serviceMethod); $params = $method->getParameters(); if ($this->securityConfigurator->IsSecure($serviceMethod)) { $serviceMethod->IsSecure = true; $this->securityConfigurator->LoadConstraints($serviceMethod); } if (count($params) > 0) { foreach ($params as $param) { $serviceMethodArg = new ServiceMethodArg($param->getName(), $serviceMethod); if (is_null($param->getClass())) { $serviceMethodArg->DataType = $this->MappingTypes["String"]; } else { $serviceMethodArg->DataType = $this->getType($param->getClass()); } $serviceMethod->AddChildNode($serviceMethodArg); } } if ($method->isPublic()) { $hasPublicMethod = true; } } } return $hasPublicMethod; }
public function execute(Request $request) { if (LOGGING) { Log::log(LoggingConstants::DEBUG, "commandmessage " . $this->operation . " operation"); } /*Object*/ $returnValue = null; if ($this->operation == "0") { /*IDestination*/ $destObj = ORBConfig::getInstance()->getDataServices()->getDestinationManager()->getDestination($this->destination); /*Hashtable*/ $headers = array(); if ($destObj != null) { /*String*/ $selectorName = $this->headers["DSSelector"]; /*String*/ $subtopic = $this->headers["DSSubtopic"]; /*String*/ $dsId = $this->headers["DSId"]; /*Subscriber*/ $subscriber = new Subscriber($selectorName, $destObj); $subscriber->setDSId($dsId); $subscriber->setSubtopic($subtopic); $guid = new GUID(); $subscriber->setClientId($guid->toString()); SubscriptionsManager::getInstance()->addSubscriber($dsId, $subscriber); $destObj->getServiceHandler()->handleSubscribe($subscriber); } else { /*String*/ $error = "Unknown destination " . $this->destination . ". Cannot handle subscription request"; if (LOGGING) { Log::log(LoggingConstants::ERROR, $error); } return new ErrMessage($this->messageId, new Exception($error)); } return new AckMessage($this->messageId, $clientId, null, $headers); } else { if ($this->operation == "1") { /*String*/ $dsId = $this->headers["DSId"]; /*Subscriber*/ $subscriber = SubscriptionsManager::getInstance()->getSubscriber($dsId); if ($subscriber == null) { return new ErrMessage($this->messageId, new Exception("Unable to unsubscribe - unknown client")); } /*IDestination*/ $destination = $subscriber->getDestination(); $destination->getServiceHandler()->handleUnsubscribe($subscriber); SubscriptionsManager::getInstance()->removeSubscriber($dsId); } else { if ($this->operation == "2") { /*String*/ $dsId = $this->headers["DSId"]; /*Subscriber*/ $subscriber = SubscriptionsManager::getInstance()->getSubscriber($dsId); if ($subscriber == null) { /*String*/ $error = "Invalid client id " . $dsId; if (LOGGING) { Log::log(LoggingConstants::ERROR, $error); } return new ErrMessage($this->messageId, new Exception($error)); } /*IDestination*/ $destination = $subscriber->getDestination(); //Log::log( LoggingConstants::INFO, "Getting messages from " . $destination->getServiceHandler() ); /*ArrayList*/ $messages = $destination->getServiceHandler()->getMessages($subscriber); $subscriber->setLastRequestTime(microtime(true)); if (count($messages) == 0) { return new AckMessage(null, null, null, array()); } return $this->createCmdMessage("4", $messages); } else { if ($this->operation == "5") { /*Hashtable*/ $headers = array(); $guid = new GUID(); $headers["DSId"] = $guid->toString(); return new AckMessage($this->messageId, $this->clientId, null, $headers); } else { if ($this->operation == "9") { ThreadContext::setCallerCredentials(null); } else { if ($this->operation == "8") { $arr = $this->body->getBody(); $adaptingType = $arr[0]; $authData = split(":", base64_decode($adaptingType->defaultAdapt())); $credentials = new Credentials($authData[0], $authData[1]); $authHandler = ORBSecurity::getAuthenticationHandler(ThreadContext::getORBConfig()); if (LOGGING) { Log::log(LoggingConstants::DEBUG, "got auth handler " . get_class($authHandler)); } if ($authHandler == null) { $errorMessage = new ErrMessage($this->messageId, new ServiceException("Missing authentication handler")); $errorMessage->faultCode = "Client.Authentication"; return $errorMessage; } try { $authHandler->checkCredentials($credentials->getUserId(), $credentials->getPassword(), $request); if (LOGGING) { Log::log(LoggingConstants::DEBUG, "credentials are valid "); } ThreadContext::setCallerCredentials($credentials); } catch (Exception $e) { if (LOGGING) { Log::log(LoggingConstants::EXCEPTION, "authentication exception" . $e); } $errorMessage = new ErrMessage($this->messageId, $e); $errorMessage->faultCode = "Client.Authentication"; return $errorMessage; } return new AckMessage($this->messageId, $this->clientId, null); } } } } } } //echo $this->operation; exit; return new AckMessage($this->messageId, $this->clientId, $returnValue, array()); }
<?php if (!defined("WebOrb")) { define("WebOrb", dirname(__FILE__) . DIRECTORY_SEPARATOR); } if (!defined("WebOrbCache")) { define("WebOrbCache", dirname(__FILE__) . DIRECTORY_SEPARATOR . "PollCache" . DIRECTORY_SEPARATOR); } require_once WebOrb . "DCA/WebORBDataCollectionAgent.php"; require_once WebOrb . 'Registry/MonitoredClass.php'; require_once WebOrb . 'Util/Logging/Log.php'; require_once WebOrb . "Util/Logging/LoggingConstants.php"; require_once WebOrb . 'Config/ORBConfig.php'; ob_start(); $config = ORBConfig::getInstance(); if (isset($_POST['action']) && $_POST['action'] == 'sendDCA') { WebORBDataCollectionAgent::startup('http://localhost/weborb/PHP/weborb.php'); $weborbDCA = WebORBDataCollectionAgent::getInstance(); $weborbDCA->sendDCAInformationToRBI(); Log::log(LoggingConstants::MYDEBUG, ob_get_contents()); exit; } $monitoredClass = unserialize($_POST['object']); WebORBDataCollectionAgent::startup('http://localhost/weborb/PHP/weborb.php'); $weborbDCA = WebORBDataCollectionAgent::getInstance(); // $weborbDCA->sendDCAInformationToRBI(); $weborbDCA->getMonitoredRIsFromRBIServer(); for ($i = 0; $i < MonitoredClass::MAX_CACHE; $i++) { if ($monitoredClass->setCurrentMethodNumber($i)) { $weborbDCA->update($monitoredClass); }
public function getUserRoles($userName) { return ORBConfig::getInstance()->getSecurity()->getUserRoles($userName); }
public static function getDefaultAdapter() { return ORBConfig::getInstance()->getDataServices()->_GetDefaultAdapter(); }