Package org.tmatesoft.hg.auth

Examples of org.tmatesoft.hg.auth.HgAuthFailedException


      while (is.read() != -1) {
      }
      is.close();
      final int HTTP_UNAUTHORIZED = 401;
      if (c.getResponseCode() == HTTP_UNAUTHORIZED) {
        throw new HgAuthFailedException(c.getResponseMessage(), null);
      }
    } catch (IOException ex) {
      throw new HgAuthFailedException("Communication failure while authenticating", ex);
    } finally {
      if (c != null) {
        c.disconnect();
      }
    }
View Full Code Here


  public void withPublicKey(String username, InputStream privateKey, String passphrase) throws HgAuthFailedException {
    if (username == null) {
      // FIXME AuthFailure and AuthFailed or similar distinct exceptions to tell true authentication issues from
      // failures around it.
      throw new HgAuthFailedException("Need username", null);
    }
    if (privateKey == null) {
      throw new HgAuthFailedException("Need private key", null);
    }
    CharArrayWriter a = new CharArrayWriter(2048);
    int r;
    try {
      while((r = privateKey.read()) != -1) {
        a.append((char) r);
      }
    } catch (IOException ex) {
      throw new HgAuthFailedException("Failed to read private key", ex);
    }
    try {
      boolean success = conn.authenticateWithPublicKey(username, a.toCharArray(), passphrase);
      if (!success) {
        throw authFailed(username);
View Full Code Here

    }
  }

  public void withPassword(String username, String password) throws HgAuthFailedException {
    if (username == null) {
      throw new HgAuthFailedException("Need username", null);
    }
    try {
      boolean success;
      if (password == null) {
        success = conn.authenticateWithNone(username);
View Full Code Here

  public boolean supportsCertificate() {
    return true;
  }

  private HgAuthFailedException commFailed(IOException ex) {
    return new HgAuthFailedException("Communication failure while authenticating", ex);
  }
View Full Code Here

    return new HgAuthFailedException("Communication failure while authenticating", ex);
  }

  private HgAuthFailedException authFailed(String username) throws IOException {
    final String[] authMethodsLeft = conn.getRemainingAuthMethods(username);
    return new HgAuthFailedException(String.format("Failed to authenticate, other methods to try: %s", Arrays.toString(authMethodsLeft)), null);
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.auth.HgAuthFailedException

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.