public SvnAuthenticationNotifier(final SvnVcs17 svnVcs) {
   super(
       svnVcs.getProject(),
       svnVcs.getDisplayName(),
       "Not Logged In to Subversion",
       NotificationType.ERROR);
   myVcs = svnVcs;
   myRootsToWorkingCopies = myVcs.getRootsToWorkingCopies();
   myCopiesPassiveResults = Collections.synchronizedMap(new HashMap<SVNURL, Boolean>());
   myVerificationInProgress = false;
 }
 protected List<Change> getChangesInScope(final VcsDirtyScope dirtyScope) throws VcsException {
   ChangeProvider changeProvider = SvnVcs17.getInstance(myProject).getChangeProvider();
   assert changeProvider != null;
   MockChangelistBuilder builder = new MockChangelistBuilder();
   changeProvider.getChanges(dirtyScope, builder, new EmptyProgressIndicator(), myGate);
   return builder.getChanges();
 }
 public static boolean interactiveValidation(
     final Project project, final SVNURL url, final String realm, final String kind) {
   final SvnConfiguration17 configuration = SvnConfiguration17.getInstance(project);
   final SvnAuthenticationManager passiveManager =
       configuration.getInteractiveManager(SvnVcs17.getInstance(project));
   return validationImpl(project, url, configuration, passiveManager, true, realm, kind, true);
 }
  private void onStateChangedToSuccess(final AuthenticationRequest obj) {
    myCopiesPassiveResults.put(getKey(obj), true);
    myVcs.invokeRefreshSvnRoots(false);

    final List<SVNURL> outdatedRequests = new LinkedList<SVNURL>();
    final Collection<SVNURL> keys = getAllCurrentKeys();
    for (SVNURL key : keys) {
      final SVNURL commonURLAncestor = SVNURLUtil.getCommonURLAncestor(key, obj.getUrl());
      if ((commonURLAncestor != null)
          && (!StringUtil.isEmptyOrSpaces(commonURLAncestor.getHost()))
          && (!StringUtil.isEmptyOrSpaces(commonURLAncestor.getPath()))) {
        // final AuthenticationRequest currObj = getObj(key);
        // if ((currObj != null) && passiveValidation(myVcs.getProject(), key, true,
        // currObj.getRealm(), currObj.getKind())) {
        outdatedRequests.add(key);
        // }
      }
    }
    log("on state changed ");
    ApplicationManager.getApplication()
        .invokeLater(
            new Runnable() {
              public void run() {
                for (SVNURL key : outdatedRequests) {
                  removeLazyNotificationByKey(key);
                }
              }
            },
            ModalityState.NON_MODAL);
  }
  private static void addRecursively(final SvnVcs17 activeVcs, final VirtualFile file)
      throws SVNException {
    final SVNWCClient wcClient = activeVcs.createWCClient();
    final SvnExcludingIgnoredOperation operation =
        new SvnExcludingIgnoredOperation(
            activeVcs.getProject(),
            new SvnExcludingIgnoredOperation.Operation() {
              public void doOperation(final VirtualFile virtualFile) throws SVNException {
                final File ioFile = new File(virtualFile.getPath());
                final ProgressIndicator indicator =
                    ProgressManager.getInstance().getProgressIndicator();
                if (indicator != null) {
                  indicator.checkCanceled();
                  indicator.setText(
                      SvnBundle.message(
                          "share.or.import.add.progress.text", virtualFile.getPath()));
                }
                wcClient.doAdd(ioFile, true, false, false, SVNDepth.EMPTY, false, false);
              }
            },
            SVNDepth.INFINITY);

    operation.execute(file);
  }
  /** Bases on presence of notifications! */
  public ThreeState isAuthenticatedFor(final VirtualFile vf) {
    final WorkingCopy wcCopy = myRootsToWorkingCopies.getWcRoot(vf);
    if (wcCopy == null) return ThreeState.UNSURE;

    // check there's no cancellation yet
    final boolean haveCancellation = getStateFor(wcCopy.getUrl());
    if (haveCancellation) return ThreeState.NO;

    final Boolean keptResult = myCopiesPassiveResults.get(wcCopy.getUrl());
    if (Boolean.TRUE.equals(keptResult)) return ThreeState.YES;
    if (Boolean.FALSE.equals(keptResult)) return ThreeState.NO;

    // check have credentials
    final boolean calculatedResult = passiveValidation(myVcs.getProject(), wcCopy.getUrl());
    myCopiesPassiveResults.put(wcCopy.getUrl(), calculatedResult);
    return calculatedResult ? ThreeState.YES : ThreeState.NO;
  }
 private static Pair<SVNRevision, SVNURL> createRemoteFolder(
     final SvnVcs17 vcs, final SVNURL parent, final String folderName) throws SVNException {
   SVNURL url = parent.appendPath(folderName, false);
   final String urlText = url.toString();
   final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
   if (indicator != null) {
     indicator.checkCanceled();
     indicator.setText(SvnBundle.message("share.directory.create.dir.progress.text", urlText));
   }
   final SVNCommitInfo info =
       vcs.createCommitClient()
           .doMkDir(
               new SVNURL[] {url},
               SvnBundle.message(
                   "share.directory.commit.message",
                   folderName,
                   ApplicationNamesInfo.getInstance().getFullProductName()));
   return new Pair<SVNRevision, SVNURL>(SVNRevision.create(info.getNewRevision()), url);
 }
 public static boolean share(final Project project, final VirtualFile file) throws VcsException {
   return performImpl(project, SvnVcs17.getInstance(project), file);
 }
  private static boolean validationImpl(
      final Project project,
      final SVNURL url,
      final SvnConfiguration17 configuration,
      final SvnAuthenticationManager manager,
      final boolean checkWrite,
      final String realm,
      final String kind,
      boolean interactive) {
    SvnInteractiveAuthenticationProvider.clearCallState();
    try {
      new SVNWCClient(manager, configuration.getOptions(project))
          .doInfo(url, SVNRevision.UNDEFINED, SVNRevision.HEAD);
    } catch (SVNAuthenticationException e) {
      log(e);
      return false;
    } catch (SVNCancelException e) {
      log(e); // auth canceled
      return false;
    } catch (SVNException e) {
      if (e.getErrorMessage().getErrorCode().isAuthentication()) {
        log(e);
        return false;
      }
      LOG.info("some other exc", e);
      if (interactive) {
        VcsBalloonProblemNotifier.showOverChangesView(
            project, "Authentication failed: " + e.getMessage(), MessageType.ERROR);
      }
      return false; /// !!!! any exception means user should be notified that authorization failed
    }

    if (!checkWrite) {
      return true;
    }
    /*if (passive) {
      return SvnInteractiveAuthenticationProvider.wasCalled();
    }*/

    if (SvnInteractiveAuthenticationProvider.wasCalled()
        && SvnInteractiveAuthenticationProvider.wasCancelled()) return false;
    if (SvnInteractiveAuthenticationProvider.wasCalled()) return true;

    final SvnVcs17 svnVcs = SvnVcs17.getInstance(project);

    final SvnInteractiveAuthenticationProvider provider =
        new SvnInteractiveAuthenticationProvider(svnVcs, manager);
    final SVNAuthentication svnAuthentication =
        provider.requestClientAuthentication(kind, url, realm, null, null, true);
    if (svnAuthentication != null) {
      configuration.acknowledge(kind, realm, svnAuthentication);
      try {
        configuration
            .getAuthenticationManager(svnVcs)
            .acknowledgeAuthentication(true, kind, realm, null, svnAuthentication);
      } catch (SVNException e) {
        LOG.info(e);
      }
      return true;
    }
    return false;
  }