jenkins.model.Jenkins.hasPermission()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(268)

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

Jenkins.hasPermission介绍

暂无

代码示例

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

  1. public String getIconFileName() {
  2. if (Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER))
  3. return "gear2.png";
  4. else
  5. return null;
  6. }

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

  1. /**
  2. * Gets the user of the given name.
  3. *
  4. * @return the user of the given name (which may or may not be an id), if that person exists; else null
  5. * @see User#get(String,boolean)
  6. * @see User#getById(String, boolean)
  7. */
  8. public @CheckForNull User getUser(String name) {
  9. return User.get(name, User.ALLOW_USER_CREATION_VIA_URL && hasPermission(ADMINISTER));
  10. }

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

  1. /**
  2. * Returns true if the configuration of this subsystem becomes relevant.
  3. * Unless this option is relevant, we don't let users choose this.
  4. */
  5. public boolean isRelevant() {
  6. return jenkins.hasPermission(Jenkins.RUN_SCRIPTS) && jenkins.isUseSecurity();
  7. }
  8. }

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

  1. public boolean hasPermission(Permission permission) {
  2. return Jenkins.getInstance().hasPermission(permission);
  3. }

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

  1. @Override
  2. protected FullDuplexHttpService createService(StaplerRequest req, UUID uuid) throws IOException {
  3. // do not require any permission to establish a CLI connection
  4. // the actual authentication for the connecting Channel is done by CLICommand
  5. return new FullDuplexHttpChannel(uuid, !Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
  6. @SuppressWarnings("deprecation")
  7. @Override
  8. protected void main(Channel channel) throws IOException, InterruptedException {
  9. // capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator()
  10. channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, Jenkins.getAuthentication());
  11. channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl(channel));
  12. }
  13. };
  14. }
  15. }

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

  1. /**
  2. * Checks if the current user has permission to see this pointer.
  3. * @return {@code true} if the job exists and user has {@link Item#READ} permissions
  4. * or if the current user has {@link Jenkins#ADMINISTER} permissions.
  5. * If the job exists, but the current user has no permission to discover it,
  6. * {@code false} will be returned.
  7. * If the job has been deleted and the user has no {@link Jenkins#ADMINISTER} permissions,
  8. * it also returns {@code false} in order to avoid the job existence fact exposure.
  9. */
  10. private boolean hasPermissionToDiscoverBuild() {
  11. // We expose the data to Jenkins administrators in order to
  12. // let them manage the data for deleted jobs (also works for SYSTEM)
  13. final Jenkins instance = Jenkins.getInstance();
  14. if (instance.hasPermission(Jenkins.ADMINISTER)) {
  15. return true;
  16. }
  17. return canDiscoverItem(name);
  18. }

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

  1. @Exported(name="usage")
  2. public @Nonnull List<RangeItem> _getUsages() {
  3. List<RangeItem> r = new ArrayList<RangeItem>();
  4. final Jenkins instance = Jenkins.getInstance();
  5. for (Entry<String, RangeSet> e : usages.entrySet()) {
  6. final String itemName = e.getKey();
  7. if (instance.hasPermission(Jenkins.ADMINISTER) || canDiscoverItem(itemName)) {
  8. r.add(new RangeItem(itemName, e.getValue()));
  9. }
  10. }
  11. return r;
  12. }

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

  1. @Override
  2. @Restricted(NoExternalUse.class)
  3. public Object getTarget() {
  4. if (!SKIP_PERMISSION_CHECK) {
  5. if (!Jenkins.get().hasPermission(Jenkins.READ)) {
  6. return null;
  7. }
  8. }
  9. return this;
  10. }

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

  1. @Override
  2. public String getColumnCaption() {
  3. // Hide this column from non-admins
  4. return Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER) ? super.getColumnCaption() : null;
  5. }

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

  1. @Override
  2. public String getColumnCaption() {
  3. // Hide this column from non-admins
  4. return Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER) ? super.getColumnCaption() : null;
  5. }

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

  1. @Override
  2. public String getColumnCaption() {
  3. // Hide this column from non-admins
  4. return Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER) ? super.getColumnCaption() : null;
  5. }

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

  1. /**
  2. * Do we need to show the upgrade wizard prompt?
  3. */
  4. public boolean isDue() {
  5. if (isUpToDate)
  6. return false;
  7. // only admin users should see this
  8. if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER))
  9. return false;
  10. // only show when Jenkins is fully up & running
  11. WebApp wa = WebApp.getCurrent();
  12. if (wa==null || !(wa.getApp() instanceof Jenkins))
  13. return false;
  14. return System.currentTimeMillis() > SetupWizard.getUpdateStateFile().lastModified();
  15. }

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

  1. public static boolean usePostBack() {
  2. return get().isUseBrowser() && Jenkins.get().hasPermission(Jenkins.ADMINISTER);
  3. }

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

  1. if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
  2. return Collections.emptyList();

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

  1. /**
  2. * Runs the validation code.
  3. */
  4. public final void process() throws IOException, ServletException {
  5. if(permission!=null)
  6. try {
  7. if(subject==null)
  8. throw new AccessDeniedException("No subject");
  9. subject.checkPermission(permission);
  10. } catch (AccessDeniedException e) {
  11. // if the user has hudson-wide admin permission, all checks are allowed
  12. // this is to protect Hudson administrator from broken ACL/SecurityRealm implementation/configuration.
  13. if(!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER))
  14. throw e;
  15. }
  16. check();
  17. }

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

  1. @Override
  2. protected int run() throws Exception {
  3. if (!Jenkins.getActiveInstance().hasPermission(Jenkins.READ)) {
  4. throw new AccessDeniedException("You must authenticate to access this Jenkins.\n"
  5. + CLI.usage());
  6. }
  7. if (command != null)
  8. return showCommandDetails();
  9. showAllCommands();
  10. return 0;
  11. }

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

  1. /**
  2. * Only for legacy token
  3. */
  4. private boolean hasPermissionToSeeToken() {
  5. // Administrators can do whatever they want
  6. if (SHOW_LEGACY_TOKEN_TO_ADMINS && Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
  7. return true;
  8. }
  9. User current = User.current();
  10. if (current == null) { // Anonymous
  11. return false;
  12. }
  13. // SYSTEM user is always eligible to see tokens
  14. if (Jenkins.getAuthentication() == ACL.SYSTEM) {
  15. return true;
  16. }
  17. return User.idStrategy().equals(user.getId(), current.getId());
  18. }

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

  1. /**
  2. * This version is so that the 'hasPermission' can degrade gracefully
  3. * if "it" is not an {@link AccessControlled} object.
  4. */
  5. public static boolean hasPermission(Object object, Permission permission) throws IOException, ServletException {
  6. if (permission == null)
  7. return true;
  8. if (object instanceof AccessControlled)
  9. return ((AccessControlled)object).hasPermission(permission);
  10. else {
  11. List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors();
  12. for(Ancestor anc : Iterators.reverse(ancs)) {
  13. Object o = anc.getObject();
  14. if (o instanceof AccessControlled) {
  15. return ((AccessControlled)o).hasPermission(permission);
  16. }
  17. }
  18. return Jenkins.getInstance().hasPermission(permission);
  19. }
  20. }

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

  1. @Restricted(NoExternalUse.class)
  2. public boolean hasCurrentUserRightToGenerateNewToken(User propertyOwner){
  3. if (ADMIN_CAN_GENERATE_NEW_TOKENS && Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
  4. return true;
  5. }
  6. User currentUser = User.current();
  7. if (currentUser == null) {
  8. // Anonymous
  9. return false;
  10. }
  11. if (Jenkins.getAuthentication() == ACL.SYSTEM) {
  12. // SYSTEM user is always eligible to see tokens
  13. return true;
  14. }
  15. return User.idStrategy().equals(propertyOwner.getId(), currentUser.getId());
  16. }

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

  1. @Override
  2. public SearchIndexBuilder makeSearchIndex() {
  3. SearchIndexBuilder builder = super.makeSearchIndex();
  4. if (hasPermission(ADMINISTER)) {
  5. builder.add("configure", "config", "configure")
  6. .add("manage")

相关文章

Jenkins类方法