コード例 #1
0
 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;
 }
コード例 #2
0
 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);
 }
コード例 #3
0
  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);
  }
コード例 #4
0
  /** 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;
  }
コード例 #5
0
  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;
  }