Schedules expiration of new users from policy and existing ones

 @param [Array<LoginUsers>] Array of updated users

 == Returns:
 @return [TrueClass] always returns true
7595
def manage_existing_users(new_policy_users)
      now = Time.now

      previous = {}
      if InstanceState.login_policy
        InstanceState.login_policy.users.each do |user|
          previous[user.uuid] = user
        end
      end

      current = {}
      new_policy_users.each do |user|
        current[user.uuid] = user
      end

      added   = current.keys - previous.keys
      removed = previous.keys - current.keys
      stayed  = current.keys & previous.keys

      removed.each do |k|
        begin
          user = current[k] || previous[k]
          LoginUserManager.manage_user(user.uuid, user.superuser, :disable => true)
        rescue Exception => e
          RightScale::Log.error("Failed to disable user '#{user.uuid}'", e) unless e.is_a?(ArgumentError)
        end
      end

      (added + stayed).each do |k|
        begin
          user = current[k] || previous[k]
          disable = !!(user.expires_at) && (now >= user.expires_at)
          LoginUserManager.manage_user(user.uuid, user.superuser, :disable => disable)
        rescue Exception => e
          RightScale::Log.error("Failed to manage existing user '#{user.uuid}'", e) unless e.is_a?(ArgumentError)
        end
      end
    rescue Exception => e
      RightScale::Log.error("Failed to manage existing users", e)
    end
1079642
def _UpdateUsers(self, update_users):
    
    for user, ssh_keys in update_users.items():
      if not user or user in self.invalid_users:
        continue
      configured_keys = self.user_ssh_keys.get(user, [])
      if set(ssh_keys) != set(configured_keys):
        if not self.utils.UpdateUser(user, ssh_keys):
          self.invalid_users.add(user)
        else:
          self.user_ssh_keys[user] = ssh_keys[:]
766160
def _zone_expired(self, zone):
        
        return (time.time() > self._zones[zone].timestamp + Zonetracker.EXPIRE) and self._zones[zone].expander is False
792620
def expire_at(time)
      time = (time.to_f * 1000).floor
      return coerce_bool(self.connection.pexpireat(@key, time))
    end
965357
def executor(user_account, options = {}) 
      @executor ||= case self.class.name
      when /System/
        then Permit::Executor::System.new self, user_account, options
      else  
        Permit::Executor::Base.new self, user_account, options
      end
    end
187513
def users(time_unit, start, duration)
      start = start.strftime(TIME_FORMAT[time_unit.downcase.to_sym])
      duration = build_duration(time_unit.downcase.to_sym, duration)
      params = {
        time_unit: time_unit.upcase,
        start: start,
        duration: duration
      }
      url = base_url + '/users'
      Http::Client.get(@jpush, url, params: params)
    end
466428
def _update_session_expiration(self):
        

        session_time = oz.settings["session_time"]

        if session_time:
            self.redis().expire(self._session_key, session_time)
738559
def expired(self):
        
        if self.timeout is None:
            return False

        return monotonic() - self.start_time > self.timeout
930836
def auth_expired(self):
        
        if self._auth and self._expires:
            now_with_skew = time.time() + AUTH_TOKEN_CLOCK_SKEW_MAX
            return now_with_skew > self._expires
        return True
1308028
def expires_at(self):
        """"""
        try:
            expires = min(sig.key_expiration for sig in itertools.chain(iter(uid.selfsig for uid in self.userids), self.self_signatures)
                          if sig.key_expiration is not None)

        except ValueError:
            return None

        else:
            return (self.created + expires)
493412
def update_users(self, entries):
        
        ws = IWorkspace(self.context)
        members = ws.members

        # check user permissions against join policy
        join_policy = self.context.join_policy
        if (join_policy == "admin"
            and not checkPermission(
                "collective.workspace: Manage roster",
                self.context)):
            raise Unauthorized("You are not allowed to add users here")

        for entry in entries:
            id = entry.get('id')
            is_member = bool(entry.get('member'))
            is_admin = bool(entry.get('admin'))

            # Existing members
            if id in members:
                member = members[id]
                if not is_member:
                    if checkPermission(
                            "ploneintranet.workspace: Manage workspace",
                            self.context):
                        ws.membership_factory(ws, member).remove_from_team()
                    else:
                        raise Unauthorized(
                            "Only team managers can remove members")
                elif not is_admin:
                    ws.membership_factory(ws, member).groups -= {'Admins'}
                else:
                    ws.membership_factory(ws, member).groups |= {'Admins'}

            # New members
            elif id not in members and (is_member or is_admin):
                groups = set()
                if is_admin:
                    groups.add('Admins')
                ws.add_to_team(user=id, groups=groups)
1259230
def accounts=(new_accounts)
      old_accounts = @accounts
      @accounts = FogTracker.validate_accounts(new_accounts)
      if (@accounts != old_accounts)
        stop if (was_running = running?)
        create_trackers
        start if was_running
      end
      @accounts
    end
470657
function (sql, docs, users, queueAttrRecs, partitions, cols, policy, roles,
  userRoles, attrs, partitioner) {
  this._sql = sql;
  this._docs = docs;
  this._users = users;
  this._queueAttrRecs = queueAttrRecs;
  this._partitions = partitions;
  this._cols = cols;
  this._policy = policy;
  this._roles = roles;
  this._userRoles = userRoles;
  this._mainParts = [constants.LATEST, constants.RECENT, constants.ALL];
  this._clearCache();
  this._attrs = attrs;
  this._partitioner = partitioner;
}
1178384
def expired?
      return false if @task.expires_after.blank?

      expire_duration.from_now(@scheduled_time) < Time.now.in_time_zone(@task.time_zone)
    end
750335
def expired?(service_name)
      if entry = @record_cache[service_name]
        return Time.now > (entry.resolution_time + entry.ttl)
      else
        return true
      end
    end
1300962
def expire(self, current_time=None):
        
        if self._queue.is_empty():
            return

        if current_time is None:
            current_time = time.time()

        while not self._queue.is_empty():
            # Get top most item
            top = self._queue.peek()

            # Early exit if item was not promoted and its expiration time
            # is greater than now.
            if top.promoted is None and top.expiry_date > current_time:
                break

            # Pop item from the stack
            top = self._queue.pop()

            need_reschedule = (top.promoted is not None
                               and top.promoted > current_time)

            # Give chance to reschedule
            if not need_reschedule:
                top.promoted = None
                top.on_delete(False)

                need_reschedule = (top.promoted is not None
                                   and top.promoted > current_time)

            # If item is promoted and expiration time somewhere in future
            # just reschedule it
            if need_reschedule:
                top.expiry_date = top.promoted
                top.promoted = None
                self._queue.push(top)
            else:
                del self._items[top.session_id]
240181
def last_librarian?
      if has_role?('Librarian')
        role = Role.where(name: 'Librarian').first
        return true if role.users.count == 1
        false
      end
    end