Migrate old cell Auth() data into a HiveAuth().
762430
async def cellAuthToHive(dirn, auth):
    '''
    
    '''
    logger.warning('migrating old cell auth to hive')

    path = os.path.join(dirn, 'auth.lmdb')

    lenv = lmdb.open(path, max_dbs=128)

    userdb = lenv.open_db(b'users')
    roledb = lenv.open_db(b'roles')

    migrated_roles = False
    migrated_users = False

    with lenv.begin() as xact:

        with xact.cursor(db=roledb) as curs:

            for lkey, lval in curs.iternext():

                name = lkey.decode('utf8')
                info = s_msgpack.un(lval)

                logger.info(f'Migrating role: {name}')

                role = auth.getRoleByName(name)
                if role is None:
                    logger.info(f'Creating role: {name}')
                    role = await auth.addRole(name)

                rules = info.get('rules', ())

                await role.setRules(rules)

                migrated_roles = True

        if not migrated_roles:  # pragma: no cover
            logger.info('No roles were migrated.')

        with xact.cursor(db=userdb) as curs:

            for lkey, lval in curs.iternext():

                name = lkey.decode('utf8')
                info = s_msgpack.un(lval)

                logger.info(f'Migrating user: {name}')

                user = auth.getUserByName(name)
                if user is None:
                    logger.info(f'Creating user: {name}')
                    user = await auth.addUser(name)

                if info.get('admin', False):
                    await user.setAdmin(True)

                if info.get('locked', False):
                    await user.setLocked(True)

                # set this directly since we only have the shadow
                shadow = info.get('shadow')
                if shadow is not None:
                    await user.info.set('passwd', shadow)

                rules = info.get('rules', ())
                await user.setRules(rules)

                for name in info.get('roles', ()):
                    await user.grant(name)

                migrated_users = True

        if not migrated_users:  # pragma: no cover
            logger.info('No users were migrated.')

    lenv.sync()
    lenv.close()
306550
private void migrateUsers() throws Exception
   {
      Session session = service.getStorageSession();
      try
      {
         if (session.itemExists(usersStorageOld))
         {
            NodeIterator iterator = ((ExtendedNode)session.getItem(usersStorageOld)).getNodesLazily();
            UserHandlerImpl uh = ((UserHandlerImpl)service.getUserHandler());
            while (iterator.hasNext())
            {
               uh.migrateUser(iterator.nextNode());
            }
         }
      }
      finally
      {
         session.logout();
      }
   }
259825
function getAuthorizationData(metadata, store){
	var properties;
	var workspaceIDs;
	var isPropertyString;
	if (typeof metadata.properties === "string") {
		isPropertyString = true;
		properties = JSON.parse(metadata.properties); // metadata.properties need to be parse when using MongoDB
		workspaceIDs = metadata.workspaces.map(function(workspace){
			return workspace.id;
		});
	} else {
		isPropertyString = false;
		properties = metadata.properties; // metadata.properties don't need to be parse when using FS
		workspaceIDs = metadata.WorkspaceIds; // This is only needed for Java server's metadata migration from old Java code
	}
	var version = properties["UserRightsVersion"] || 1; //assume version 1 if not specified
	var userRightArray = [];
	if (version === 1 || version === 2) { // This only for Java server's metadata migration 
		workspaceIDs.forEach(function(workspaceId){
			userRightArray = userRightArray.concat(createUserAccess(metadata["UniqueId"]).concat(createWorkspaceAccess(workspaceId)));
		});
		properties["UserRights"] = userRightArray;
		properties["UserRightsVersion"] = CURRENT_VERSION;
		if (isPropertyString) {
			metadata.properties = JSON.stringify(properties, null, 2);
		}
		store.updateUser(metadata["UniqueId"], metadata, function(){});
	} else {
		userRightArray = properties.UserRights;
	}
	return userRightArray;
}
788368
function migrateExpiration (store) {
  const request = store.openCursor()
  request.onsuccess = (event) => {
    const cursor = event.target.result
    if (!cursor) {
      return
    }
    const entry = cursor.value
    entry.expires = Date.now() + DEFAULT_EXPIRY
    cursor.update(entry)
  }
}
585341
def set_basic(self, realm='authentication required'):
        """"""
        dict.clear(self)
        dict.update(self, {'__auth_type__': 'basic', 'realm': realm})
        if self.on_update:
            self.on_update(self)
1226446
function onCopyLastUser() {
  // If last user is null, NULL_USER error will be thrown.
  auth.updateCurrentUser(lastUser).then(function() {
    alertSuccess('Copied last user to Auth');
  }, function(error) {
    alertError('Error: ' + error.code);
  });
}
1010588
def _registry_update(s, oldid):
        '''
        
        '''
        with _lock:
            sock_queue = ApplicationLayer._to_app.pop(oldid)
            ApplicationLayer._to_app[s._sockid()] = sock_queue
410880
def to_native(self, obj):
        """"""
        ret = super(UserSerializer, self).to_native(obj)
        del ret['password']
        return ret
1351606
def update(self, instance, oldValue, newValue, subKey):
    """"""
    histogram = self.__get__(instance, None)
    histogram[subKey] += newValue - oldValue
617244
private void cleanupStaleClients() {
    LocalTime cleanupTime = LocalTime.now();
    LOG.debug("Starting cleanup authentication registry at {}", cleanupTime);
    // Get a list of stale clients under read lock.
    List<UUID> staleChannels = new ArrayList<>();
    for (Map.Entry<UUID, AuthenticatedChannelInfo> clientEntry : mChannels.entrySet()) {
      LocalTime lat = clientEntry.getValue().getLastAccessTime();
      if (lat.plusSeconds(mCleanupIntervalMs / 1000).isBefore(cleanupTime)) {
        staleChannels.add(clientEntry.getKey());
      }
    }

    // Unregister stale clients.
    LOG.debug("Found {} stale channels for cleanup.", staleChannels.size());
    for (UUID clientId : staleChannels) {
      unregisterChannel(clientId);
    }
    LOG.debug("Finished state channel cleanup at {}", LocalTime.now());
  }
55327
def from_remote_hive(cls, url, *args, **kwargs):
        
        version = kwargs.pop('version', None)
        require = kwargs.pop('require_https', False)
        return cls(Hive.from_url(url, version, require), *args, **kwargs)
1058144
def authenticated(f):
    """"""
    @wraps(f)
    def new_f(self, *args, **kwargs):
        if not self.nova_client.client.auth_token:
            self.authenticate()
        return f(self, *args, **kwargs)
    return new_f
1013123
public void sessionLastAccessTimeSet(ISession session, long old, long newaccess) {
        // ArrayList sessionStateObservers = null;

        /*
         * Check to see if there is a non-empty list of sessionStateObservers.
         */
        if (_sessionStateObservers == null || _sessionStateObservers.size() < 1) {
            return;
        }

        // synchronized(_sessionStateObservers) {
        // sessionStateObservers = (ArrayList)_sessionStateObservers.clone();
        // }

        ISessionStateObserver sessionStateObserver = null;
        for (int i = 0; i < _sessionStateObservers.size(); i++) {
            sessionStateObserver = (ISessionStateObserver) _sessionStateObservers.get(i);
            sessionStateObserver.sessionLastAccessTimeSet(session, old, newaccess);
        }

    }
599098
def updateAndFlush(self, login, tableName, cells):
    
    self.send_updateAndFlush(login, tableName, cells)
    self.recv_updateAndFlush()
1026099
def MigrateInstance(r, instance, mode=None, cleanup=None):
    

    body = {}

    if mode is not None:
        body["mode"] = mode

    if cleanup is not None:
        body["cleanup"] = cleanup

    return r.request("put", "/2/instances/%s/migrate" % instance,
                     content=body)
1078375
def move(self, auth, resource, destinationresource, options={"aliases": True}, defer=False):
        
        return self._call('move', auth, [resource, destinationresource, options], defer)
390711
def _MigrateArtifact(artifact):
  """"""
  name = Text(artifact.name)

  try:
    logging.info("Migating %s", name)
    data_store.REL_DB.WriteArtifact(artifact)
    logging.info("  Wrote %s", name)
  except db.DuplicatedArtifactError:
    logging.info("  Skipped %s, because artifact already exists.", name)