hudson.security.ACL.hasPermission()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(199)

本文整理了Java中hudson.security.ACL.hasPermission()方法的一些代码示例,展示了ACL.hasPermission()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ACL.hasPermission()方法的具体详情如下:
包路径:hudson.security.ACL
类名称:ACL
方法名:hasPermission

ACL.hasPermission介绍

[英]Checks if the current security principal has this permission.
[中]检查当前安全主体是否具有此权限。

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * Convenient short-cut for {@code getACL().hasPermission(a, permission)}
 * @since 2.92
 */
default boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission) {
  if (a == ACL.SYSTEM) {
    return true;
  }
  return getACL().hasPermission(a, permission);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Convenient short-cut for {@code getACL().hasPermission(permission)}
 */
default boolean hasPermission(@Nonnull Permission permission) {
  return getACL().hasPermission(permission);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Checks if the current security principal has this permission.
 *
 * @return false
 *      if the user doesn't have the permission.
 */
public final boolean hasPermission(@Nonnull Permission p) {
  Authentication a = Jenkins.getAuthentication();
  if (a == SYSTEM) {
    return true;
  }
  return hasPermission(a, p);
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public boolean hasPermission(Authentication a, Permission permission) {
  if(a==SYSTEM)   return true;
  Boolean b = _hasPermission(a,permission);
  if(b!=null) return b;
  if(parent!=null) {
    if(LOGGER.isLoggable(FINE))
      LOGGER.fine("hasPermission("+a+","+permission+") is delegating to parent ACL: "+parent);
    return parent.hasPermission(a,permission);
  }
  // the ultimate default is to reject everything
  return false;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Checks if the current security principal has this permission.
 *
 * <p>
 * This is just a convenience function.
 *
 * @throws AccessDeniedException
 *      if the user doesn't have the permission.
 */
public final void checkPermission(@Nonnull Permission p) {
  Authentication a = Jenkins.getAuthentication();
  if (a == SYSTEM) {
    return;
  }
  if(!hasPermission(a,p))
    throw new AccessDeniedException2(a,p);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Implementation can choose to provide different ACL for different views.
 * This can be used as a basis for more fine-grained access control.
 *
 * <p>
 * The default implementation makes the view visible if any of the items are visible
 * or the view is configurable.
 *
 * @since 1.220
 */
public @Nonnull ACL getACL(final @Nonnull View item) {
  return ACL.lambda((a, permission) -> {
      ACL base = item.getOwner().getACL();
      boolean hasPermission = base.hasPermission(a, permission);
      if (!hasPermission && permission == View.READ) {
        return base.hasPermission(a,View.CONFIGURE) || !item.getItems().isEmpty();
      }
      return hasPermission;
  });
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Checks if the current user (for which we are processing the current request)
 * has the admin access.
 *
 * @deprecated since 2007-12-18.
 *      This method is deprecated when Hudson moved from simple Unix root-like model
 *      of "admin gets to do everything, and others don't have any privilege" to more
 *      complex {@link hudson.security.ACL} and {@link hudson.security.Permission} based scheme.
 *
 *      <p>
 *      For a quick migration, use {@code Hudson.getInstance().getACL().hasPermission(Hudson.ADMINISTER)}
 *      To check if the user has the 'administer' role in Hudson.
 *
 *      <p>
 *      But ideally, your plugin should first identify a suitable {@link hudson.security.Permission} (or create one,
 *      if appropriate), then identify a suitable {@link hudson.security.AccessControlled} object to check its permission
 *      against.
 */
@Deprecated
public static boolean isAdmin() {
  return Jenkins.getInstance().getACL().hasPermission(ADMINISTER);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Is this executor chunk and the given work chunk compatible? Can the latter be run on the former?
 */
public boolean canAccept(WorkChunk c) {
  if (this.size()<c.size())
    return false;   // too small compared towork
  if (c.assignedLabel!=null && !c.assignedLabel.contains(node))
    return false;   // label mismatch
  if (!(Node.SKIP_BUILD_CHECK_ON_FLYWEIGHTS && item.task instanceof Queue.FlyweightTask) && !nodeAcl.hasPermission(item.authenticate(), Computer.BUILD))
    return false;   // tasks don't have a permission to run on this node
  return true;
}

代码示例来源:origin: jenkinsci/jenkins

@Override
@Restricted(NoExternalUse.class)
public Object getTarget() {
  if (!SKIP_PERMISSION_CHECK) {
    if (!getACL().hasPermission(Item.DISCOVER)) {
      return null;
    }
    getACL().checkPermission(Item.READ);
  }
  return this;
}

代码示例来源:origin: jenkinsci/jenkins

@Override
@Nonnull
public ACL getACL() {
  ACL base = Jenkins.get().getAuthorizationStrategy().getACL(this);
  // always allow a non-anonymous user full control of himself.
  return ACL.lambda((a, permission) -> (idStrategy().equals(a.getName(), id) && !(a instanceof AnonymousAuthenticationToken))
      || base.hasPermission(a, permission));
}

代码示例来源:origin: jenkinsci/gitlab-plugin

private void checkPermission(Permission permission) {
  if (((GitLabConnectionConfig) Jenkins.getInstance().getDescriptor(GitLabConnectionConfig.class)).isUseAuthenticatedEndpoint()) {
    if (!Jenkins.getActiveInstance().getACL().hasPermission(authentication, permission)) {
      String message = Messages.AccessDeniedException2_MissingPermission(authentication.getName(), permission.group.title+"/"+permission.name);
      LOGGER.finest("Unauthorized (Did you forget to add API Token to the web hook ?)");
      throw HttpResponses.errorWithoutStack(403, message);
    }
  }
}

代码示例来源:origin: org.jenkins-ci.plugins/credentials

/**
 * {@inheritDoc}
 */
@Override
public boolean hasPermission(@Nonnull Permission permission) {
  return getACL().hasPermission(permission);
}

代码示例来源:origin: org.jenkins-ci.plugins/credentials

/**
 * {@inheritDoc}
 */
@Override
public boolean hasPermission(@Nonnull Permission permission) {
  return getACL().hasPermission(permission);
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Checks if the current security principal has this permission.
 *
 * @return false
 *      if the user doesn't have the permission.
 */
public final boolean hasPermission(@Nonnull Permission p) {
  return hasPermission(Jenkins.getAuthentication(),p);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Short for {@code getACL().hasPermission(p)}
 */
public boolean hasPermission(Permission p) {
  return getACL().hasPermission(p);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

public boolean hasPermission(Authentication a, Permission permission) {
    return (a.getName().equals(id) && !(a instanceof AnonymousAuthenticationToken))
        || base.hasPermission(a, permission);
  }
};

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Short for {@code getACL().hasPermission(p)}
 */
public boolean hasPermission(Permission p) {
  return getACL().hasPermission(p);
}

代码示例来源:origin: org.jenkins-ci.plugins/credentials

@Override
  public boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission) {
    return user.equals(User.get(a.getName())) && user.getACL().hasPermission(a, permission);
  }
};

代码示例来源:origin: org.jenkins-ci.plugins/credentials

/**
 * {@inheritDoc}
 */
@Override
public boolean hasPermission(@NonNull Authentication a, @NonNull Permission permission) {
  // we follow the permissions of Jenkins itself
  return getACL().hasPermission(a, permission);
}

代码示例来源:origin: org.jenkins-ci.plugins/credentials

/**
 * {@inheritDoc}
 */
@Override
public boolean hasPermission(@NonNull Authentication a, @NonNull Permission permission) {
  return getACL().hasPermission(a, permission);
}

相关文章

微信公众号

最新文章

更多