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);
 }
Example #2
0
 public function addRestriction($constraintName, $action, IRestriction $restriction)
 {
     $accessConstraint = null;
     if (array_key_exists($constraintName, $this->m_accessConstraints)) {
         $accessConstraint = $this->m_accessConstraints[$constraintName];
     } else {
         $accessConstraint = new AccessConstraint($constraintName, $action);
     }
     $accessConstraint->addRestriction($restriction);
     $orbconfig = ORBConfig::getInstance();
     $configHandler = $orbconfig->getConfig("weborb/security");
     $configHandler->addRestriction($constraintName, $action, $restriction);
     //return;
     $configHandler->saveConfig();
 }
 private function processRoles($ipNodes, AccessConstraint $accessConstraint)
 {
     foreach ($ipNodes as $node) {
         if (!$node instanceof DOMElement) {
             continue;
         }
         $roleName = trim($node->nodeValue);
         if (!$this->getORBConfig()->getSecurity()->checkRole($roleName)) {
             if (LOGGING) {
                 Log::log(LoggingConstants::INFO, "Unknown role name in access constant " . $accessConstraint->getName() . ". Role name is " . $roleName . ". Make sure the role name is listed in acl.xml");
             }
         }
         $accessConstraint->addRole($roleName);
     }
 }