hudson.security.AccessControlled.getACL()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(72)

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

AccessControlled.getACL介绍

[英]Obtains the ACL associated with this object.
[中]获取与此对象关联的ACL。

代码示例

代码示例来源: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

/**
 * Convenient short-cut for {@code getACL().checkPermission(permission)}
 */
default void checkPermission(@Nonnull Permission permission) throws AccessDeniedException {
  getACL().checkPermission(permission);
}

代码示例来源: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

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

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

acl.getACL().checkCreatePermission(parent, descriptor);

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

public synchronized TopLevelItem createProject( TopLevelItemDescriptor type, String name, boolean notify )
    throws IOException {
  acl.checkPermission(Item.CREATE);
  type.checkApplicableIn(parent);
  acl.getACL().checkCreatePermission(parent, type);
  Jenkins.getInstance().getProjectNamingStrategy().checkName(name);
  Items.verifyItemDoesNotAlreadyExist(parent, name, null);
  TopLevelItem item = type.newInstance(parent, name);
  item.onCreatedFromScratch();
  item.save();
  add(item);
  Jenkins.getInstance().rebuildDependencyGraphAsync();
  if (notify)
    ItemListener.fireOnCreated(item);
  return item;
}

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

acl.getACL().checkCreatePermission(parent, src.getDescriptor());
ItemListener.checkBeforeCopy(src, parent);

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

/**
 * Convenient short-cut for {@code getACL().checkPermission(permission)}
 */
default void checkPermission(@Nonnull Permission permission) throws AccessDeniedException {
  getACL().checkPermission(permission);
}

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

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

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

@Override
  public boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission) {
    if (accessControlled.getACL().hasPermission(a, permission)) {
      for (CredentialsStore s : getLocalStores()) {
        if (s.hasPermission(a, permission)) {
          return true;
        }
      }
    }
    return false;
  }
};

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

@Override
  public boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission) {
    if (accessControlled.getACL().hasPermission(a, permission)) {
      for (CredentialsStore s : getLocalStores()) {
        if (s.hasPermission(a, permission)) {
          return true;
        }
      }
    }
    return false;
  }
};

代码示例来源:origin: com.marvelution.jira.plugins/jenkins-jira-plugin

/**
 * Check if the current user has the given {@link Permission} on the {@link AccessControlled} object given
 *
 * @param ac         the {@link AccessControlled} object
 * @param permission the {@link Permission}
 * @param <AC>
 * @return {@code true} if the user has the {@link Permission}, {@code false} otherwise
 */
protected <AC extends AccessControlled> boolean hasPermission(AC ac, Permission permission) {
  Authentication authentication = Hudson.getAuthentication();
  return authentication != Hudson.ANONYMOUS && ac.getACL().hasPermission(authentication, permission);
}

代码示例来源:origin: com.marvelution.jira.plugins/jenkins-jira-plugin

/**
 * Check if the current user has the given {@link Permission} on the {@link AccessControlled} object given
 *
 * @param ac         the {@link AccessControlled} object
 * @param permission the {@link Permission}
 * @param <AC>
 * @return {@code true} if the user has the {@link Permission}, {@code false} otherwise
 */
protected <AC extends AccessControlled> boolean hasPermission(AC ac, Permission permission) {
  return ac.getACL().hasPermission(Hudson.getAuthentication(), permission);
}

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

/**
 * {@inheritDoc}
 */
public @Nonnull
ACL getACL() {
  AccessControlled eventItem = getAccessControlled();
  if (eventItem != null) {
    return eventItem.getACL();
  } else {
    // TODO: Is the right thing to do?
    return Jenkins.getInstance().getAuthorizationStrategy().getRootACL();
  }
}

代码示例来源: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.plugins.workflow/workflow-durable-task-step

/**
 * Something we can use to check abort and read permissions.
 * Normally this will be a {@link Run}.
 * However if things are badly broken, for example if the build has been deleted,
 * then as a fallback we use the Jenkins root.
 * This allows an administrator to clean up dead queue items and executor cells.
 * TODO make {@link FlowExecutionOwner} implement {@link AccessControlled}
 * so that an implementation could fall back to checking {@link Job} permission.
 */
@Override public ACL getACL() {
  try {
    if (!context.isReady()) {
      return Jenkins.getActiveInstance().getACL();
    }
    FlowExecution exec = context.get(FlowExecution.class);
    if (exec == null) {
      return Jenkins.getActiveInstance().getACL();
    }
    Queue.Executable executable = exec.getOwner().getExecutable();
    if (executable instanceof AccessControlled) {
      return ((AccessControlled) executable).getACL();
    } else {
      return Jenkins.getActiveInstance().getACL();
    }
  } catch (Exception x) {
    LOGGER.log(FINE, null, x);
    return Jenkins.getActiveInstance().getACL();
  }
}

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

/**
 * Something we can use to check abort and read permissions.
 * Normally this will be a {@link Run}.
 * However if things are badly broken, for example if the build has been deleted,
 * then as a fallback we use the Jenkins root.
 * This allows an administrator to clean up dead queue items and executor cells.
 * TODO make {@link FlowExecutionOwner} implement {@link AccessControlled}
 * so that an implementation could fall back to checking {@link Job} permission.
 */
@Override public ACL getACL() {
  try {
    if (!context.isReady()) {
      return Jenkins.getInstance().getACL();
    }
    FlowExecution exec = context.get(FlowExecution.class);
    if (exec == null) {
      return Jenkins.getInstance().getACL();
    }
    Queue.Executable executable = exec.getOwner().getExecutable();
    if (executable instanceof AccessControlled) {
      return ((AccessControlled) executable).getACL();
    } else {
      return Jenkins.getInstance().getACL();
    }
  } catch (Exception x) {
    LOGGER.log(FINE, null, x);
    return Jenkins.getInstance().getACL();
  }
}

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

public synchronized TopLevelItem createProject( TopLevelItemDescriptor type, String name, boolean notify )
    throws IOException {
  acl.checkPermission(Item.CREATE);
  type.checkApplicableIn(parent);
  acl.getACL().checkCreatePermission(parent, type);
  Jenkins.getInstance().getProjectNamingStrategy().checkName(name);
  Items.verifyItemDoesNotAlreadyExist(parent, name, null);
  TopLevelItem item = type.newInstance(parent, name);
  item.onCreatedFromScratch();
  item.save();
  add(item);
  Jenkins.getInstance().rebuildDependencyGraphAsync();
  if (notify)
    ItemListener.fireOnCreated(item);
  return item;
}

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

acl.getACL().checkCreatePermission(parent, src.getDescriptor());
ItemListener.checkBeforeCopy(src, parent);

相关文章

微信公众号

最新文章

更多