Determine whether +reuse_access_token+ and a non-restorable
 +token_secret_strategy+ have both been activated.

 In that case, disable reuse_access_token value and warn the user.
963664
def validate_reuse_access_token_value
      strategy = token_secret_strategy
      return if !reuse_access_token || strategy.allows_restoring_secrets?

      ::Rails.logger.warn(
        "You have configured both reuse_access_token " \
        "AND strategy strategy '#{strategy}' that cannot restore tokens. " \
        "This combination is unsupported. reuse_access_token will be disabled"
      )
      @reuse_access_token = false
    end
1111298
static void ensureAccessible(AccessibleObject accessibleObject) {
        if (accessibleObject != null) {
            if (!accessibleObject.isAccessible()) {
                if (System.getSecurityManager() != null) {
                    AccessController.doPrivileged(SetAccessibleAction.of(accessibleObject));
                } else {
                    accessibleObject.setAccessible(true);
                }
            }
        }
    }
181549
def disable(self, threads=True):
        
        if self.enabled_start:
            sys.settrace(None)
            self._disable()
        else:
            warn('Duplicate "disable" call')
673073
def _token_valid(self):
        
        if not self._cache_token:
            return False
        now = time.time()
        if now - self._token.acquired_time > self._token_timeout:
            logger.debug('token needs to be reset')
            return False
        return True
1239427
def disable_csrf_protection():
    
    if not HAS_PLONE_PROTECT:
        logger.warn(
            "Can not disable CSRF protection – please install plone.protect"
        )
        return False
    request = get_request()
    interface.alsoProvides(request, IDisableCSRFProtection)
    return True
1275395
def revoke(self, token_id, *args, **kwargs):
        

        return self.delete(token_id, *args, **kwargs)
257334
def is_resource_protected(self, request, **kwargs):
        
        access_state = self._get_resource_access_state(request)
        protected_states = self.get_protected_states()
        return access_state in protected_states
1269797
def _disable_access_key(self, force_disable_self=False):
        
        client = self.client
        if self.validate is True:
            return
        else:
            try:
                client.update_access_key(
                    UserName=self._search_user_for_key(),
                    AccessKeyId=self.access_key_id,
                    Status='Inactive'
                )
                logger.info(
                    "Access key {id} has "
                    "been disabled.".format(id=self.access_key_id)
                )
            except Exception as e:
                logger.info(
                    "Access key {id} could not "
                    "be disabled due to: {e}.".format(
                        e=e, id=self.access_key_id
                    )
                )
492419
private boolean checkEnabled() {
        boolean retVal = false;

        try {
            if (getSettings().getBoolean(Settings.KEYS.ANALYZER_CENTRAL_ENABLED)) {
                if (!getSettings().getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED)
                        || NexusAnalyzer.DEFAULT_URL.equals(getSettings().getString(Settings.KEYS.ANALYZER_NEXUS_URL))) {
                    LOGGER.debug("Enabling the Central analyzer");
                    retVal = true;
                } else {
                    LOGGER.info("Nexus analyzer is enabled, disabling the Central Analyzer");
                }
            } else {
                LOGGER.info("Central analyzer disabled");
            }
        } catch (InvalidSettingException ise) {
            LOGGER.warn("Invalid setting. Disabling the Central analyzer");
        }
        return retVal;
    }
967805
def stop_accepting_passive_svc_checks(self):
        
        if self.my_conf.accept_passive_service_checks:
            self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value
            self.my_conf.accept_passive_service_checks = False
            self.my_conf.explode_global_conf()
            self.daemon.update_program_status()
65970
def invalidate(strategy, value = nil)
      (value = strategy; strategy = :id) unless strategy.is_a?(Symbol)
      # call the invalidate method of the chosen strategy
      @strategy_by_attribute[strategy].invalidate(value) if @strategy_by_attribute[strategy]
    end
886067
def check_user_token(self, request, user):
        
        if not app_settings.REST_USER_TOKEN_ENABLED:
            return False
        try:
            token = Token.objects.get(
                user=user,
                key=request.data.get('password')
            )
        except Token.DoesNotExist:
            token = None
        else:
            if app_settings.DISPOSABLE_USER_TOKEN:
                token.delete()
        finally:
            return token is not None
45476
def guard_deactivate(analysis_service):
    
    for dependant in analysis_service.getServiceDependants():
        status = api.get_workflow_status_of(dependant)
        if status == "active":
            return False

    return True
1108656
def delete_refresh_token(self, refresh_token):
        
        access_token = self.fetch_by_refresh_token(refresh_token)

        self.delete(access_token.token)
1143434
def guard_cancel(analysis_request):
    
    # Ask to partitions
    for partition in analysis_request.getDescendants(all_descendants=False):
        if not isTransitionAllowed(partition, "cancel"):
            return False

    # Look through analyses. We've checked the partitions already, so there is
    # no need to look through analyses from partitions again, but through the
    # analyses directly bound to the current Analysis Request.
    cancellable_states = ["unassigned", "registered"]
    for analysis in analysis_request.objectValues("Analysis"):
        if api.get_workflow_status_of(analysis) not in cancellable_states:
            return False

    return True
61343
final boolean deactivate() {
        long c = callId;
        if (c <= 0) {
            return false;
        }
        if (CALL_ID.compareAndSet(this, c, -c)) {
            return true;
        }
        if (callId > 0) {
            throw new IllegalStateException("Operation concurrently re-activated while executing deactivate(). " + this);
        }
        return false;
    }
677716
def revoke_session(self, sid='', token=''):
        
        if not sid:
            if token:
                sid = self.handler.sid(token)
            else:
                raise ValueError('Need one of "sid" or "token"')

        for typ in ['access_token', 'refresh_token', 'code']:
            try:
                self.revoke_token(self[sid][typ], typ)
            except KeyError:  # If no such token has been issued
                pass

        self.update(sid, revoked=True)