Package org.eclipse.egit.github.core.client

Examples of org.eclipse.egit.github.core.client.GitHubClient


   */
  protected GitHubClient createClient(String host, String userName,
      String password, String oauth2Token, String serverId,
      Settings settings, MavenSession session)
      throws MojoExecutionException {
    GitHubClient client;
    if (!StringUtils.isEmpty(host)) {
      if (isDebug())
        debug("Using custom host: " + host);
      client = createClient(host);
    } else
View Full Code Here


   * @throws MojoExecutionException
   */
  protected GitHubClient createClient(String hostname)
      throws MojoExecutionException {
    if (!hostname.contains("://"))
      return new GitHubClient(hostname);
    try {
      URL hostUrl = new URL(hostname);
      return new GitHubClient(hostUrl.getHost(), hostUrl.getPort(),
          hostUrl.getProtocol());
    } catch (MalformedURLException e) {
      throw new MojoExecutionException("Could not parse host URL "
          + hostname, e);
    }
View Full Code Here

   * Subclasses can override to do any custom client configuration
   *
   * @return non-null client
   */
  protected GitHubClient createClient() {
    return new GitHubClient();
  }
View Full Code Here

    }
   
    String[] paths = getPaths(outputDirectory);
    String prefix = getPrefix(destinationDirectory);
   
    GitHubClient client = createClient(host, userName, password, oauth2Token);
    DataService service = new DataService(client);
   
    boolean createNoJekyll = noJekyll;
   
    if(createNoJekyll){
View Full Code Here

      throw new GitHubException("Error creating blob from '" + path + "': " + e.getMessage(), e);
    }
  }

  private GitHubClient createClient(String host, String userName, String password, String oauth2Token) throws GitHubException {
    GitHubClient client;
    if (!StringUtils.isEmpty(host)) {
      if (log.isDebugEnabled()){
        log.debug("Using custom host: " + host);
      }
      client = createClient(host);
    } else{
      client = new GitHubClient();
    }
   
    if(!StringUtils.isEmpty(userName) && !StringUtils.isEmpty(password)){
      if (log.isDebugEnabled()){
        log.debug("Using basic authentication with username: " + userName);
      }
      client.setCredentials(userName, password);
      return client;
    }else if(!StringUtils.isEmpty(oauth2Token)){
      if (log.isDebugEnabled()){
        log.debug("Using OAuth2 access token authentication");
      }
      client.setOAuth2Token(oauth2Token);
      return client;
    }else if(StringUtils.isEmpty(userName) && !StringUtils.isEmpty(password)){
      if (log.isDebugEnabled()){
        log.debug("Using OAuth2 access token authentication");
      }
      client.setOAuth2Token(password);
      return client;
    }else if(!StringUtils.isEmpty(userName) && System.console() != null){
      Console console = System.console();
      while(StringUtils.isEmpty(password)){
        password = new String(console.readPassword("Input the password for '" + userName + "': "));
      }
      client.setCredentials(userName, password);
      return client;
    }

    throw new GitHubException("No authentication credentials configured");
  }
View Full Code Here

   * @return non-null client
   * @throws MojoExecutionException
   */
  private GitHubClient createClient(String hostnamethrows GitHubException {
    if (!hostname.contains("://"))
      return new GitHubClient(hostname);
    try {
      URL hostUrl = new URL(hostname);
      return new GitHubClient(hostUrl.getHost(), hostUrl.getPort(), hostUrl.getProtocol());
    } catch (MalformedURLException e) {
      throw new GitHubException("Could not parse host URL " + hostname, e);
    }
  }
View Full Code Here

    String password="";
   
    SketchCode[] theSketches;
    String[] theSketchesContent;
   
    GitHubClient client;
      GistService service;
      GistFile[] file;
      String[] filename;
      Gist gist = new Gist();
      Map<String,GistFile> mp=new HashMap<String, GistFile>();
   
    theSketches=editor.getSketch().getCode();
    theSketchesContent = new String[theSketches.length];
    file=new GistFile[theSketches.length];
    filename = new String[theSketches.length];
    int indexOfUsername=-1;
    boolean makePrivate=false;
   
    for(int j =0; j<theSketches.length; j++){
      file[j]=new GistFile();
      if(theSketches[j]==editor.getSketch().getCurrentCode()){//so you don't need to save
        theSketchesContent[j]=editor.getText();
      }else{
        theSketchesContent[j]=theSketches[j].getProgram();
      }
          if(theSketches[j].getExtension()=="ino" || theSketches[j].getExtension()=="pde"){
            indexOfUsername=theSketchesContent[j].indexOf("USE_GITHUB_USERNAME=");
            makePrivate=theSketchesContent[j].contains("MAKE_PRIVATE_ON_GITHUB");
           
            if(indexOfUsername!=-1){//if the user specifies a username in the code comments
            username=theSketchesContent[j].substring(indexOfUsername+20);
              username=username.substring(0,username.indexOf('\n')).trim();
              if(table.containsKey(username)){
                password=(String) table.get(username);
              }else{
                System.out.println("No entry found for specified username in gistCredentials.txt, check spelling and try again");
                return;
              }
          }else{ //defaults to first entry in gistCredentials.txt
              username=table.keySet().toArray()[0].toString(); //first entry
              password=(String) table.get(table.keySet().toArray()[0]);
          }
          }
    }
   
    System.out.println("Sending source to "+username+"'s github account...");
 
    client = new GitHubClient().setCredentials(username, password);
    service = new GistService(client);
     
    try{
        List<Gist> gists = service.getGists(username);
        Boolean foundMatchingGist=false;
View Full Code Here

    Iterator iterator = table.keySet().iterator();
    while (iterator.hasNext()) {
      Object key = (String) iterator.next();
      String username=(String) key;
      if (!username.equals(correctUsername)){
        GitHubClient client;
          GistService service;
          Gist gist = new Gist();
       
        String password=(String) table.get(key);
       
        client = new GitHubClient().setCredentials(username, password);
          service = new GistService(client);
       
        try{
              List<Gist> gists = service.getGists(username);
              //Boolean foundMatchingGist=false;
View Full Code Here

 
     
      private boolean retrieveFromGitHub(String serialNumber, String username, String password) {
       
       
        GitHubClient client = new GitHubClient().setCredentials(username, password);
        GistService service = new GistService(client);
       
        try{
          List<Gist> gists = service.getGists(username);
          Boolean foundMatchingGist=false;
View Full Code Here

        // The githubclient prefers to connect to 'github.com' using the api domain, unlike github enterprise
        // which can connect fine using its domain, so for github.com use empty constructor
        if ( githubURL.getHost().equalsIgnoreCase( "github.com" ) )
        {
            this.client = new GitHubClient();
        }
        else
        {
            this.client = new GitHubClient( githubURL.getHost(), githubPort, githubScheme );
        }

        this.githubIssueURL = project.getIssueManagement().getUrl();
        if ( !this.githubIssueURL.endsWith( "/" ) )
        {
View Full Code Here

TOP

Related Classes of org.eclipse.egit.github.core.client.GitHubClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.