congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Username.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.thoughtworks.go.server.domain.Username
constructor

Best Java code snippets using com.thoughtworks.go.server.domain.Username.<init> (Showing top 20 results out of 315)

origin: gocd/gocd

public GoUserPrinciple(String username, String displayName, Set<GrantedAuthority> authorities) {
  this.username = new Username(username, displayName);
  this.authorities = authorities;
  this.displayName = displayName;
}
origin: gocd/gocd

public Username usernameFor(String pluginId) {
  return new Username(format("plugin-%s", pluginId));
}
origin: gocd/gocd

public Username agentUsername(String uuId, String ipAddress, String hostNameForDisplay) {
  return new Username(String.format("agent_%s_%s_%s", uuId, ipAddress, hostNameForDisplay));
}
origin: gocd/gocd

public Map<CaseInsensitiveString, List<CaseInsensitiveString>> templatesWithPipelinesForUser(CaseInsensitiveString username) {
  HashMap<CaseInsensitiveString, List<CaseInsensitiveString>> templatesToPipelinesMap = new HashMap<>();
  Map<CaseInsensitiveString, Map<CaseInsensitiveString, Authorization>> authMap = goConfigService.getCurrentConfig().templatesWithAssociatedPipelines();
  for (CaseInsensitiveString templateName : authMap.keySet()) {
    if (securityService.isAuthorizedToViewTemplate(templateName, new Username(username))) {
      templatesToPipelinesMap.put(templateName, new ArrayList<>());
      Map<CaseInsensitiveString, Authorization> authorizationMap = authMap.get(templateName);
      for (CaseInsensitiveString pipelineName : authorizationMap.keySet()) {
        templatesToPipelinesMap.get(templateName).add(pipelineName);
      }
    }
  }
  return templatesToPipelinesMap;
}
origin: gocd/gocd

private void checkAndAddTemplateViewUser(String userName, Set<GrantedAuthority> authorities) {
  if (securityService.isAuthorizedToViewTemplates(new Username(userName))) {
    authorities.add(GoAuthority.ROLE_TEMPLATE_VIEW_USER.asAuthority());
  }
}
origin: gocd/gocd

  public static Username valueOf(String username) {
    return new Username(new CaseInsensitiveString(username));
  }
}
origin: gocd/gocd

  private void checkAndAddSuperAdmin(String username, Set<GrantedAuthority> authorities) {
    if (securityService.isUserAdmin(new Username(new CaseInsensitiveString(username)))) {
      authorities.add(GoAuthority.ROLE_SUPERVISOR.asAuthority());
    }
  }
}
origin: gocd/gocd

private boolean userNameListContainsAdmin(List<String> enabledUserNames) {
  for (String enabledUserName : enabledUserNames) {
    if (securityService.isUserAdmin(new Username(new CaseInsensitiveString(enabledUserName)))) {
      return true;
    }
  }
  return false;
}
origin: gocd/gocd

private void checkAndAddGroupAdmin(String username, Set<GrantedAuthority> authorities) {
  if (securityService.isUserGroupAdmin(new Username(new CaseInsensitiveString(username)))) {
    authorities.add(GoAuthority.ROLE_GROUP_SUPERVISOR.asAuthority());
  }
}
origin: gocd/gocd

private void checkAndAddTemplateAdmin(String username, Set<GrantedAuthority> authorities) {
  if (securityService.isAuthorizedToViewAndEditTemplates(new Username(new CaseInsensitiveString(username)))) {
    authorities.add(GoAuthority.ROLE_TEMPLATE_SUPERVISOR.asAuthority());
  }
}
origin: gocd/gocd

private List<UserModel> allUsersForDisplay() {
  Collection<User> users = allUsers();
  ArrayList<UserModel> userModels = new ArrayList<>();
  for (User user : users) {
    String userName = user.getName();
    ArrayList<String> roles = new ArrayList<>();
    for (Role role : goConfigService.rolesForUser(new CaseInsensitiveString(userName))) {
      roles.add(CaseInsensitiveString.str(role.getName()));
    }
    userModels.add(new UserModel(user, roles, securityService.isUserAdmin(new Username(new CaseInsensitiveString(userName)))));
  }
  return userModels;
}
origin: gocd/gocd

public boolean isUserAdminOfGroup(final CaseInsensitiveString userName, String groupName) {
  if (!isSecurityEnabled()) {
    return true;
  }
  PipelineConfigs group = null;
  if (groupName != null) {
    group = getCurrentConfig().findGroup(groupName);
  }
  return isUserAdmin(new Username(userName)) || isUserAdminOfGroup(userName, group);
}
origin: gocd/gocd

public PipelineInstanceModels load(String pipelineName, Pagination pagination, String username, boolean populateCanRun) {
  PipelineInstanceModels history = pipelineDao.loadHistory(pipelineName, pagination.getPageSize(), pagination.getOffset());
  PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName));
  for (PipelineInstanceModel pipelineInstanceModel : history) {
    populatePipelineInstanceModel(new Username(new CaseInsensitiveString(username)), populateCanRun, pipelineConfig, pipelineInstanceModel);
  }
  addEmptyPipelineInstanceIfNeeded(pipelineName, history, new Username(new CaseInsensitiveString(username)), pipelineConfig, populateCanRun);
  return history;
}
origin: gocd/gocd

@Test
public void shouldIncludeUserWhoForcedBuildInManualBuildCause() {
  BuildCause cause = BuildCause.createManualForced(null, new Username(new CaseInsensitiveString("Joe Bloggs")));
  assertThat(cause.getBuildCauseMessage(), containsString("Forced by Joe Bloggs"));
}
origin: gocd/gocd

public boolean hasOperatePermissionForGroup(final CaseInsensitiveString username, String groupName) {
  CruiseConfig cruiseConfig = goConfigService.getCurrentConfig();
  if (!cruiseConfig.isSecurityEnabled()) {
    return true;
  }
  if (isUserAdmin(new Username(username))) {
    return true;
  }
  PipelineConfigs group = cruiseConfig.getGroups().findGroup(groupName);
  return isUserAdminOfGroup(username, group) || group.hasOperatePermission(username, new UserRoleMatcherImpl(cruiseConfig.server().security()));
}
origin: gocd/gocd

private String saveUserAndRenderResult(Request req, Response res, HttpLocalizedOperationResult result, User userToOperate, User userFromRequest, String username) throws IOException {
  userService.save(userToOperate, TriState.from(userFromRequest.isEnabled()), TriState.from(userFromRequest.isEmailMe()), userFromRequest.getEmail(), userFromRequest.getMatcher(), result);
  boolean isSaved = result.isSuccessful();
  if (isSaved) {
    return writerForTopLevelObject(req, res, writer -> UserRepresenter.toJSON(writer, getUserToRepresent(userService.findUserByName(username), roleConfigService.getRolesForUser(Collections.singletonList(new Username(username))))));
  } else {
    return renderHTTPOperationResult(result, req, res);
  }
}
origin: gocd/gocd

public boolean hasViewPermissionForGroup(String userName, String pipelineGroupName) {
  CruiseConfig cruiseConfig = goConfigService.getCurrentConfig();
  if (!cruiseConfig.isSecurityEnabled()) {
    return true;
  }
  CaseInsensitiveString username = new CaseInsensitiveString(userName);
  if (isUserAdmin(new Username(username))) {
    return true;
  }
  PipelineConfigs group = cruiseConfig.getGroups().findGroup(pipelineGroupName);
  return isUserAdminOfGroup(username, group) || group.hasViewPermission(username, new UserRoleMatcherImpl(cruiseConfig.server().security()));
}
origin: gocd/gocd

  private User getUser(HttpServletRequest request) {
    Long userId = SessionUtils.getUserId(request);
    if (userId == null) {
      final GoUserPrinciple currentUser = SessionUtils.getCurrentUser();

      Username userName = new Username(currentUser.getUsername());

      if (userName.isAnonymous() || userName.isGoAgentUser()) {
        return new NullUser();
      }

      return userService.findUserByName(CaseInsensitiveString.str(userName.getUsername()));
    } else {
      return userService.load(userId);
    }
  }
}
origin: gocd/gocd

public PipelineInstanceModels loadWithEmptyAsDefault(String pipelineName, Pagination pagination, String userName) {
  if (!securityService.hasViewPermissionForPipeline(new Username(new CaseInsensitiveString(userName)), pipelineName)) {
    return PipelineInstanceModels.createPipelineInstanceModels();
  }
  PipelineInstanceModels pipelineInstanceModels = null;
  if (triggerMonitor.isAlreadyTriggered(new CaseInsensitiveString(pipelineName))) {
    StageInstanceModels stageHistory = new StageInstanceModels();
    appendFollowingStagesFromConfig(pipelineName, stageHistory);
    PipelineInstanceModel model = PipelineInstanceModel.createPreparingToSchedule(pipelineName, stageHistory);
    model.setCanRun(false);
    pipelineInstanceModels = PipelineInstanceModels.createPipelineInstanceModels(model);
  } else {
    pipelineInstanceModels = load(pipelineName, pagination, userName, true);
  }
  return pipelineInstanceModels;
}
origin: gocd/gocd

public boolean hasOperatePermissionForStage(String pipelineName, String stageName, String username) {
  if (!goConfigService.isSecurityEnabled()) {
    return true;
  }
  if (!goConfigService.hasStageConfigNamed(pipelineName, stageName)) {
    return false;
  }
  StageConfig stage = goConfigService.stageConfigNamed(pipelineName, stageName);
  CaseInsensitiveString userName = new CaseInsensitiveString(username);
  //TODO - #2517 - stage not exist
  if (stage.hasOperatePermissionDefined()) {
    CruiseConfig cruiseConfig = goConfigService.getCurrentConfig();
    String groupName = goConfigService.findGroupNameByPipeline(new CaseInsensitiveString(pipelineName));
    PipelineConfigs group = goConfigService.getCurrentConfig().findGroup(groupName);
    if (isUserAdmin(new Username(userName)) || isUserAdminOfGroup(userName, group)) {
      return true;
    }
    return goConfigService.readAclBy(pipelineName, stageName).isGranted(userName);
  }
  return hasOperatePermissionForPipeline(new CaseInsensitiveString(username), pipelineName);
}
com.thoughtworks.go.server.domainUsername<init>

Popular methods of Username

  • getUsername
  • equals
  • getDisplayName
  • isAnonymous
  • valueOf
  • hashCode
  • isGoAgentUser

Popular in Java

  • Updating database using SQL prepared statement
  • compareTo (BigDecimal)
  • setContentView (Activity)
  • onCreateOptionsMenu (Activity)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now