Esempio n. 1
0
 public function getAuthenticationHandler(ORBConfig $config)
 {
     $securityConfigHandler = $config->getConfig("weborb/security");
     if ($securityConfigHandler != null) {
         $authenticationHandlerClassName = $securityConfigHandler->getAuthenticationHandler();
         if ($authenticationHandlerClassName != null && strlen($authenticationHandlerClassName) > 0) {
             return ObjectFactories::createServiceObject($authenticationHandlerClassName);
         }
     }
     return null;
 }
 public function setStoragePolicy($storagePolicyClass)
 {
     if ($storagePolicyClass == null) {
         return;
     }
     try {
         /*IMessageStoragePolicy*/
         $storagePolicy = ObjectFactories::createServiceObject($storagePolicyClass);
         $this->storagePolicy = $storagePolicy;
     } catch (Exception $exception) {
         if (LOGGING) {
             Log::log(LoggingConstants::EXCEPTION, "unable to create message storage policy object - " . $storagePolicyClass . " " . $exception);
         }
         $this->setDefaultStoragePolicy();
     }
 }
 public function setConfigServiceHandler()
 {
     if (!array_key_exists(ORBConstants::MESSAGE_SERVICE_HANDLER, $this->getProperties())) {
         return true;
     }
     $properties = $this->getProperties();
     /*String*/
     $handlerClassName = $properties[ORBConstants::MESSAGE_SERVICE_HANDLER];
     try {
         /*IServiceHandler*/
         $serviceHandler = ObjectFactories::createServiceObject($handlerClassName);
         $serviceHandler->initialize($this);
         $this->setServiceHandler($serviceHandler);
     } catch (Exception $exception) {
         /*String*/
         $error = "Unable to set " . $handlerClassName . " as a message service handler due to an error";
         if (LOGGING) {
             Log::log(LoggingConstants::ERROR, $error);
             Log::log(LoggingConstants::EXCEPTION, $error, $exception);
         }
         return false;
     }
     return true;
 }
 private function processResources($resources)
 {
     foreach ($resources->childNodes as $node) {
         if (!$node instanceof DOMElement) {
             continue;
         }
         $resourceId = $this->getElementText($node, "resource");
         $constraints = $node->getElementsByTagName("constraint-name");
         $constraintNames = array();
         for ($i = 0, $max = $constraints->length; $i < $max; $i++) {
             $constraintNames[$i] = trim($constraints->item($i)->nodeValue);
         }
         $resourceAuthHandlers = $node->getElementsByTagName("resourceAuthorizationHandler");
         $resourceAuthHandler = null;
         if ($resourceAuthHandlers->length > 0) {
             $authHandlerClassName = $resourceAuthHandlers[0]->nodeValue;
             $resourceAuthHandler = ObjectFactories::createServiceObject($authHandlerClassName);
         }
         $this->getORBConfig()->getSecurity()->secureResource($resourceId, $constraintNames, $resourceAuthHandler);
     }
 }
 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();
 }
Esempio n. 6
0
 private function createSelector()
 {
     /*IMessageSelector*/
     $selector = null;
     if ($this->selectorName != null && strlen(trim($this->selectorName)) > 0) {
         $this->selectorName = ServiceRegistry::getMapping($this->selectorName);
         try {
             $selector = ObjectFactories::createServiceObject($this->selectorName);
             if ($selector != null) {
                 $selector->setClientId($this->clientId);
             }
         } catch (Exception $exception) {
             if (LOGGING) {
                 Log::log(LoggingConstants::ERROR, "unable to create message selector object");
                 Log::log(LoggingConstants::ERROR, "will treat the selector as a query - " . $this->selectorName);
             }
         }
     }
 }
 public function adapt($type)
 {
     return ObjectFactories::createServiceObject($type);
 }