Two methods, that parse the CVSRoot can throw IllegalArgumentException.
This exception must be catched on appropriate places and handled accordingly.
Also CvsLoginGlobalCheck class removed, since it was mostly a duplicate of CvsLoginCheck
class. The CvsLoginCheck is now using the more generic CommandExecutionContext
instead of the VcsFileSystem.
This is a fix of issue #43228.
1.1 --- a/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/commands/CvsLoginCheck.java Mon Jun 21 14:13:16 2004 +0000
1.2 +++ b/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/commands/CvsLoginCheck.java Mon Jun 21 16:28:46 2004 +0000
1.3 @@ -7,7 +7,7 @@
1.4 * http://www.sun.com/
1.5 *
1.6 * The Original Code is NetBeans. The Initial Developer of the Original
1.7 - * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
1.8 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
1.9 * Microsystems, Inc. All Rights Reserved.
1.10 */
1.11
1.12 @@ -23,7 +23,7 @@
1.13 import org.openide.util.HelpCtx;
1.14
1.15 import org.netbeans.modules.vcscore.Variables;
1.16 -import org.netbeans.modules.vcscore.VcsFileSystem;
1.17 +import org.netbeans.modules.vcscore.commands.CommandExecutionContext;
1.18 import org.netbeans.modules.vcscore.commands.CommandOutputListener;
1.19 import org.netbeans.modules.vcscore.commands.CommandDataOutputListener;
1.20 import org.netbeans.modules.vcscore.cmdline.*;
1.21 @@ -40,10 +40,10 @@
1.22 */
1.23 public class CvsLoginCheck implements VcsAdditionalCommand {
1.24
1.25 - private VcsFileSystem fileSystem = null;
1.26 + private CommandExecutionContext context = null;
1.27
1.28 - public void setFileSystem(VcsFileSystem fileSystem) {
1.29 - this.fileSystem = fileSystem;
1.30 + public void setExecutionContext(CommandExecutionContext context) {
1.31 + this.context = context;
1.32 }
1.33
1.34 /**
1.35 @@ -101,7 +101,7 @@
1.36 StringBuffer message = new StringBuffer();
1.37 boolean loggedIn = false;
1.38 CVSPasswd pasFile = new CVSPasswd((String)null);
1.39 - Object loggedInText = fileSystem.getVariablesAsHashtable().get("LOGGED_IN_TEXT");
1.40 + Object loggedInText = context.getVariablesAsHashtable().get("LOGGED_IN_TEXT");
1.41 vars.clear(); // Not to unnecessarily update too many variables.
1.42 vars.put("LOGGED_IN_TEXT", loggedInText);
1.43 //System.out.println("CvsLoginCheck: putting LOGGED_IN_TEXT = '"+loggedInText+"'");
1.44 @@ -111,59 +111,67 @@
1.45 port = Integer.parseInt(portStr);
1.46 } catch (NumberFormatException nfex) {}
1.47 }
1.48 + boolean validConnectString = true;
1.49 + pasFile.loadPassFile();
1.50 try {
1.51 - pasFile.loadPassFile();
1.52 pasFile.remove(connectStr, port);
1.53 - if (builtIn) {
1.54 - PasswdEntry entry = new PasswdEntry();
1.55 - String scrambledPassword = StandardScrambler.getInstance().scramble(password);
1.56 - entry.setEntry(connectStr+" "+scrambledPassword);
1.57 - if (port > 0) entry.getCVSRoot().setPort(port);
1.58 - loggedIn = pasFile.checkServer(entry);
1.59 - if (loggedIn) {
1.60 + } catch (IllegalArgumentException iaex) {
1.61 + validConnectString = false;
1.62 + message.append(iaex.getLocalizedMessage());
1.63 + }
1.64 + if (validConnectString) {
1.65 + try {
1.66 + if (builtIn) {
1.67 + PasswdEntry entry = new PasswdEntry();
1.68 + String scrambledPassword = StandardScrambler.getInstance().scramble(password);
1.69 + entry.setEntry(connectStr+" "+scrambledPassword);
1.70 + if (port > 0) entry.getCVSRoot().setPort(port);
1.71 + loggedIn = pasFile.checkServer(entry);
1.72 + if (loggedIn) {
1.73 + pasFile.add(connectStr, port, password);
1.74 + pasFile.savePassFile();
1.75 + }
1.76 + } else {
1.77 + //System.out.println("Adding '"+connectStr+"' with password '"+password+"' into "+pasFile.getHome()+"/.cvspass");
1.78 pasFile.add(connectStr, port, password);
1.79 pasFile.savePassFile();
1.80 + loggedIn = CVSPasswd.checkLogin(context, message);
1.81 }
1.82 - } else {
1.83 - //System.out.println("Adding '"+connectStr+"' with password '"+password+"' into "+pasFile.getHome()+"/.cvspass");
1.84 - pasFile.add(connectStr, port, password);
1.85 - pasFile.savePassFile();
1.86 - loggedIn = CVSPasswd.checkLogin(fileSystem, message);
1.87 - }
1.88 - } catch (java.net.UnknownHostException exc) {
1.89 - if (loginPanel != null) {
1.90 - /*
1.91 - DialogDisplayer.getDefault().notify(
1.92 - new NotifyDescriptor.Message(
1.93 - org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.unknownHost")));
1.94 - */
1.95 - loginPanel.loginFinished(org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.unknownHost"));
1.96 - } else {
1.97 - stderrNRListener.outputLine(
1.98 - org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.unknownHost"));
1.99 - }
1.100 - vars.put("USER_IS_LOGGED_IN", "");
1.101 - vars.put(org.netbeans.modules.vcscore.util.VariableInputDialog.VAR_UPDATE_CHANGED_FROM_SELECTOR, "true");
1.102 - return false;
1.103 - } catch (java.io.IOException exc) {
1.104 - if (loginPanel != null) {
1.105 - /*
1.106 - DialogDisplayer.getDefault().notify(
1.107 - new NotifyDescriptor.Message(
1.108 - org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.connectionIOError")));
1.109 - */
1.110 - loginPanel.loginFinished(org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.connectionIOError"));
1.111 - } else {
1.112 - stderrNRListener.outputLine(
1.113 - org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.connectionIOError"));
1.114 - }
1.115 - vars.put("USER_IS_LOGGED_IN", "");
1.116 - vars.put(org.netbeans.modules.vcscore.util.VariableInputDialog.VAR_UPDATE_CHANGED_FROM_SELECTOR, "true");
1.117 - return false;
1.118 - } finally {
1.119 - if (!loggedIn && !builtIn) {
1.120 - pasFile.remove(connectStr, port);
1.121 - pasFile.savePassFile();
1.122 + } catch (java.net.UnknownHostException exc) {
1.123 + if (loginPanel != null) {
1.124 + /*
1.125 + DialogDisplayer.getDefault().notify(
1.126 + new NotifyDescriptor.Message(
1.127 + org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.unknownHost")));
1.128 + */
1.129 + loginPanel.loginFinished(org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.unknownHost"));
1.130 + } else {
1.131 + stderrNRListener.outputLine(
1.132 + org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.unknownHost"));
1.133 + }
1.134 + vars.put("USER_IS_LOGGED_IN", "");
1.135 + vars.put(org.netbeans.modules.vcscore.util.VariableInputDialog.VAR_UPDATE_CHANGED_FROM_SELECTOR, "true");
1.136 + return false;
1.137 + } catch (java.io.IOException exc) {
1.138 + if (loginPanel != null) {
1.139 + /*
1.140 + DialogDisplayer.getDefault().notify(
1.141 + new NotifyDescriptor.Message(
1.142 + org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.connectionIOError")));
1.143 + */
1.144 + loginPanel.loginFinished(org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.connectionIOError"));
1.145 + } else {
1.146 + stderrNRListener.outputLine(
1.147 + org.openide.util.NbBundle.getMessage(CvsLoginDialog.class, "LoginDialog.connectionIOError"));
1.148 + }
1.149 + vars.put("USER_IS_LOGGED_IN", "");
1.150 + vars.put(org.netbeans.modules.vcscore.util.VariableInputDialog.VAR_UPDATE_CHANGED_FROM_SELECTOR, "true");
1.151 + return false;
1.152 + } finally {
1.153 + if (!loggedIn && !builtIn) {
1.154 + pasFile.remove(connectStr, port);
1.155 + pasFile.savePassFile();
1.156 + }
1.157 }
1.158 }
1.159 if (!loggedIn) {
2.1 --- a/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/commands/passwd/CVSPasswd.java Mon Jun 21 14:13:16 2004 +0000
2.2 +++ b/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/commands/passwd/CVSPasswd.java Mon Jun 21 16:28:46 2004 +0000
2.3 @@ -224,7 +224,7 @@
2.4 /**
2.5 * Remove the entry from the current set of entries.
2.6 */
2.7 - public void remove(String entry, int port) {
2.8 + public void remove(String entry, int port) throws IllegalArgumentException {
2.9 PasswdEntry ent = find(entry, port);
2.10 if (ent != null) {
2.11 entries.remove(ent);
2.12 @@ -243,7 +243,7 @@
2.13 * @return the found PasswdEntry, or if not found null.
2.14 * @param current The current cvs root directory
2.15 */
2.16 - public PasswdEntry find(String current, int port) {
2.17 + public PasswdEntry find(String current, int port) throws IllegalArgumentException {
2.18 CVSRoot currentRootWithPort = CVSRoot.parse(current);
2.19 if (port > 0) currentRootWithPort.setPort(port);
2.20 if (currentRootWithPort.getPort() == 0) currentRootWithPort.setPort(STANDARD_PSERVER_PORT);
3.1 --- a/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/commands/passwd/LoginPanel.java Mon Jun 21 14:13:16 2004 +0000
3.2 +++ b/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/commands/passwd/LoginPanel.java Mon Jun 21 16:28:46 2004 +0000
3.3 @@ -205,7 +205,12 @@
3.4 pasFile.loadPassFile();
3.5 password = new String(passwordField.getPassword());
3.6 //entry = new PasswdEntry();
3.7 - pasFile.remove(connectStr, port);
3.8 + try {
3.9 + pasFile.remove(connectStr, port);
3.10 + } catch (IllegalArgumentException iaex) {
3.11 + setStatus(iaex.getLocalizedMessage());
3.12 + return;
3.13 + }
3.14 pasFile.add(connectStr, port, password); //CVSPasswd.scramble(password));
3.15 pasFile.savePassFile();
3.16 //boolean setRight = entry.setEntry(connectStr + " " + CVSPasswd.scramble(password));
3.17 @@ -246,6 +251,9 @@
3.18 } catch (java.io.IOException exc) {
3.19 setStatus(org.openide.util.NbBundle.getBundle(CvsLoginDialog.class).getString("LoginDialog.connectionIOError"));
3.20 return;
3.21 + } catch (IllegalArgumentException iaex) {
3.22 + setStatus(iaex.getLocalizedMessage());
3.23 + return ;
3.24 } finally {
3.25 passwordField.setEnabled(true);
3.26 loginButton.setEnabled(true);
4.1 --- a/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/config/cvs.xml Mon Jun 21 14:13:16 2004 +0000
4.2 +++ b/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/config/cvs.xml Mon Jun 21 16:28:46 2004 +0000
4.3 @@ -3035,7 +3035,7 @@
4.4 </command>
4.5 <command name="CONNECTION_LOGIN">
4.6 <property name="exec">
4.7 - <value>vcs.commands.CvsLoginGlobalCheck.class -gui "${CVSROOT}" "${PASSWORD}"</value>
4.8 + <value>vcs.commands.CvsLoginCheck.class -gui "${CVSROOT}" "${PASSWORD}"</value>
4.9 </property>
4.10 <property name="ignoreFail">
4.11 <value>true</value>