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

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

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

ACL.hasCreatePermission介绍

[英]Checks if the given principal has the permission to create top level items within the specified item group.

Note that #SYSTEM can be passed in as the authentication parameter, in which case you should probably just assume it can create anything anywhere.
[中]检查给定主体是否具有在指定项目组内创建顶级项目的权限。
注意#SYSTEM可以作为身份验证参数传入,在这种情况下,您可能应该假设它可以在任何地方创建任何内容。

代码示例

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

/**
 * Checks if the current security principal has the permission to create views within the specified view group.
 * <p>
 * This is just a convenience function.
 *
 * @param c the container of the item.
 * @param d the descriptor of the view to be created.
 * @throws AccessDeniedException if the user doesn't have the permission.
 * @since 1.607
 */
public final void checkCreatePermission(@Nonnull ViewGroup c,
                    @Nonnull ViewDescriptor d) {
  Authentication a = Jenkins.getAuthentication();
  if (a == SYSTEM) {
    return;
  }
  if (!hasCreatePermission(a, c, d)) {
    throw new AccessDeniedException(Messages.AccessDeniedException2_MissingPermission(a.getName(),
        View.CREATE.group.title + "/" + View.CREATE.name + View.CREATE + "/" + d.getDisplayName()));
  }
}

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

/**
 * Returns all the registered {@link TopLevelItemDescriptor}s that the specified security principal is allowed to
 * create within the specified item group.
 *
 * @since 1.607
 */
public static List<TopLevelItemDescriptor> all(Authentication a, ItemGroup c) {
  List<TopLevelItemDescriptor> result = new ArrayList<TopLevelItemDescriptor>();
  ACL acl;
  if (c instanceof AccessControlled) {
    acl = ((AccessControlled) c).getACL();
  } else {
    // fall back to root
    acl = Jenkins.getInstance().getACL();
  }
  for (TopLevelItemDescriptor d: all()) {
    if (acl.hasCreatePermission(a, c, d) && d.isApplicableIn(c)) {
      result.add(d);
    }
  }
  return result;
}

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

/**
 * Checks if the current security principal has the permission to create top level items within the specified
 * item group.
 * <p>
 * This is just a convenience function.
 * @param c the container of the item.
 * @param d the descriptor of the item to be created.
 * @throws AccessDeniedException
 *      if the user doesn't have the permission.
 * @since 1.607
 */
public final void checkCreatePermission(@Nonnull ItemGroup c,
                    @Nonnull TopLevelItemDescriptor d) {
  Authentication a = Jenkins.getAuthentication();
  if (a == SYSTEM) {
    return;
  }
  if (!hasCreatePermission(a, c, d)) {
    throw new AccessDeniedException(Messages.AccessDeniedException2_MissingPermission(a.getName(),
        Item.CREATE.group.title+"/"+Item.CREATE.name + Item.CREATE + "/" + d.getDisplayName()));
  }
}
/**

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

/**
 * Returns the {@link ViewDescriptor} instances that can be instantiated for the {@link ViewGroup} in the current
 * {@link StaplerRequest}.
 * <p>
 * <strong>NOTE: Historically this method is only ever called from a {@link StaplerRequest}</strong>
 * @return the list of instantiable {@link ViewDescriptor} instances for the current {@link StaplerRequest}
 */
@Nonnull
public static List<ViewDescriptor> allInstantiable() {
  List<ViewDescriptor> r = new ArrayList<ViewDescriptor>();
  StaplerRequest request = Stapler.getCurrentRequest();
  if (request == null) {
    throw new IllegalStateException("This method can only be invoked from a stapler request");
  }
  ViewGroup owner = request.findAncestorObject(ViewGroup.class);
  if (owner == null) {
    throw new IllegalStateException("This method can only be invoked from a request with a ViewGroup ancestor");
  }
  for (ViewDescriptor d : DescriptorVisibilityFilter.apply(owner, all())) {
    if (d.isApplicableIn(owner) && d.isInstantiable()
        && owner.getACL().hasCreatePermission(Jenkins.getAuthentication(), owner, d)) {
      r.add(d);
    }
  }
  return r;
}

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

success = acl.getACL().hasCreatePermission(Jenkins.getAuthentication(), parent, result.getDescriptor())
  && result.getDescriptor().isApplicableIn(parent);

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

/**
 * Checks if the current security principal has the permission to create views within the specified view group.
 * <p>
 * This is just a convenience function.
 *
 * @param c the container of the item.
 * @param d the descriptor of the view to be created.
 * @throws AccessDeniedException if the user doesn't have the permission.
 * @since 1.607
 */
public final void checkCreatePermission(@Nonnull ViewGroup c,
                    @Nonnull ViewDescriptor d) {
  Authentication a = Jenkins.getAuthentication();
  if (!hasCreatePermission(a, c, d)) {
    throw new AccessDeniedException(Messages.AccessDeniedException2_MissingPermission(a.getName(),
        View.CREATE.group.title + "/" + View.CREATE.name + View.CREATE + "/" + d.getDisplayName()));
  }
}

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

/**
 * Checks if the current security principal has the permission to create top level items within the specified
 * item group.
 * <p>
 * This is just a convenience function.
 * @param c the container of the item.
 * @param d the descriptor of the item to be created.
 * @throws AccessDeniedException
 *      if the user doesn't have the permission.
 * @since 1.607
 */
public final void checkCreatePermission(@Nonnull ItemGroup c,
                    @Nonnull TopLevelItemDescriptor d) {
  Authentication a = Jenkins.getAuthentication();
  if (!hasCreatePermission(a, c, d)) {
    throw new AccessDeniedException(Messages.AccessDeniedException2_MissingPermission(a.getName(),
        Item.CREATE.group.title+"/"+Item.CREATE.name + Item.CREATE + "/" + d.getDisplayName()));
  }
}
/**

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

/**
 * Returns all the registered {@link TopLevelItemDescriptor}s that the specified security principal is allowed to
 * create within the specified item group.
 *
 * @since 1.607
 */
public static List<TopLevelItemDescriptor> all(Authentication a, ItemGroup c) {
  List<TopLevelItemDescriptor> result = new ArrayList<TopLevelItemDescriptor>();
  ACL acl;
  if (c instanceof AccessControlled) {
    acl = ((AccessControlled) c).getACL();
  } else {
    // fall back to root
    acl = Jenkins.getInstance().getACL();
  }
  for (TopLevelItemDescriptor d: all()) {
    if (acl.hasCreatePermission(a, c, d) && d.isApplicableIn(c)) {
      result.add(d);
    }
  }
  return result;
}

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

/**
 * Returns the {@link ViewDescriptor} instances that can be instantiated for the {@link ViewGroup} in the current
 * {@link StaplerRequest}.
 * <p>
 * <strong>NOTE: Historically this method is only ever called from a {@link StaplerRequest}</strong>
 * @return the list of instantiable {@link ViewDescriptor} instances for the current {@link StaplerRequest}
 */
@Nonnull
public static List<ViewDescriptor> allInstantiable() {
  List<ViewDescriptor> r = new ArrayList<ViewDescriptor>();
  StaplerRequest request = Stapler.getCurrentRequest();
  if (request == null) {
    throw new IllegalStateException("This method can only be invoked from a stapler request");
  }
  ViewGroup owner = request.findAncestorObject(ViewGroup.class);
  if (owner == null) {
    throw new IllegalStateException("This method can only be invoked from a request with a ViewGroup ancestor");
  }
  for (ViewDescriptor d : DescriptorVisibilityFilter.apply(owner, all())) {
    if (d.isApplicableIn(owner) && d.isInstantiable()
        && owner.getACL().hasCreatePermission(Jenkins.getAuthentication(), owner, d)) {
      r.add(d);
    }
  }
  return r;
}

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

/**
 * Returns true if the specified descriptor type is allowed for this container.
 *
 * @param tid the type of child item.
 * @return {@code true} if it can be added.
 */
public boolean isAllowedChildDescriptor(TopLevelItemDescriptor tid) {
  for (FolderProperty<?> p : getProperties().getAll(FolderProperty.class)) {
    if (!p.allowsParentToCreate(tid)) {
      return false;
    }
  }
  if (!getACL().hasCreatePermission(Jenkins.getAuthentication(), this, tid)) {
    return false;
  }
  return tid.isApplicableIn(this);
}

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

/**
 * Returns true if the specified descriptor type is allowed for this container.
 *
 * @param tid the type of child item.
 * @return {@code true} if it can be added.
 */
public boolean isAllowedChildDescriptor(TopLevelItemDescriptor tid) {
  for (FolderProperty<?> p : getProperties().getAll(FolderProperty.class)) {
    if (!p.allowsParentToCreate(tid)) {
      return false;
    }
  }
  if (!getACL().hasCreatePermission(Jenkins.getAuthentication(), this, tid)) {
    return false;
  }
  return tid.isApplicableIn(this);
}

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

success = acl.getACL().hasCreatePermission(Jenkins.getAuthentication(), parent, result.getDescriptor())
  && result.getDescriptor().isApplicableIn(parent);

相关文章