From 4936aef4c4efb3d1fac7b1644257e5acbd67499d Mon Sep 17 00:00:00 2001 From: irengrig Date: Tue, 22 Dec 2009 17:35:46 +0300 Subject: [PATCH] SVN auth --- .../openapi/vcs/impl/GenericNotifierImpl.java | 13 ++++++- .../idea/svn/SvnAuthenticationNotifier.java | 7 +++- .../org/jetbrains/idea/svn/SvnConfiguration.java | 4 ++ .../SvnInteractiveAuthenticationProvider.java | 45 ++++++++++++++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/GenericNotifierImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/GenericNotifierImpl.java index e0d9a9e749..241e57b12c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/GenericNotifierImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/GenericNotifierImpl.java @@ -19,6 +19,8 @@ import com.intellij.notification.Notification; import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; import com.intellij.notification.Notifications; +import com.intellij.openapi.application.Application; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; @@ -84,7 +86,16 @@ public abstract class GenericNotifierImpl { notification = new MyNotification(myGroupId, myTitle, getNotificationContent(obj), myType, myListener, obj); myState.put(key, notification); } - Notifications.Bus.notify(notification, myProject); + final Application application = ApplicationManager.getApplication(); + if (application.isDispatchThread()) { + Notifications.Bus.notify(notification, myProject); + } else { + application.invokeLater(new Runnable() { + public void run() { + Notifications.Bus.notify(notification, myProject); + } + }); + } } public void removeLazyNotificationByKey(final Key key) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java index 5008f1e681..459d12dd30 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java @@ -198,6 +198,7 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl myCallState = new ThreadLocal(); + private final SvnVcs myVcs; public SvnInteractiveAuthenticationProvider(final SvnVcs vcs) { + myVcs = vcs; myProject = vcs.getProject(); } + public static void clearCallState() { + myCallState.set(null); + } + + public static boolean wasCalled() { + return myCallState.get() != null && myCallState.get().isWasCalled(); + } + + public static boolean wasCancelled() { + return myCallState.get() != null && myCallState.get().isWasCancelled(); + } + public SVNAuthentication requestClientAuthentication(String kind, final SVNURL url, final String realm, SVNErrorMessage errorMessage, final SVNAuthentication previousAuth, final boolean authMayBeStored) { + final MyCallState callState = new MyCallState(true, false); + myCallState.set(callState); + // once we came here, we don't know _correct_ auth todo +- + final SvnConfiguration configuration = SvnConfiguration.getInstance(myProject); + configuration.clearCredentials(kind, realm); + final SVNAuthentication[] result = new SVNAuthentication[1]; Runnable command = null; @@ -146,6 +168,7 @@ public class SvnInteractiveAuthenticationProvider implements ISVNAuthenticationP } log("3 authentication result: " + result[0]); } + callState.setWasCancelled(result[0] == null); return result[0]; } @@ -157,4 +180,26 @@ public class SvnInteractiveAuthenticationProvider implements ISVNAuthenticationP private void log(final String s) { LOG.debug(s); } + + public static class MyCallState { + private boolean myWasCalled; + private boolean myWasCancelled; + + public MyCallState(boolean wasCalled, boolean wasCancelled) { + myWasCalled = wasCalled; + myWasCancelled = wasCancelled; + } + + public boolean isWasCalled() { + return myWasCalled; + } + + public boolean isWasCancelled() { + return myWasCancelled; + } + + public void setWasCancelled(boolean wasCancelled) { + myWasCancelled = wasCancelled; + } + } } -- 2.11.4.GIT