private TokenPair getTokenPair(String tokenPairName) {
    for (TokenPair tokenPair : getDescriptor().getTokenPairs()) {
      if (tokenPair.getTokenPairName().equals(tokenPairName)) return tokenPair;
    }

    if (getApiToken() != null && getTeamToken() != null)
      return new TokenPair("", getApiToken(), getTeamToken());

    String tokenPairNameForMessage = tokenPairName != null ? tokenPairName : "(null)";
    throw new MisconfiguredJobException(
        Messages._TestflightRecorder_TokenPairNotFound(tokenPairNameForMessage));
  }
 private TestflightUploader.UploadRequest createPartialUploadRequest(
     TestflightTeam team, EnvVars vars, AbstractBuild<?, ?> build) {
   TestflightUploader.UploadRequest ur = new TestflightUploader.UploadRequest();
   TokenPair tokenPair = getTokenPair(team.getTokenPairName());
   ur.filePaths = vars.expand(StringUtils.trim(team.getFilePath()));
   ur.dsymPath = vars.expand(StringUtils.trim(team.getDsymPath()));
   ur.apiToken = vars.expand(Secret.toString(tokenPair.getApiToken()));
   ur.buildNotes = createBuildNotes(vars.expand(buildNotes), build.getChangeSet());
   ur.lists = vars.expand(lists);
   ur.notifyTeam = notifyTeam;
   ProxyConfiguration proxy = getProxy();
   ur.proxyHost = proxy.name;
   ur.proxyPass = proxy.getPassword();
   ur.proxyPort = proxy.port;
   ur.proxyUser = proxy.getUserName();
   ur.replace = replace;
   ur.teamToken = vars.expand(Secret.toString(tokenPair.getTeamToken()));
   ur.debug = debug;
   return ur;
 }