/**
  * Log in a user if the username matches, but without checking the password,
  * as part of the admin-act-as process
  * 
  * @param <##>
  * @return boolean TRUE if tokens are valid.
  * @access public
  * @since 12/11/06
  */
 function _authenticateAdminActAsUserForType(AuthNTokens $authNTokens, Type $authenticationType)
 {
     $this->_checkType($authenticationType);
     // 		$this->destroyAuthenticationForType($authenticationType);
     if ($authNTokens) {
         $authNMethodManager = Services::getService("AuthNMethods");
         $authNMethod = $authNMethodManager->getAuthNMethodForType($authenticationType);
         // just check if the tokens exist, not if there is a correct password.
         $isValid = $authNMethod->tokensExist($authNTokens);
         // If the authentication was successful, get the AgentId from the mapping
         // system and record the result.
         if ($isValid) {
             $agentId = $this->_getAgentIdForAuthNTokens($authNTokens, $authenticationType);
             $authenticationTypeString = $this->_getTypeString($this->_adminActAsType);
             $_SESSION['__AuthenticatedAgents'][$authenticationTypeString] = $agentId;
             // Update any stale info that was previously loaded
             $properties = $authNMethod->getPropertiesForTokens($authNTokens);
             $displayName = $authNMethod->getDisplayNameForTokens($authNTokens);
             $agentManager = Services::getService("Agent");
             $agent = $agentManager->getAgent($agentId);
             $agent->updateDisplayName($displayName);
             $propertyManager = Services::getService("Property");
             $propertyManager->storeProperties($agentId->getIdString(), $properties);
             // Ensure that the Authorization Cache gets the new users
             $authorizationMgr = Services::getService("AuthZ");
             $isAuthorizedCache = $authorizationMgr->getIsAuthorizedCache();
             $isAuthorizedCache->dirtyUser();
         }
         // Log the success or failure
         if (Services::serviceRunning("Logging")) {
             $loggingManager = Services::getService("Logging");
             $log = $loggingManager->getLogForWriting("Authentication");
             $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
             $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events.");
             if ($isValid) {
                 $item = new AgentNodeEntryItem("Admin Acting As", "Admin users: <br/>&nbsp;&nbsp;&nbsp;&nbsp;" . implode(", ", $_SESSION['__ADMIN_NAMES_ACTING_AS_OTHER']) . "<br/>Successfully authenticated as: <br/>&nbsp;&nbsp;&nbsp;&nbsp;" . htmlspecialchars($authenticationType->getKeyword()) . " <br/>&nbsp;&nbsp;&nbsp;&nbsp;" . htmlspecialchars($authNTokens->getIdentifier()));
                 $item->addAgentId($agentId);
                 $item->addUserIds();
                 $log->appendLogWithTypes($item, $formatType, $priorityType);
             }
         }
         return $isValid;
     } else {
         return false;
     }
 }