4141import hudson .model .Describable ;
4242import hudson .model .Descriptor ;
4343import hudson .model .DescriptorVisibilityFilter ;
44- import hudson .model .Hudson ;
4544import hudson .model .Item ;
4645import hudson .model .ItemGroup ;
4746import hudson .model .Items ;
9796import hudson .views .MyViewsTabBar ;
9897import hudson .views .ViewsTabBar ;
9998import hudson .widgets .RenderOnDemandClosure ;
100- import io .jenkins .servlet .ServletExceptionWrapper ;
10199import io .jenkins .servlet .http .CookieWrapper ;
102100import io .jenkins .servlet .http .HttpServletRequestWrapper ;
103101import io .jenkins .servlet .http .HttpServletResponseWrapper ;
104- import jakarta .servlet .ServletException ;
105102import jakarta .servlet .http .Cookie ;
106103import jakarta .servlet .http .HttpServletRequest ;
107104import jakarta .servlet .http .HttpServletResponse ;
190187import org .kohsuke .stapler .Stapler ;
191188import org .kohsuke .stapler .StaplerRequest ;
192189import org .kohsuke .stapler .StaplerRequest2 ;
193- import org .kohsuke .stapler .StaplerResponse ;
194- import org .kohsuke .stapler .StaplerResponse2 ;
195190import org .springframework .security .access .AccessDeniedException ;
196191
197192/**
@@ -921,11 +916,11 @@ public static String htmlAttributeEscape(String text) {
921916 return buf .toString ();
922917 }
923918
924- public static void checkPermission (Permission permission ) throws IOException , ServletException {
919+ public static void checkPermission (Permission permission ) {
925920 checkPermission (Jenkins .get (), permission );
926921 }
927922
928- public static void checkPermission (AccessControlled object , Permission permission ) throws IOException , ServletException {
923+ public static void checkPermission (AccessControlled object , Permission permission ) {
929924 if (permission != null ) {
930925 object .checkPermission (permission );
931926 }
@@ -936,7 +931,7 @@ public static void checkPermission(AccessControlled object, Permission permissio
936931 * degrades gracefully if "it" is not an {@link AccessControlled} object.
937932 * Otherwise it will perform no check and that problem is hard to notice.
938933 */
939- public static void checkPermission (Object object , Permission permission ) throws IOException , ServletException {
934+ public static void checkPermission (Object object , Permission permission ) {
940935 if (permission == null )
941936 return ;
942937
@@ -961,15 +956,15 @@ public static void checkPermission(Object object, Permission permission) throws
961956 * @param permission
962957 * If null, returns true. This defaulting is convenient in making the use of this method terse.
963958 */
964- public static boolean hasPermission (Permission permission ) throws IOException , ServletException {
959+ public static boolean hasPermission (Permission permission ) {
965960 return hasPermission (Jenkins .get (), permission );
966961 }
967962
968963 /**
969964 * This version is so that the 'hasPermission' can degrade gracefully
970965 * if "it" is not an {@link AccessControlled} object.
971966 */
972- public static boolean hasPermission (Object object , Permission permission ) throws IOException , ServletException {
967+ public static boolean hasPermission (Object object , Permission permission ) {
973968 if (permission == null )
974969 return true ;
975970 if (object instanceof AccessControlled )
@@ -986,36 +981,6 @@ public static boolean hasPermission(Object object, Permission permission) throws
986981 }
987982 }
988983
989- /**
990- * @since 2.475
991- */
992- public static void adminCheck (StaplerRequest2 req , StaplerResponse2 rsp , Object required , Permission permission ) throws IOException , ServletException {
993- // this is legacy --- all views should be eventually converted to
994- // the permission based model.
995- if (required != null && !Hudson .adminCheck (StaplerRequest .fromStaplerRequest2 (req ), StaplerResponse .fromStaplerResponse2 (rsp ))) {
996- // check failed. commit the FORBIDDEN response, then abort.
997- rsp .setStatus (HttpServletResponse .SC_FORBIDDEN );
998- rsp .getOutputStream ().close ();
999- throw new ServletException ("Unauthorized access" );
1000- }
1001-
1002- // make sure the user owns the necessary permission to access this page.
1003- if (permission != null )
1004- checkPermission (permission );
1005- }
1006-
1007- /**
1008- * @deprecated use {@link #adminCheck(StaplerRequest2, StaplerResponse2, Object, Permission)}
1009- */
1010- @ Deprecated
1011- public static void adminCheck (StaplerRequest req , StaplerResponse rsp , Object required , Permission permission ) throws IOException , javax .servlet .ServletException {
1012- try {
1013- adminCheck (StaplerRequest .toStaplerRequest2 (req ), StaplerResponse .toStaplerResponse2 (rsp ), required , permission );
1014- } catch (ServletException e ) {
1015- throw ServletExceptionWrapper .fromJakartaServletException (e );
1016- }
1017- }
1018-
1019984 /**
1020985 * Infers the hudson installation URL from the given request.
1021986 *
@@ -1298,7 +1263,7 @@ public static boolean hasAnyPermission(AccessControlled ac, Permission[] permiss
12981263 *
12991264 * @since 2.238
13001265 */
1301- public static boolean hasAnyPermission (Object object , Permission [] permissions ) throws IOException , ServletException {
1266+ public static boolean hasAnyPermission (Object object , Permission [] permissions ) {
13021267 if (permissions == null || permissions .length == 0 ) {
13031268 return true ;
13041269 }
@@ -1336,7 +1301,7 @@ public static void checkAnyPermission(AccessControlled ac, Permission[] permissi
13361301 * degrades gracefully if "it" is not an {@link AccessControlled} object.
13371302 * Otherwise it will perform no check and that problem is hard to notice.
13381303 */
1339- public static void checkAnyPermission (Object object , Permission [] permissions ) throws IOException , ServletException {
1304+ public static void checkAnyPermission (Object object , Permission [] permissions ) {
13401305 if (permissions == null || permissions .length == 0 ) {
13411306 return ;
13421307 }
0 commit comments