org.acegisecurity.AccessDeniedException.<init>()方法的使用及代码示例

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

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

AccessDeniedException.<init>介绍

[英]Constructs an AccessDeniedException with the specified message.
[中]

代码示例

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

/**
 * Exposes the current user to {@code /me} URL.
 */
public User getMe() {
  User u = User.current();
  if (u == null)
    throw new AccessDeniedException("/me is not available when not logged in");
  return u;
}

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

/**
 * {@inheritDoc}.
 *
 * Note that the look up is case-insensitive.
 */
@Override public TopLevelItem getItem(String name) throws AccessDeniedException {
  if (name==null)    return null;
  TopLevelItem item = items.get(name);
  if (item==null)
    return null;
  if (!item.hasPermission(Item.READ)) {
    if (item.hasPermission(Item.DISCOVER)) {
      throw new AccessDeniedException("Please login to access job " + name);
    }
    return null;
  }
  return item;
}

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

/**
 * Checks if this top level item is applicable within the specified item group.
 * <p>
 * This is just a convenience function.
 * @since 1.607
 */
public final void checkApplicableIn(ItemGroup parent) {
  if (!isApplicableIn(parent)) {
    throw new AccessDeniedException(
        Messages.TopLevelItemDescriptor_NotApplicableIn(getDisplayName(), parent.getFullDisplayName()));
  }
}

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

public static void checkPostBackAccess() throws AccessDeniedException {
  if (!get().isUseBrowser()) {
    throw new AccessDeniedException("browser-based download disabled");
  }
  Jenkins.get().checkPermission(Jenkins.ADMINISTER);
}

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

/**
 * 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

/**
 * Runs the validation code.
 */
public final void process() throws IOException, ServletException {
  if(permission!=null)
    try {
      if(subject==null)
        throw new AccessDeniedException("No subject");
      subject.checkPermission(permission);
    } catch (AccessDeniedException e) {
      // if the user has hudson-wide admin permission, all checks are allowed
      // this is to protect Hudson administrator from broken ACL/SecurityRealm implementation/configuration.
      if(!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER))
        throw e;
    }
  check();
}

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

@Override
protected int run() throws Exception {
  if (!Jenkins.getActiveInstance().hasPermission(Jenkins.READ)) {
    throw new AccessDeniedException("You must authenticate to access this Jenkins.\n"
        + CLI.usage());
  }
  if (command != null)
    return showCommandDetails();
  showAllCommands();
  return 0;
}

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

@Restricted(DoNotUse.class) // only for Stapler export
public Api getApi() throws AccessDeniedException {
  if (task instanceof AccessControlled) {
    AccessControlled ac = (AccessControlled) task;
    if (!ac.hasPermission(hudson.model.Item.DISCOVER)) {
      return null; // same as getItem(long) returning null (details are printed only in case of -Dstapler.trace=true)
    } else if (!ac.hasPermission(hudson.model.Item.READ)) {
      throw new AccessDeniedException("Please log in to access " + task.getUrl()); // like Jenkins.getItem
    } else { // have READ
      return new Api(this);
    }
  } else { // err on the safe side
    return null;
  }
}

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

public static void checkPermission(Job<?,?> project, BuildAuthorizationToken token, StaplerRequest req, StaplerResponse rsp) throws IOException {
  if (!Jenkins.getInstance().isUseSecurity())
    return;    // everyone is authorized
  if(token!=null && token.token != null) {
    //check the provided token
    String providedToken = req.getParameter("token");
    if (providedToken != null && providedToken.equals(token.token))
      return;
    if (providedToken != null)
      throw new AccessDeniedException(Messages.BuildAuthorizationToken_InvalidTokenProvided());
  }
  project.checkPermission(Item.BUILD);
  if (req.getMethod().equals("POST")) {
    return;
  }
  if (req.getAttribute(ApiTokenProperty.class.getName()) instanceof User) {
    return;
  }
  rsp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
  rsp.addHeader("Allow", "POST");
  throw HttpResponses.forwardToView(project, "requirePOST.jelly");
}

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

if (Secret.decrypt(matcher.group(1)) != null) {
  throw new AccessDeniedException(Messages.ItemGroupMixIn_may_not_copy_as_it_contains_secrets_and_(src.getFullName(), Jenkins.getAuthentication().getName(), Item.PERMISSIONS.title, Item.EXTENDED_READ.name, Item.CONFIGURE.name));

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

/**
 * Exposes the current user to <tt>/me</tt> URL.
 */
public User getMe() {
  User u = User.current();
  if (u == null)
    throw new AccessDeniedException("/me is not available when not logged in");
  return u;
}

代码示例来源:origin: org.acegisecurity/acegi-security

protected final void checkAllowIfAllAbstainDecisions() {
  if (!this.isAllowIfAllAbstainDecisions()) {
    throw new AccessDeniedException(messages.getMessage("AbstractAccessDecisionManager.accessDenied",
        "Access is denied"));
  }
}

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

public void checkAccessKeyThreadDump(@CheckForNull String accessKey) {
  if (!hasAccessKeyThreadDump(accessKey)) {
    throw new AccessDeniedException(Messages.MetricsAccessKey_invalidAccessKey(accessKey));
  }
}

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

public void checkAccessKeyMetrics(@CheckForNull String accessKey) {
  if (!hasAccessKeyMetrics(accessKey)) {
    throw new AccessDeniedException(Messages.MetricsAccessKey_invalidAccessKey(accessKey));
  }
}

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

public void checkAccessKeyPing(@CheckForNull String accessKey) {
  if (!hasAccessKeyPing(accessKey)) {
    throw new AccessDeniedException(Messages.MetricsAccessKey_invalidAccessKey(accessKey));
  }
}

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

public void checkAccessKeyHealthCheck(@CheckForNull String accessKey) {
  if (!hasAccessKeyHealthCheck(accessKey)) {
    throw new AccessDeniedException(Messages.MetricsAccessKey_invalidAccessKey(accessKey));
  }
}

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

/**
 * Checks if this top level item is applicable within the specified item group.
 * <p>
 * This is just a convenience function.
 * @since 1.607
 */
public final void checkApplicableIn(ItemGroup parent) {
  if (!isApplicableIn(parent)) {
    throw new AccessDeniedException(
        Messages.TopLevelItemDescriptor_NotApplicableIn(getDisplayName(), parent.getFullDisplayName()));
  }
}

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

public static void checkPostBackAccess() throws AccessDeniedException {
  if (!get().isUseBrowser()) {
    throw new AccessDeniedException("browser-based download disabled");
  }
  Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
}

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

@Override
protected int run() throws Exception {
  if (!Jenkins.getActiveInstance().hasPermission(Jenkins.READ)) {
    throw new AccessDeniedException("You must authenticate to access this Jenkins.\n"
        + hudson.cli.client.Messages.CLI_Usage());
  }
  if (command != null)
    return showCommandDetails();
  showAllCommands();
  return 0;
}

相关文章

微信公众号

最新文章

更多