git4idea: Refactored out SSHMain specific properties to a separate bundle

This commit is contained in:
Constantine Plotnikov
2010-03-31 20:17:53 +04:00
parent ca79adad03
commit 1363fe0f86
5 changed files with 75 additions and 21 deletions
@@ -360,15 +360,6 @@ ssh.keyboard.interactive.username=Username:
ssh.new.host.key=<html>Connecting to a new host {0}:{1} that has the key {2} (type {3}).\nDo you want to add this host to known hosts database?</html>
ssh.password.message=Please enter password for user {0}
ssh.password.title=SSH Password Login
sshmain.failed.to.verify.key=Failed to verify key: {0}
sshmain.forwarding.failed=Forwarding {0} failed: {1}
sshmain.invald.host.key=Invald host key {0} {1}
sshmain.invalid.amount.of.arguments=Invalid amount of arguments: {0}
sshmain.invalidpassphrase=Invalid passphrase for the key {0}
sshmain.keyboard.interactive.failed=Keyboard interactive authentication failed.
sshmain.password.failed=Invalid user or password.
sshmain.pk.authenitication.failed=Authentication using key {0} failed.
sshmain.too.mush.passphrase.guesses=Invalid passphrase for the key {0}({1} attempts)
stash.action.name=Stash
stash.button=Create Stash
stash.keep.index.tooltip=If this checkbox is selected, indexed changes are kept in the index.
@@ -22,7 +22,6 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.io.FileUtil;
import com.trilead.ssh2.KnownHosts;
import git4idea.commands.ScriptGenerator;
import git4idea.i18n.GitBundle;
import gnu.trove.THashMap;
import org.apache.commons.codec.DecoderException;
import org.apache.xmlrpc.XmlRpcClientLite;
@@ -120,7 +119,7 @@ public class GitSSHService implements ApplicationComponent {
generator.addInternal(Integer.toString(myXmlRpcServer.getPortNumber()));
generator.addClasses(XmlRpcClientLite.class, DecoderException.class);
generator.addClasses(KnownHosts.class, FileUtil.class);
generator.addResource(GitBundle.class, "/git4idea/i18n/GitBundle.properties");
generator.addResource(SSHMainBundle.class, "/org/jetbrains/git4idea/ssh/SSHMainBundle.properties");
myScriptPath = generator.generate();
}
return myScriptPath;
@@ -19,7 +19,6 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.ArrayUtil;
import com.trilead.ssh2.*;
import com.trilead.ssh2.crypto.PEMDecoder;
import git4idea.i18n.GitBundle;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -243,7 +242,7 @@ public class SSHMain {
return;
}
else {
myLastError = GitBundle.getString("sshmain.keyboard.interactive.failed");
myLastError = SSHMainBundle.getString("sshmain.keyboard.interactive.failed");
}
if (interactiveSupport.myPromptCount == 0 || interactiveSupport.myCancelled) {
// the interactive callback has never been asked or it was cancelled, exit the loop
@@ -270,7 +269,7 @@ public class SSHMain {
return;
}
else {
myLastError = GitBundle.getString("sshmain.password.failed");
myLastError = SSHMainBundle.getString("sshmain.password.failed");
}
}
}
@@ -317,14 +316,14 @@ public class SSHMain {
}
catch (IOException e) {
// decoding failed
myLastError = GitBundle.message("sshmain.invalidpassphrase", keyPath);
myLastError = SSHMainBundle.message("sshmain.invalidpassphrase", keyPath);
continue;
}
break;
}
}
if (i == 0) {
myLastError = GitBundle.message("sshmain.too.mush.passphrase.guesses", keyPath, myHost.getNumberOfPasswordPrompts());
myLastError = SSHMainBundle.message("sshmain.too.mush.passphrase.guesses", keyPath, myHost.getNumberOfPasswordPrompts());
return false;
}
}
@@ -336,7 +335,7 @@ public class SSHMain {
else {
if (passphrase != null) {
// mark as failed authentication only if passphrase were asked
myLastError = GitBundle.message("sshmain.pk.authenitication.failed", keyPath);
myLastError = SSHMainBundle.message("sshmain.pk.authenitication.failed", keyPath);
}
else {
myLastError = "";
@@ -407,7 +406,7 @@ public class SSHMain {
}
}
catch (IOException e) {
System.err.println(GitBundle.message("sshmain.forwarding.failed", name, e.getMessage()));
System.err.println(SSHMainBundle.message("sshmain.forwarding.failed", name, e.getMessage()));
e.printStackTrace();
myExitCode = 1;
if (releaseSemaphore) {
@@ -452,7 +451,7 @@ public class SSHMain {
*/
private static SSHMain parseArguments(String[] args) throws IOException {
if (args.length != 3 && args.length != 5) {
System.err.println(GitBundle.message("sshmain.invalid.amount.of.arguments", Arrays.asList(args)));
System.err.println(SSHMainBundle.message("sshmain.invalid.amount.of.arguments", Arrays.asList(args)));
System.exit(1);
}
int i = 0;
@@ -564,12 +563,12 @@ public class SSHMain {
return true;
}
else {
System.err.println(GitBundle.message("sshmain.invald.host.key", serverHostKeyAlgorithm, fingerprint));
System.err.println(SSHMainBundle.message("sshmain.invald.host.key", serverHostKeyAlgorithm, fingerprint));
return false;
}
}
catch (Throwable t) {
System.err.println(GitBundle.message("sshmain.failed.to.verify.key", t.getMessage()));
System.err.println(SSHMainBundle.message("sshmain.failed.to.verify.key", t.getMessage()));
t.printStackTrace();
return false;
}
@@ -0,0 +1,56 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.git4idea.ssh;
import com.intellij.CommonBundle;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.PropertyKey;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.util.ResourceBundle;
/**
* The bundle for SSH messages
*/
public class SSHMainBundle {
private static Reference<ResourceBundle> ourBundle;
@NonNls
private static final String BUNDLE = "org.jetbrains.git4idea.ssh.SSHMainBundle";
private SSHMainBundle() {
}
public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) {
return CommonBundle.message(getBundle(), key, params);
}
private static ResourceBundle getBundle() {
ResourceBundle bundle = null;
if (ourBundle != null) bundle = ourBundle.get();
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference<ResourceBundle>(bundle);
}
return bundle;
}
public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) {
return getBundle().getString(key);
}
}
@@ -0,0 +1,9 @@
sshmain.failed.to.verify.key=Failed to verify key: {0}
sshmain.forwarding.failed=Forwarding {0} failed: {1}
sshmain.invald.host.key=Invald host key {0} {1}
sshmain.invalid.amount.of.arguments=Invalid amount of arguments: {0}
sshmain.invalidpassphrase=Invalid passphrase for the key {0}
sshmain.keyboard.interactive.failed=Keyboard interactive authentication failed.
sshmain.password.failed=Invalid user or password.
sshmain.pk.authenitication.failed=Authentication using key {0} failed.
sshmain.too.mush.passphrase.guesses=Invalid passphrase for the key {0}({1} attempts)