Grant a permission to the resource.

@param iResource
Requested resource
@param iOperation
Permission to grant/add
160427
public void grant(final String iResource, final int iOperation) {
    final Byte current = rules.get(iResource);
    byte currentValue = current == null ? PERMISSION_NONE : current.byteValue();

    currentValue |= (byte) iOperation;

    rules.put(iResource, currentValue);
    document.field("rules", rules);
  }
1041073
public final void checkPermission( String resource , String action ) throws JMSException
    {
        if (securityContext == null)
            return; // Security is disabled

        securityContext.checkPermission(resource, action);        
    }
1020620
public void grantResource(ResourceRequestInfo req, ResourceGrant grant) {
    if (deleted) {
      throw new RuntimeException("Session: " +
          sessionId + " has been deleted");
    }

    removePendingRequest(req);
    idToGrant.put(req.getId(), grant);
    addGrantedRequest(req);

    // Handle the first wait metrics
    synchronized (typeToFirstWait) {
      if (!typeToFirstWait.containsKey(req.getType())) {
        throw new IllegalStateException(
            "Impossible to get a grant prior to requesting a resource.");
      }
      Long firstWait = typeToFirstWait.get(req.getType());
      if (firstWait == null) {
        firstWait = new Long(ClusterManager.clock.getTime() - startTime);
        typeToFirstWait.put(req.getType(), firstWait);
      }
    }
  }
877075
private static void grantUriPermissionsForIntent(final Activity context, final Uri outputDestination, final Intent intent) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            final List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
            for (ResolveInfo resolveInfo : resInfoList) {
                final String packageName = resolveInfo.activityInfo.packageName;
                context.grantUriPermission(packageName, outputDestination, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
            }
        }
    }
221971
@SuppressWarnings("resource")
    private InputStream openResource(String name) throws IOException {
        InputStream in;
        if (iFileDir != null) {
            in = new FileInputStream(new File(iFileDir, name));
        } else {
            final String path = iResourcePath.concat(name);
            in = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
                public InputStream run() {
                    if (iLoader != null) {
                        return iLoader.getResourceAsStream(path);
                    } else {
                        return ClassLoader.getSystemResourceAsStream(path);
                    }
                }
            });
            if (in == null) {
                StringBuilder buf = new StringBuilder(40)
                    .append("Resource not found: \"")
                    .append(path)
                    .append("\" ClassLoader: ")
                    .append(iLoader != null ? iLoader.toString() : "system");
                throw new IOException(buf.toString());
            }
        }
        return in;
    }
646561
private void visit_OP_SET_PERMISSIONS() throws IOException {
    visitTxId();
    v.visitStringUTF8( EditsElement.PATH);
    v.visitShort(      EditsElement.FS_PERMISSIONS);
  }
1091992
public void setPermission(String src, FsPermission permission
                            ) throws IOException {
    checkOpen();
    clearFileStatusCache();
    
    try {
      namenode.setPermission(src, permission);
    } catch(RemoteException re) {
      throw re.unwrapRemoteException(AccessControlException.class,
                                     FileNotFoundException.class);
    }
  }
1291394
public void addSource(ISource source) {
		if (sourceList == null) {
			sourceList = new ArrayList<ISource>();
		}
		sourceList.add(source);
	}
511355
public Set<Permission> authorize(AuthenticatedUser user, IResource resource)
    {
        if (user.isSuper())
            return Permission.ALL;

        UntypedResultSet result;
        try
        {
            ResultMessage.Rows rows = authorizeStatement.execute(QueryState.forInternalCalls(),
                                                                 QueryOptions.forInternalCalls(ConsistencyLevel.LOCAL_ONE,
                                                                                               Lists.newArrayList(ByteBufferUtil.bytes(user.getName()),
                                                                                                                  ByteBufferUtil.bytes(resource.getName()))));
            result = UntypedResultSet.create(rows.result);
        }
        catch (RequestValidationException e)
        {
            throw new AssertionError(e); // not supposed to happen
        }
        catch (RequestExecutionException e)
        {
            logger.warn("CassandraAuthorizer failed to authorize {} for {}", user, resource);
            return Permission.NONE;
        }

        if (result.isEmpty() || !result.one().has(PERMISSIONS))
            return Permission.NONE;

        Set<Permission> permissions = EnumSet.noneOf(Permission.class);
        for (String perm : result.one().getSet(PERMISSIONS, UTF8Type.instance))
            permissions.add(Permission.valueOf(perm));
        return permissions;
    }
1007983
public void setAuditSourceId(String sourceId, String enterpriseSiteId)
	{
		setAuditSourceId(sourceId, enterpriseSiteId, (RFC3881AuditSourceTypes[])null);
	}
58775
public static void ioprioSetIfPossible(int ioprio_value) throws IOException {
    if (nativeLoaded && ioprioPossible) {
      try {
        ioprio_set(ioprio_value);
      } catch (UnsupportedOperationException uoe) {
        LOG.warn("ioprioSetIfPossible() failed", uoe);
        ioprioPossible = false;
      } catch (UnsatisfiedLinkError ule) {
        LOG.warn("ioprioSetIfPossible() failed", ule);
        ioprioPossible = false;
      } catch (NativeIOException nie) {
        LOG.warn("ioprioSetIfPossible() failed", nie);
        throw nie;
      }
    }
  }
1137514
public static void executeWithSystemPermissions(Runnable task) {
        ContextAwareRunnable contextAwaretask = new ContextAwareRunnable(task);
        Subject newsubject = new Subject.Builder().buildSubject();
        newsubject.login(new RootAuthenticationToken());
        try {
            newsubject.execute(contextAwaretask);
        } finally {
            newsubject.logout();
        }
    }
593972
private void visit_OP_GET_DELEGATION_TOKEN() throws IOException {
    visitTxId();
    
    v.visitByte(EditsElement.T_VERSION);
    v.visitStringText(EditsElement.T_OWNER);
    v.visitStringText(EditsElement.T_RENEWER);
    v.visitStringText(EditsElement.T_REAL_USER);
    v.visitVLong(EditsElement.T_ISSUE_DATE);
    v.visitVLong(EditsElement.T_MAX_DATE);
    v.visitVInt(EditsElement.T_SEQUENCE_NUMBER);
    v.visitVInt(EditsElement.T_MASTER_KEY_ID);
    if (LayoutVersion.supports(Feature.EDITLOG_OP_OPTIMIZATION, editsVersion)) {
      v.visitLong(EditsElement.T_EXPIRY_TIME);
    } else {
      v.visitStringUTF8(EditsElement.T_EXPIRY_TIME);
    }
  }
1369204
private Permission createReadPermission(String table) {
        return _permissionResolver.resolvePermission(Permissions.readSorTable(new NamedResource(table)));
    }
1368780
static void requestPermission(Source source, String[] permissions) {
        Intent intent = new Intent(source.getContext(), BridgeActivity.class);
        intent.putExtra(KEY_TYPE, BridgeRequest.TYPE_PERMISSION);
        intent.putExtra(KEY_PERMISSIONS, permissions);
        source.startActivity(intent);
    }
703130
@SuppressWarnings("unchecked")
    public boolean hasPermission(Authentication authentication,
                                 Serializable resource,
                                 String resourceType,
                                 Object privilege) {
        boolean logPermission = isLogPermission(resource);
        if (checkRole(authentication, privilege, logPermission)) {
            return true;
        }
        if (resource != null) {
            Object resourceId = ((Map<String, Object>) resource).get("id");
            if (resourceId != null) {
                ((Map<String, Object>) resource).put(resourceType,
                    resourceFactory.getResource(resourceId, resourceType));
            }
        }
        return checkPermission(authentication, resource, privilege, true, logPermission);
    }
42046
public void setAccessControlList(java.util.Collection<Grant> accessControlList) {
        if (accessControlList == null) {
            this.accessControlList = null;
            return;
        }

        this.accessControlList = new java.util.ArrayList<Grant>(accessControlList);
    }