/* haven't decided about access for this one yet
514590
private GeneralizedCounter<K> conditionalizeHelper(K o) {
    if (depth > 1) {
      GeneralizedCounter<K> next = ErasureUtils.<GeneralizedCounter<K>>uncheckedCast(map.get(o));
      if (next == null) // adds a new GeneralizedCounter if needed
      {
        map.put(o, (next = new GeneralizedCounter<K>(depth - 1)));
      }
      return next;
    } else {
      throw new RuntimeException("Error -- can't conditionalize a distribution of depth 1");
    }
  }
821329
function find(params = {}) {
  const name = params.type;

  if (Utils.has(availableDirectives, name)) {
    return new availableDirectives[name](params);
  }

  // Only show warning if someone explicity enters a bad name
  if (name) { Logger.warn(`Directive type '${name}' does not exist. Falling back to 'text'`); }
  /* eslint-disable-next-line new-cap */
  return new availableDirectives.text(params);
}
1292317
function useNonce($server_url, $timestamp, $salt)
    {
        global $Auth_OpenID_SKEW;

        if (!$this->active) {
            trigger_error("FileStore no longer active", E_USER_ERROR);
            return null;
        }

        if ( abs($timestamp - time()) > $Auth_OpenID_SKEW ) {
            return false;
        }

        if ($server_url) {
            list($proto, $rest) = explode('://', $server_url, 2);
        } else {
            $proto = '';
            $rest = '';
        }

        $parts = explode('/', $rest, 2);
        $domain = $this->_filenameEscape($parts[0]);
        $url_hash = $this->_safe64($server_url);
        $salt_hash = $this->_safe64($salt);

        $filename = sprintf('%08x-%s-%s-%s-%s', $timestamp, $proto,
                            $domain, $url_hash, $salt_hash);
        $filename = $this->nonce_dir . DIRECTORY_SEPARATOR . $filename;

        $result = @fopen($filename, 'x');

        if ($result === false) {
            return false;
        } else {
            fclose($result);
            return true;
        }
    }
1363453
function(req, res, next) {
                    if (req.headers.origin === undefined) {
                        res.setHeader('Access-Control-Allow-Origin', "*");
                    } else {
                        res.setHeader('Access-Control-Allow-Origin', req.headers.origin);
                    }
                    res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
                    console.log(req.method + " on " + req.originalUrl);
                    if (req.method === "OPTIONS") {
                        res.setHeader('Access-Control-Allow-Headers', 'content-type');
                        res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
                        res.setHeader('Content-Length', '0');
                        res.setHeader('Content-Type', 'application/json; charset=utf-8');
                        grunt.file.read(req.originalUrl.split("?")[0]);
                        //res.write(body);
                        res.end("200");
                        //next();
                    } else {
                        next();
                    }
                }
1024491
function determineUserScope (req, res, next) {
  var params = req.connectParams
  var scope = params.scope
  var subject = req.user

  Scope.determine(scope, subject, function (err, scope, scopes) {
    if (err) { return next(err) }
    req.scope = scope
    req.scopes = scopes
    next()
  })
}
572779
function getPreviousItem(opts: Options, value: Value, block?: Block): ?Block {
    const { document, startBlock } = value;
    block = block || startBlock;

    const currentItem = getCurrentItem(opts, value, block);
    if (!currentItem) {
        return null;
    }

    const previousSibling = document.getPreviousSibling(currentItem.key);

    if (!previousSibling) {
        return null;
    } else if (previousSibling.type === opts.typeItem) {
        return previousSibling;
    }
    return null;
}
164156
function publishAreaVisibility() {
      const showing = visibilityIsChanging ? !$scope.model.areaShowing : $scope.model.areaShowing;
      return visibility.updateAreaVisibility( { [ $scope.features.area.name ]: showing } );
   }
1313190
function getAccessToken() {
  let token = dropbox.getAccessToken();
  if (!token && window.localStorage) {
    const jsonString = window.localStorage.getItem('dropbox');
    token = jsonString && JSON.parse(jsonString).token;
    if (token) {
      dropbox.setAccessToken(token);
    }
  }

  return (token || '') !== '' ? token : null;
}
245741
function get_wiring( req, res, next) {
		req.wiring_collection.findOne({
					user_id: req.current_user._id, 
					_id: ObjectID.createFromHexString(req.param('id')) 
			}, function(error, wiring) {
				if(error) { throw error; }
				req.wiring = wiring;
				next();
			});
	}
24487
async function getUsersIdsToNotify(thing, checkValueAccess) {
	
	if (!thing)
		throw new utils.ErrorCustom(httpStatusCodes.INTERNAL_SERVER_ERROR, "Thing can't be null", 26);
	
	let UsersIdsToNotify = new Set();
	
	for(let r of thing.usersRights) {
	
		if (!(
			((r.userStatus & (thConstants.ThingUserStates.Ok | thConstants.ThingUserStates.WaitForAuth)) != 0) &&
				((r.userVisibility & thConstants.ThingUserVisibility.Visible) != 0))
		)
			continue;

		let userId = r.userId;
		let username = r.username;
	
		if (!userId && !username)
			throw new utils.ErrorCustom(httpStatusCodes.INTERNAL_SERVER_ERROR, "Both userId and username can't be empty", 27);
		
		let user = userId ? await usersManager.findUserById(userId) : await	usersManager.findUserByUsername(username);
		if (!user)
			continue;

		if (checkValueAccess) {
			let thingUserClaims = getThingUserClaims(user, thing, user.isSuperAdministrator);
			if ((thingUserClaims.change & thConstants.ThingUserChangeClaims.CanChangeValue) == 0)
				continue;
		}
			
		UsersIdsToNotify.add(userId);
	}
	
	return UsersIdsToNotify;
}
413052
function() {
      var deferred = $q.defer();

      $rootScope.$evalAsync(function() {
        var n = _current.name;
        var p = angular.copy(_current.params);
        if(!_current.params) {
          _current.params = {};
        }
        _current.params.deprecated = true;

        // Notify
        $rootScope.$broadcast('$stateReload', null, _current);

        _changeStateAndBroadcastComplete(n, p).then(function() {
          deferred.resolve();
        }, function(err) {
          deferred.reject(err);
        });
      });

      return deferred.promise;
    }
431095
function(req, res, next) {
      var accData = req.user.Account
        , newData = {
          name:       req.body.name       || accData.name,
          logo:       req.body.logo       || accData.logo,
          info:       req.body.info       || accData.info,
          email:      req.body.email      || accData.email,
          themeColor: req.body.themeColor || accData.themeColor
        };

      req.body = newData;
      next();
    }
299467
function isAvailable( name, clbk ) {
	isOnline( next );

	/**
	* FUNCTION: next( error, online )
	*	Callback invoked after checking if a user has internet access.
	*
	* @private
	* @param {Null} error - error argument
	* @param {Boolean} online - boolean indicating if the user is online
	*/
	function next( error, online ) {
		if ( !online ) {
			// Error on the side of assuming that the name is available...
			return clbk( null, true );
		}
		npmName( name, done );
	}

	/**
	* FUNCTION: done( error, available )
	*	Callback invoked after checking NPM name availability.
	*
	* @private
	* @param {Null} error - error argument
	* @param {Boolean} available - boolean indicating if an NPM name is available
	*/
	function done( error, available ) {
		clbk( null, available );
	}
}
1114901
function () {
            var cfg = this._cfg;
            var waiEscapeMsg = cfg.waiEscapeMsg;
            var confirmed = !(cfg.waiAria && waiEscapeMsg);
            if (!confirmed) {
                var now = new Date().getTime();
                confirmed = this._firstEscapeTime && (now - this._firstEscapeTime) <= 3000;
                if (!confirmed) {
                    this._firstEscapeTime = now;
                    this.waiReadText(waiEscapeMsg);
                }
            }
            if (confirmed) {
                this._firstEscapeTime = null;
                this.actionClose();
            }
        }
147825
function (done) {
      // the token is random
      if (token.indexOf('.') === -1) {
        AccessToken.get(token, function (err, instance) {
          if (err) {
            return done(err)
          }

          if (!instance) {
            return done(new UnauthorizedError({
              realm: 'user',
              error: 'invalid_request',
              error_description: 'Unknown access token',
              statusCode: 401
            }))
          }

          done(null, {
            jti: instance.at,
            iss: instance.iss,
            sub: instance.uid,
            aud: instance.cid,
            iat: instance.created,
            exp: instance.created + instance.ei,
            scope: instance.scope
          })
        })

      // the token is not random
      } else {
        done()
      }
    }
179004
private int getAccess(Collection.Key key) {
	Member member = getMember(ACCESS_PRIVATE, key, false, false);
	if (member == null) return Component.ACCESS_PRIVATE;
	return member.getAccess();
    }
404315
function AuthenticationOAuth(options) {
    AuthenticationAbstract.call(this, options);
    options = options || {};
    this._token = {
        access: options.accessToken || null
    };
}