hudson.Functions.checkPermission()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(125)

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

Functions.checkPermission介绍

[英]This version is so that the 'checkPermission' on layout.jelly degrades gracefully if "it" is not an AccessControlled object. Otherwise it will perform no check and that problem is hard to notice.
[中]此版本允许布局上的“checkPermission”。如果“jelly”不是AccessControl对象,它会优雅地退化。否则它将不执行任何检查,并且很难注意到该问题。

代码示例

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

public static void checkPermission(Permission permission) throws IOException, ServletException {
  checkPermission(Jenkins.getInstance(),permission);
}

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

public static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission) throws IOException, ServletException {
  // this is legacy --- all views should be eventually converted to
  // the permission based model.
  if(required!=null && !Hudson.adminCheck(req, rsp)) {
    // check failed. commit the FORBIDDEN response, then abort.
    rsp.setStatus(HttpServletResponse.SC_FORBIDDEN);
    rsp.getOutputStream().close();
    throw new ServletException("Unauthorized access");
  }
  // make sure the user owns the necessary permission to access this page.
  if(permission!=null)
    checkPermission(permission);
}

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

/**
 * This version is so that the 'checkPermission' on {@code layout.jelly}
 * degrades gracefully if "it" is not an {@link AccessControlled} object.
 * Otherwise it will perform no check and that problem is hard to notice.
 */
public static void checkPermission(Object object, Permission permission) throws IOException, ServletException {
  if (permission == null)
    return;
  
  if (object instanceof AccessControlled)
    checkPermission((AccessControlled) object,permission);
  else {
    List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors();
    for(Ancestor anc : Iterators.reverse(ancs)) {
      Object o = anc.getObject();
      if (o instanceof AccessControlled) {
        checkPermission((AccessControlled) o,permission);
        return;
      }
    }
    checkPermission(Jenkins.getInstance(),permission);
  }
}

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

public static void checkPermission(Permission permission) throws IOException, ServletException {
  checkPermission(Jenkins.getInstance(),permission);
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

public static void checkPermission(Permission permission) throws IOException, ServletException {
  checkPermission(Hudson.getInstance(),permission);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

public static void checkPermission(Permission permission) throws IOException, ServletException {
  checkPermission(Hudson.getInstance(),permission);
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

public static void checkPermission(Permission permission) throws IOException, ServletException {
  checkPermission(Hudson.getInstance(), permission);
}

代码示例来源:origin: hudson/hudson-2.x

public static void checkPermission(Permission permission) throws IOException, ServletException {
  checkPermission(Hudson.getInstance(),permission);
}

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

public static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission) throws IOException, ServletException {
  // this is legacy --- all views should be eventually converted to
  // the permission based model.
  if(required!=null && !Hudson.adminCheck(req, rsp)) {
    // check failed. commit the FORBIDDEN response, then abort.
    rsp.setStatus(HttpServletResponse.SC_FORBIDDEN);
    rsp.getOutputStream().close();
    throw new ServletException("Unauthorized access");
  }
  // make sure the user owns the necessary permission to access this page.
  if(permission!=null)
    checkPermission(permission);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

public static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission) throws IOException, ServletException {
  // this is legacy --- all views should be eventually converted to
  // the permission based model.
  if(required!=null && !Hudson.adminCheck(req,rsp)) {
    // check failed. commit the FORBIDDEN response, then abort.
    rsp.setStatus(HttpServletResponse.SC_FORBIDDEN);
    rsp.getOutputStream().close();
    throw new ServletException("Unauthorized access");
  }
  // make sure the user owns the necessary permission to access this page.
  if(permission!=null)
    checkPermission(permission);
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

public static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission) throws IOException, ServletException {
  // this is legacy --- all views should be eventually converted to
  // the permission based model.
  if(required!=null && !Hudson.adminCheck(req,rsp)) {
    // check failed. commit the FORBIDDEN response, then abort.
    rsp.setStatus(HttpServletResponse.SC_FORBIDDEN);
    rsp.getOutputStream().close();
    throw new ServletException("Unauthorized access");
  }
  // make sure the user owns the necessary permission to access this page.
  if(permission!=null)
    checkPermission(permission);
}

代码示例来源:origin: hudson/hudson-2.x

public static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission) throws IOException, ServletException {
  // this is legacy --- all views should be eventually converted to
  // the permission based model.
  if(required!=null && !Hudson.adminCheck(req,rsp)) {
    // check failed. commit the FORBIDDEN response, then abort.
    rsp.setStatus(HttpServletResponse.SC_FORBIDDEN);
    rsp.getOutputStream().close();
    throw new ServletException("Unauthorized access");
  }
  // make sure the user owns the necessary permission to access this page.
  if(permission!=null)
    checkPermission(permission);
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

public static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission) throws IOException, ServletException {
  // this is legacy --- all views should be eventually converted to
  // the permission based model.
  if (required != null && !Hudson.adminCheck(req, rsp)) {
    // check failed. commit the FORBIDDEN response, then abort.
    rsp.setStatus(HttpServletResponse.SC_FORBIDDEN);
    rsp.getOutputStream().close();
    throw new ServletException("Unauthorized access");
  }
  // make sure the user owns the necessary permission to access this page.
  if (permission != null) {
    checkPermission(permission);
  }
}

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

/**
 * This version is so that the 'checkPermission' on <tt>layout.jelly</tt>
 * degrades gracefully if "it" is not an {@link AccessControlled} object.
 * Otherwise it will perform no check and that problem is hard to notice.
 */
public static void checkPermission(Object object, Permission permission) throws IOException, ServletException {
  if (permission == null)
    return;
  
  if (object instanceof AccessControlled)
    checkPermission((AccessControlled) object,permission);
  else {
    List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors();
    for(Ancestor anc : Iterators.reverse(ancs)) {
      Object o = anc.getObject();
      if (o instanceof AccessControlled) {
        checkPermission((AccessControlled) o,permission);
        return;
      }
    }
    checkPermission(Jenkins.getInstance(),permission);
  }
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * This version is so that the 'checkPermission' on <tt>layout.jelly</tt>
 * degrades gracefully if "it" is not an {@link AccessControlled} object.
 * Otherwise it will perform no check and that problem is hard to notice.
 */
public static void checkPermission(Object object, Permission permission) throws IOException, ServletException {
  if (permission == null)
    return;
  if (object instanceof AccessControlled)
    checkPermission((AccessControlled) object,permission);
  else {
    List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors();
    for(Ancestor anc : Iterators.reverse(ancs)) {
      Object o = anc.getObject();
      if (o instanceof AccessControlled) {
        checkPermission((AccessControlled) o,permission);
        return;
      }
    }
    checkPermission(Hudson.getInstance(),permission);
  }
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * This version is so that the 'checkPermission' on <tt>layout.jelly</tt>
 * degrades gracefully if "it" is not an {@link AccessControlled} object.
 * Otherwise it will perform no check and that problem is hard to notice.
 */
public static void checkPermission(Object object, Permission permission) throws IOException, ServletException {
  if (permission == null)
    return;
  if (object instanceof AccessControlled)
    checkPermission((AccessControlled) object,permission);
  else {
    List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors();
    for(Ancestor anc : Iterators.reverse(ancs)) {
      Object o = anc.getObject();
      if (o instanceof AccessControlled) {
        checkPermission((AccessControlled) o,permission);
        return;
      }
    }
    checkPermission(Hudson.getInstance(),permission);
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * This version is so that the 'checkPermission' on <tt>layout.jelly</tt>
 * degrades gracefully if "it" is not an {@link AccessControlled} object.
 * Otherwise it will perform no check and that problem is hard to notice.
 */
public static void checkPermission(Object object, Permission permission) throws IOException, ServletException {
  if (permission == null)
    return;
  
  if (object instanceof AccessControlled)
    checkPermission((AccessControlled) object,permission);
  else {
    List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors();
    for(Ancestor anc : Iterators.reverse(ancs)) {
      Object o = anc.getObject();
      if (o instanceof AccessControlled) {
        checkPermission((AccessControlled) o,permission);
        return;
      }
    }
    checkPermission(Hudson.getInstance(),permission);
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * This version is so that the 'checkPermission' on <tt>layout.jelly</tt>
 * degrades gracefully if "it" is not an {@link AccessControlled} object.
 * Otherwise it will perform no check and that problem is hard to notice.
 */
public static void checkPermission(Object object, Permission permission) throws IOException, ServletException {
  if (permission == null) {
    return;
  }
  if (object instanceof AccessControlled) {
    checkPermission((AccessControlled) object, permission);
  } else {
    List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors();
    for (Ancestor anc : Iterators.reverse(ancs)) {
      Object o = anc.getObject();
      if (o instanceof AccessControlled) {
        checkPermission((AccessControlled) o, permission);
        return;
      }
    }
    checkPermission(Hudson.getInstance(), permission);
  }
}

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

Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
  Functions.checkPermission(Jenkins.ADMINISTER);

相关文章

微信公众号

最新文章

更多