mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SVN auth
This commit is contained in:
@@ -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<T, Key> {
|
||||
notification = new MyNotification<T>(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) {
|
||||
|
||||
@@ -198,6 +198,7 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
|
||||
private static boolean validationImpl(final Project project, final SVNURL url,
|
||||
final SvnConfiguration configuration, final ISVNAuthenticationManager manager,
|
||||
final boolean checkWrite, final String realm, final String kind) {
|
||||
SvnInteractiveAuthenticationProvider.clearCallState();
|
||||
try {
|
||||
new SVNWCClient(manager, configuration.getOptions(project)).doInfo(url, SVNRevision.UNDEFINED, SVNRevision.HEAD);
|
||||
} catch (SVNAuthenticationException e) {
|
||||
@@ -213,9 +214,13 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
|
||||
}
|
||||
LOG.info("some other exc", e);
|
||||
}
|
||||
if ((! checkWrite) || configuration.haveCredentialsFor(kind, realm)) {
|
||||
if (! checkWrite) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SvnInteractiveAuthenticationProvider.wasCalled() && SvnInteractiveAuthenticationProvider.wasCancelled()) return false;
|
||||
if (SvnInteractiveAuthenticationProvider.wasCalled()) return true;
|
||||
|
||||
final SvnVcs svnVcs = SvnVcs.getInstance(project);
|
||||
if (svnVcs.getAuthNotifier().getObj(url) != null) return false;
|
||||
|
||||
|
||||
@@ -451,4 +451,8 @@ public class SvnConfiguration implements ProjectComponent, JDOMExternalizable {
|
||||
public void acknowledge(final String kind, final String realm, final Object object) {
|
||||
RUNTIME_AUTH_CACHE.putData(kind, realm, object);
|
||||
}
|
||||
|
||||
public void clearCredentials(final String kind, final String realm) {
|
||||
RUNTIME_AUTH_CACHE.putData(kind, realm, null);
|
||||
}
|
||||
}
|
||||
|
||||
+45
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.GuiUtils;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jetbrains.idea.svn.SvnBundle;
|
||||
import org.jetbrains.idea.svn.SvnConfiguration;
|
||||
import org.jetbrains.idea.svn.SvnVcs;
|
||||
import org.tmatesoft.svn.core.SVNErrorMessage;
|
||||
import org.tmatesoft.svn.core.SVNURL;
|
||||
@@ -32,17 +33,38 @@ import java.lang.reflect.InvocationTargetException;
|
||||
public class SvnInteractiveAuthenticationProvider implements ISVNAuthenticationProvider {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.idea.svn.dialogs.SvnInteractiveAuthenticationProvider");
|
||||
private final Project myProject;
|
||||
private static ThreadLocal<MyCallState> myCallState = new ThreadLocal<MyCallState>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user