/**
  * Creates a single sign on token for the <code>HttpRequest</code>
  *
  * @param request <code>HttpServletRequest</code>
  * @return single sign on token for the request
  * @exception SSOException if the single sign on token cannot be created.
  */
 public function createSSOTokenFromRequest(array $request)
 {
     try {
         $sid = new SessionID($request);
         $session = Session::getSession($sid);
         if ($sid != null) {
             $cookieMode = $sid->getCookieMode();
             //                if (debug.messageEnabled()) {
             //                    debug.message("cookieMode is :" + cookieMode);
             //                }
             if ($cookieMode != null) {
                 $session->setCookieMode($cookieMode);
             }
         }
         if ($this->checkIP && !isIPValid($session, $_SERVER['REMOTE_ADDR'])) {
             throw new Exception("Invalid IP address");
         }
         $ssoToken = new SSOTokenImpl($session);
         return $ssoToken;
     } catch (Exception $e) {
         //            if (debug.messageEnabled()) {
         //                debug.message("could not create SSOToken from HttpRequest", e);
         //            }
         throw new SSOException($e->getMessage());
     }
 }
     //only update comments for this device connected via DHCP
     $idArr = explode(",", getInstanceIds("Device.Hosts.Host."));
     foreach ($idArr as $key => $value) {
         $macArr["{$value}"] = getStr("Device.Hosts.Host.{$value}.PhysAddress");
     }
     foreach ($macArr as $key => $value) {
         if (!strcasecmp($value, $macAddr)) {
             $index = $key;
             break;
         }
     }
     if (isset($index)) {
         setStr("Device.Hosts.Host.{$index}.Comments", $deviceInfo['Comments'], true);
     }
     $result = "success";
 } elseif (isIPValid($ipAddr) == FALSE) {
     $result = "Invlid IP address, please input again.";
 } else {
     $idArr = explode(",", getInstanceIds("Device.DHCPv4.Server.Pool.1.StaticAddress."));
     foreach ($idArr as $key => $value) {
         if (!strcasecmp(getStr("Device.DHCPv4.Server.Pool.1.StaticAddress.{$value}.Chaddr"), $macAddr)) {
             $exist = true;
             $existIndex = $value;
             break;
         }
     }
     if (!$exist) {
         /*
          * there are two scenarios: 
          *  1. DHCP ==> ReservedIP, add entry, update host comments
          *  2. ReservedIP ==> ReservedIP, mac address changed, modify this static entry, update host comments meanwhile