Does the current user have permission to access this screen.
@return NORMAL_RETURN if access is allowed, ACCESS_DENIED or LOGIN_REQUIRED otherwise.
488669
public int checkSecurity()
    {
        int iLevel = Constants.LOGIN_USER;
        try {
            iLevel = Integer.parseInt(this.getProperty(Params.SECURITY_LEVEL));
        } catch (NumberFormatException ex) {
        }
        
        int iAccessAllowed = DBConstants.NORMAL_RETURN;
        
        if (iLevel == Constants.LOGIN_USER)
            if (!DBConstants.ANON_USER_ID.equalsIgnoreCase(this.getProperty(DBParams.USER_ID)))
        {
            if (this.getProperty(DBParams.USER_NAME) != null)
                iAccessAllowed = DBConstants.AUTHENTICATION_REQUIRED;   // If you have an account, you need to sign into it.
        }
        
        return iAccessAllowed;
    }
621859
def permitted_to? (privilege, options = {}, &block)
      options = {
        :user =>  Authorization.current_user,
        :object => self
      }.merge(options)
      Authorization::Engine.instance.permit?(privilege,
          {:user => options[:user],
           :object => options[:object]},
          &block)
    end
691328
def checkUserAccess(self):
        
        # Deny access to foreign analysts
        allowed = True
        pm = getToolByName(self, "portal_membership")
        member = pm.getAuthenticatedMember()

        analyst = self.getAnalyst().strip()
        if analyst != _c(member.getId()):
            roles = member.getRoles()
            restrict = 'Manager' not in roles \
                and 'LabManager' not in roles \
                and 'LabClerk' not in roles \
                and 'RegulatoryInspector' not in roles \
                and self.bika_setup.getRestrictWorksheetUsersAccess()
            allowed = not restrict

        return allowed
559301
protected function initPermissions()
    {
        if ($this->app->runningInConsole()) {
            return;
        }

        Permission::get()->map(function(Permission $permission) {
            Gate::define($permission->name, function ($user) use ($permission) {
                return $user->hasPermission($permission);
            });
        });        
    }
1063109
public function isBlocked()
    {
        if ($this->user() === null) {
            return null;
        }

        // Check user blocking status only if User model is role based user
        if ($this->user instanceof User) {
            return $this->user->blocked;
        }

        return false;
    }
443942
public function canAccess()
    {
        //Check if the user needs to be authentic to access
        if($this->hasProperty('access') && !empty($this->access))
        {
            if(!$this->getObject('user')->isAuthentic()) {
                return false;
            }
        }

        //Check if the user is in the group(s) to access
        if($this->hasProperty('access_group') && !empty($this->access_group))
        {
            $groups = $this->getObject('user')->getGroups();

            if(!in_array($this->access_group, $groups)) {
                return false;
            }
        }

        //Check if the user has the right role(s) to access
        if($this->hasProperty('access_role') && !empty($this->access_role))
        {
            if(!$this->getObject('user')->hasRole($this->access_role)) {
                return false;
            }
        }

        return true;
    }
154606
private function __canAccessAlerts()
    {
        if ($this->Page instanceof AdministrationPage && self::isLoggedIn() && Symphony::Author()->isDeveloper()) {
            return true;
        }

        return false;
    }
143324
public function check()
    {
        $result = true;

        // TODO This check tries only to connect to the database
        // But it would make sense to check
        //  a) insert, select, update, delete, etc. access
        //  a) a) Which access rights do i need? Topic hardening?
        try {
            $this->database->connect($this->database->getConfig());
        } catch (\Exception $e) {
            $result = false;
        }

        return $result;
    }
911220
public function canRead()
    {
        $c = Page::getByPath('/dashboard', 'ACTIVE');
        if ($c && !$c->isError()) {
            $cp = new Permissions($c);

            return $cp->canViewPage();
        }
    }
600569
def has_access?(permission, user)
      raise UnknownUserException if user.nil?

      AccessProvider.action_permitted_for_user?(permission, user)
    end
76049
private boolean isValidTenantUserAccess(Tenant tenant, String userid, String password, Permission permNeeded) {
        TenantDefinition tenantDef = tenant.getDefinition();
        assert tenantDef != null;
        if (tenantDef.getUsers().size() == 0) {
            // We allow access to the default tenant when it has no users defined.
            return tenant.getName().equals(m_defaultTenantName);
        }
        UserDefinition userDef = tenantDef.getUser(userid);
        if (userDef == null || Utils.isEmpty(password)) {
            return false;   // no such user or no password given
        }
        if (userDef.getHash() != null) {
            if (!PasswordManager.checkPassword(password, userDef.getHash())) {
                return false;   // password is hashed but didn't match
            }
        } else {
            if (!password.equals(userDef.getPassword())) {
                return false;   // password is plaintext but didn't match
            }
        }
        return isValidUserAccess(userDef, permNeeded);
    }
915969
private boolean hasPermissionToSeeToken() {
        // Administrators can do whatever they want
        if (SHOW_LEGACY_TOKEN_TO_ADMINS && Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
            return true;
        }
        
        User current = User.current();
        if (current == null) { // Anonymous
            return false;
        }
        
        // SYSTEM user is always eligible to see tokens
        if (Jenkins.getAuthentication() == ACL.SYSTEM) {
            return true;
        }
        
        return User.idStrategy().equals(user.getId(), current.getId());
    }
501388
public function isAccessible()
    {
        $root = $this->getRootParagraph();

        if ( ! empty( $root->allAccess ) )
        {
            return true;
        }

        $user = $this->getAuthenticatedUser();

        if ( empty( $user ) )
        {
            return ! empty( $root->accessUsers ) && in_array( '', $root->accessUsers )
                || ! empty( $root->accessGroups ) && in_array( '', $root->accessGroups );
        }

        return ! empty( $root->accessUsers ) && in_array( $user->id, $root->accessUsers )
            || ! empty( $root->accessGroups ) && in_array( $user->groupId, $root->accessGroups )
            || $this->getServiceLocator()
                    ->get( 'Grid\User\Model\Permissions\Model' )
                    ->isAllowed( $root, 'view' );
    }
784586
def can_read(self):
        
        sm = getSecurityManager()
        if not sm.checkPermission(permissions.View, self.context):
            return False
        return True
883381
def has_access(self, permission_name, view_name):
        
        if current_user.is_authenticated:
            return self._has_view_access(g.user, permission_name, view_name)
        elif current_user_jwt:
            return self._has_view_access(current_user_jwt, permission_name, view_name)
        else:
            return self.is_item_public(permission_name, view_name)
518582
public function isAuthorised()
    {

        if (is_array($this->user) === true
            && isset($this->user['error']) === false
        ) {

            return true;
        }

        return $this->getUser();
    }
641415
def has_permission(self, permission):
        
        f = self.create_future()

        #: Old versions of android did permissions at install time
        if self.api_level < 23:
            f.set_result(True)
            return f

        def on_result(allowed):
            result = allowed == Activity.PERMISSION_GRANTED
            self.set_future_result(f, result)

        self.widget.checkSelfPermission(permission).then(on_result)

        return f