hudson.model.User.hasPermission()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(131)

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

User.hasPermission介绍

暂无

代码示例

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

/**
 * List of all {@link UserProperty}s exposed primarily for the remoting API.
 */
@Exported(name = "property", inline = true)
public List<UserProperty> getAllProperties() {
  if (hasPermission(Jenkins.ADMINISTER)) {
    return Collections.unmodifiableList(properties);
  }
  return Collections.emptyList();
}

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

/**
 * With ADMINISTER permission, can delete users with persisted data but can't delete self.
 */
public boolean canDelete() {
  final IdStrategy strategy = idStrategy();
  return hasPermission(Jenkins.ADMINISTER) && !strategy.equals(id, Jenkins.getAuthentication().getName())
      && UserIdMapper.getInstance().isMapped(id);
}

代码示例来源:origin: stackoverflow.com

public class Course {

  public void enroll( User user, Student student ) {
    if( user.hasPermission( Permission.OVERRIDE_COURSE_RULES ) ) {
      add( student );
    } else if( hasEnrollmentDatePassed() ) {
      throw new CourseException( "Enrollment date has passed." );
    } else if( isClassFull() ) {
      throw new CourseException( "Course is full" );
    } else {
      add( student );
    }
  }
}

代码示例来源:origin: org.hudsonci.plugins/instant-messaging

private String checkPermission(User user, Sender sender) {
  if (!user.hasPermission(Hudson.READ)) {
    return sender.getNickname() + ": you may not read that user!"; 
  }
  return null;
}

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

/**
 * List of all {@link UserProperty}s exposed primarily for the remoting API.
 */
@Exported(name="property",inline=true)
public List<UserProperty> getAllProperties() {
  if (hasPermission(Jenkins.ADMINISTER)) {
    return Collections.unmodifiableList(properties);
  }
  return Collections.emptyList();
}

代码示例来源:origin: jenkinsci/instant-messaging-plugin

private String checkPermission(User user, Sender sender) {
  if (!user.hasPermission(Hudson.READ)) {
    return sender.getNickname() + ": you may not read that user!"; 
  }
  return null;
}

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

/**
 * With ADMINISTER permission, can delete users with persisted data but
 * can't delete self.
 */
public boolean canDelete() {
  return hasPermission(Hudson.ADMINISTER) && !id.equals(HudsonSecurityManager.getAuthentication().getName())
      && new File(getRootDir(), id).exists();
}

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

/**
 * With ADMINISTER permission, can delete users with persisted data but can't delete self.
 */
public boolean canDelete() {
  return hasPermission(Hudson.ADMINISTER) && !id.equals(Hudson.getAuthentication().getName())
      && new File(getRootDir(), id).exists();
}

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

/**
 * With ADMINISTER permission, can delete users with persisted data but can't delete self.
 */
public boolean canDelete() {
  return hasPermission(Hudson.ADMINISTER) && !id.equals(Hudson.getAuthentication().getName())
      && new File(getRootDir(), id).exists();
}

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

/**
 * With ADMINISTER permission, can delete users with persisted data but can't delete self.
 */
public boolean canDelete() {
  return hasPermission(Hudson.ADMINISTER) && !id.equals(Hudson.getAuthentication().getName())
      && new File(getRootDir(), id).exists();
}

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

/**
 * With ADMINISTER permission, can delete users with persisted data but can't delete self.
 */
public boolean canDelete() {
  final IdStrategy strategy = idStrategy();
  return hasPermission(Jenkins.ADMINISTER) && !strategy.equals(id, Jenkins.getAuthentication().getName())
      && new File(getRootDir(), strategy.filenameOf(id)).exists();
}

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

/**
 * Checks if the current user has permission to create a credential.
 *
 * @param context     the context.
 * @param includeUser whether they can use their own credentials store.
 * @return {@code true} if they can create a permission.
 * @since FIXME
 */
@Restricted(NoExternalUse.class)
@SuppressWarnings("unused") // used via jelly
public boolean hasCreatePermission(ModelObject context, boolean includeUser) {
  if (includeUser) {
    User current = User.current();
    if (current != null && current.hasPermission(CREATE)) {
      return true;
    }
  }
  if (context == null) {
    StaplerRequest request = Stapler.getCurrentRequest();
    if (request != null) {
      context = request.findAncestorObject(ModelObject.class);
    }
  }
  for (CredentialsStore store : CredentialsProvider.lookupStores(context)) {
    if (store.hasPermission(CREATE)) {
      return true;
    }
  }
  return false;
}

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

/**
 * Checks if the current user has permission to create a credential.
 *
 * @param context     the context.
 * @param includeUser whether they can use their own credentials store.
 * @return {@code true} if they can create a permission.
 * @since FIXME
 */
@Restricted(NoExternalUse.class)
@SuppressWarnings("unused") // used via jelly
public boolean hasCreatePermission(ModelObject context, boolean includeUser) {
  if (includeUser) {
    User current = User.current();
    if (current != null && current.hasPermission(CREATE)) {
      return true;
    }
  }
  if (context == null) {
    StaplerRequest request = Stapler.getCurrentRequest();
    if (request != null) {
      context = request.findAncestorObject(ModelObject.class);
    }
  }
  for (CredentialsStore store : CredentialsProvider.lookupStores(context)) {
    if (store.hasPermission(CREATE)) {
      return true;
    }
  }
  return false;
}

相关文章