From 2e9f9348faab6976694202971211e931a0ef77dd Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 27 Jan 2010 12:25:40 +0300 Subject: [PATCH] IDEA-25467 (CVS is set to Offline mode on project open) - integration to trunk --- .../intellij/lifecycle/PeriodicalTasksCloser.java | 20 +++++++++++--------- .../cvsSupport2/connections/CvsConnectionUtil.java | 6 +++--- .../connections/ssh/SshPasswordAuthentication.java | 15 +++++++++------ .../connections/ssh/SshPublicKeyAuthentication.java | 14 ++++++++++---- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/lifecycle/PeriodicalTasksCloser.java b/platform/vcs-impl/src/com/intellij/lifecycle/PeriodicalTasksCloser.java index 1f45b6f6a8..61777c564b 100644 --- a/platform/vcs-impl/src/com/intellij/lifecycle/PeriodicalTasksCloser.java +++ b/platform/vcs-impl/src/com/intellij/lifecycle/PeriodicalTasksCloser.java @@ -163,15 +163,17 @@ public class PeriodicalTasksCloser implements ProjectManagerListener { return; } final Ref fire = new Ref(); - synchronized (ourLock) { - final Boolean state = myStates.get(project); - if (! Boolean.TRUE.equals(state)) { - fire.set(Boolean.TRUE); - } - if (Boolean.TRUE.equals(fire.get())) { - synchronized (start) { - start.set(Boolean.FALSE); - return; + if (project != null) { + synchronized (ourLock) { + final Boolean state = myStates.get(project); + if (! Boolean.TRUE.equals(state)) { + fire.set(Boolean.TRUE); + } + if (Boolean.TRUE.equals(fire.get())) { + synchronized (start) { + start.set(Boolean.FALSE); + return; + } } } } diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/CvsConnectionUtil.java b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/CvsConnectionUtil.java index 98e2906983..7f9e9d5d87 100644 --- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/CvsConnectionUtil.java +++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/CvsConnectionUtil.java @@ -52,11 +52,11 @@ public class CvsConnectionUtil { final ConnectionPoolI pool = SshConnectionPool.getInstance(); final SshAuthentication authentication; if (sshConfiguration.USE_PPK) { - authentication = new SshPublicKeyAuthentication(new File(sshConfiguration.PATH_TO_PPK), - sshPasswordProvider.getPPKPasswordForCvsRoot(settings.getCvsRootAsString()), settings.USER); + authentication = new SshPublicKeyAuthentication(new File(sshConfiguration.PATH_TO_PPK), settings.USER, sshPasswordProvider, + settings.getCvsRootAsString()); } else { - authentication = new SshPasswordAuthentication(settings.USER, sshPasswordProvider.getPasswordForCvsRoot(settings.getCvsRootAsString())); + authentication = new SshPasswordAuthentication(settings.USER, sshPasswordProvider, settings.getCvsRootAsString()); } return pool.getConnection(settings.REPOSITORY, connectionSettings, authentication); } diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshPasswordAuthentication.java b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshPasswordAuthentication.java index 596e95735d..80c1985a9b 100644 --- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshPasswordAuthentication.java +++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshPasswordAuthentication.java @@ -28,15 +28,18 @@ public class SshPasswordAuthentication implements SshAuthentication { private final static String KEYBOARD_METHOD = "keyboard-interactive"; private final String myLogin; - private final String myPassword; + private final SSHPasswordProvider myPasswordProvider; + private final String myCvsRootAsString; - public SshPasswordAuthentication(final String login, final String password) { - myPassword = password; + public SshPasswordAuthentication(final String login, final SSHPasswordProvider passwordProvider, final String cvsRootAsString) { myLogin = login; + myPasswordProvider = passwordProvider; + myCvsRootAsString = cvsRootAsString; } public void authenticate(final Connection connection) throws AuthenticationException, SolveableAuthenticationException { - if (myPassword == null) { + final String password = myPasswordProvider.getPasswordForCvsRoot(myCvsRootAsString); + if (password == null) { throw new SolveableAuthenticationException("Authentication rejected."); } try { @@ -45,7 +48,7 @@ public class SshPasswordAuthentication implements SshAuthentication { final List methods = Arrays.asList(methodsArr); if (methods.contains(PASSWORD_METHOD)) { - if (connection.authenticateWithPassword(myLogin, myPassword)) return; + if (connection.authenticateWithPassword(myLogin, password)) return; } if (methods.contains(KEYBOARD_METHOD)) { @@ -53,7 +56,7 @@ public class SshPasswordAuthentication implements SshAuthentication { public String[] replyToChallenge(String s, String instruction, int numPrompts, String[] strings, boolean[] booleans) throws Exception { final String[] result = new String[numPrompts]; if (numPrompts > 0) { - Arrays.fill(result, myPassword); + Arrays.fill(result, password); } return result; } diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshPublicKeyAuthentication.java b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshPublicKeyAuthentication.java index 52e7253a75..9ef8752ac6 100644 --- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshPublicKeyAuthentication.java +++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshPublicKeyAuthentication.java @@ -25,12 +25,15 @@ import java.io.IOException; public class SshPublicKeyAuthentication implements SshAuthentication { private final String myLogin; private final File myFile; - private final String myPassword; + private final SSHPasswordProvider myPasswordProvider; + private final String myCvsRootAsString; - public SshPublicKeyAuthentication(final File file, final String password, final String login) { + public SshPublicKeyAuthentication(final File file, final String login, final SSHPasswordProvider passwordProvider, + final String cvsRootAsString) { myFile = file; - myPassword = password; myLogin = login; + myPasswordProvider = passwordProvider; + myCvsRootAsString = cvsRootAsString; } public void authenticate(final Connection connection) throws AuthenticationException, SolveableAuthenticationException { @@ -43,7 +46,10 @@ public class SshPublicKeyAuthentication implements SshAuthentication { } try { - connection.authenticateWithPublicKey(myLogin, keyChars, myPassword); + final String password = myPasswordProvider.getPPKPasswordForCvsRoot(myCvsRootAsString); + if (! connection.authenticateWithPublicKey(myLogin, keyChars, password)) { + throw new SolveableAuthenticationException("Authentication rejected."); + } } catch (IOException e) { throw new SolveableAuthenticationException(e.getMessage(), e); -- 2.11.4.GIT