Ejemplo n.º 1
0
 @NotNull
 public GithubAuthData getAuthData() {
   switch (getAuthType()) {
     case BASIC:
       return GithubAuthData.createBasicAuth(getHost(), getLogin(), getPassword());
     case TOKEN:
       return GithubAuthData.createTokenAuth(getHost(), getPassword());
     case ANONYMOUS:
       return GithubAuthData.createAnonymous();
     default:
       throw new IllegalStateException(
           "GithubSettings: getAuthData - wrong AuthType: " + getAuthType());
   }
 }
Ejemplo n.º 2
0
  private void setAuthData(@NotNull GithubAuthData auth, boolean rememberPassword) {
    setAuthType(auth.getAuthType());

    switch (auth.getAuthType()) {
      case BASIC:
        assert auth.getBasicAuth() != null;
        setLogin(auth.getBasicAuth().getLogin());
        setPassword(auth.getBasicAuth().getPassword(), rememberPassword);
        break;
      case TOKEN:
        assert auth.getTokenAuth() != null;
        setLogin(null);
        setPassword(auth.getTokenAuth().getToken(), rememberPassword);
        break;
      case ANONYMOUS:
        setLogin(null);
        setPassword("", rememberPassword);
        break;
      default:
        throw new IllegalStateException(
            "GithubSettings: setAuthData - wrong AuthType: " + getAuthType());
    }
  }