/** * 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); }
if (reason.getCause() instanceof AccessDeniedException2) { cause = (AccessDeniedException2) reason.getCause(); cause.reportAsHeaders(rsp); cause.report(out);
public void handle(ServletRequest request, ServletResponse response, AccessDeniedException cause) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse rsp = (HttpServletResponse) response; rsp.setStatus(HttpServletResponse.SC_FORBIDDEN); req.setAttribute("exception",cause); if (cause instanceof AccessDeniedException2) { ((AccessDeniedException2)cause).reportAsHeaders(rsp); } WebApp.get(Jenkins.getInstance().servletContext).getSomeStapler() .invoke(req,rsp, Jenkins.getInstance(), "/accessDenied"); } }
public void handle(ServletRequest request, ServletResponse response, AccessDeniedException cause) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse rsp = (HttpServletResponse) response; rsp.setStatus(HttpServletResponse.SC_FORBIDDEN); req.setAttribute("exception",cause); if (cause instanceof AccessDeniedException2) { ((AccessDeniedException2)cause).reportAsHeaders(rsp); } WebApp.get(Jenkins.getInstance().servletContext).getSomeStapler() .invoke(req,rsp, Jenkins.getInstance(), "/accessDenied"); } }
public static void checkPermission(@Nonnull AbstractProject<?,?> target, @CheckForNull ManualCondition associatedCondition) { if (!hasPermission(target, associatedCondition)) { // TODO: Give a more accurate error message if the user has Promotion.PROMOTE but is not in the list of approvers. throw new AccessDeniedException2(Jenkins.getAuthentication(), Promotion.PROMOTE); } }
if (reason.getCause() instanceof AccessDeniedException2) { cause = (AccessDeniedException2) reason.getCause(); cause.reportAsHeaders(rsp); cause.report(out);
/** * Short-cut method for checking {@link CredentialsStore#hasPermission(hudson.security.Permission)} * * @param p the permission to check. */ private void checkPermission(Permission p) { if (!store.hasPermission(p)) { throw new AccessDeniedException2(Jenkins.getAuthentication(), p); } }
/** * 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(!hasPermission(a,p)) throw new AccessDeniedException2(a,p); }
/** * Short-cut method for checking {@link CredentialsStore#hasPermission(hudson.security.Permission)} * * @param p the permission to check. */ private void checkPermission(Permission p) { if (!store.hasPermission(p)) { throw new AccessDeniedException2(Jenkins.getAuthentication(), p); } }
/** * 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> * @throws AccessDeniedException2 if the user does not have the {@link Permission} */ protected <AC extends AccessControlled> void checkPermission(AC ac, Permission permission) { if (!hasPermission(ac, permission)) { throw new AccessDeniedException2(Hudson.getAuthentication(), permission); } }
/** * Checks if the current security principal has this permission. * * <p> This is just a convenience function. * * @throws org.acegisecurity.AccessDeniedException if the user doesn't have * the permission. */ public final void checkPermission(Permission p) { Authentication a = HudsonSecurityManager.getAuthentication(); if (!hasPermission(a, p)) { throw new AccessDeniedException2(a, p); } }
/** * Checks if the current security principal has this permission. * * <p> * This is just a convenience function. * * @throws org.acegisecurity.AccessDeniedException * if the user doesn't have the permission. */ public final void checkPermission(Permission p) { Authentication a = Hudson.getAuthentication(); if(!hasPermission(a,p)) throw new AccessDeniedException2(a,p); }
/** * Checks if the current security principal has this permission. * * <p> * This is just a convenience function. * * @throws org.acegisecurity.AccessDeniedException * if the user doesn't have the permission. */ public final void checkPermission(Permission p) { Authentication a = Hudson.getAuthentication(); if(!hasPermission(a,p)) throw new AccessDeniedException2(a,p); }
/** * Helper method to check the specified permission. * * @param p the permission to checl. */ private void checkPermission(Permission p) { if (user.equals(User.current())) { user.checkPermission(p); } else { throw new AccessDeniedException2(Jenkins.getAuthentication(), p); } }
/** * Checks if the current security principal has this permission. * * <p> * This is just a convenience function. * * @throws org.acegisecurity.AccessDeniedException * if the user doesn't have the permission. */ public final void checkPermission(Permission p) { Authentication a = Hudson.getAuthentication(); if(!hasPermission(a,p)) throw new AccessDeniedException2(a,p); }
/** * Helper method to check the specified permission. * * @param p the permission to checl. */ private void checkPermission(Permission p) { if (user.equals(User.current())) { user.checkPermission(p); } else { throw new AccessDeniedException2(Jenkins.getAuthentication(), p); } }
/** * Checks if the current security principal has this permission. * <p> * Note: This is just a convenience function. * </p> * * @throws org.acegisecurity.AccessDeniedException if the user doesn't have the permission. */ public final void checkPermission(@NonNull Permission p) { Authentication a = Jenkins.getAuthentication(); if (!hasPermission(a, p)) { throw new AccessDeniedException2(a, p); } }
/** * Checks if the current security principal has this permission. * <p> * Note: This is just a convenience function. * </p> * * @throws org.acegisecurity.AccessDeniedException if the user doesn't have the permission. */ public final void checkPermission(@NonNull Permission p) { Authentication a = Jenkins.getAuthentication(); if (!hasPermission(a, p)) { throw new AccessDeniedException2(a, p); } }
throw new AccessDeniedException2(Hudson.getAuthentication(), Item.CONFIGURE);