| Method from com.sshtools.common.configuration.SshToolsConnectionProfile Detail: |
public void addAuthenticationMethod(SshAuthenticationClient method) {
if (method != null) {
if (!authMethods.containsKey(method.getMethodName())) {
authMethods.put(method.getMethodName(), method);
}
}
}
|
public void addLocalForwarding(ForwardingConfiguration config) {
if (config != null) {
localForwardings.put(config.getName(), config);
}
}
|
public void addRemoteForwarding(ForwardingConfiguration config) {
if (config != null) {
remoteForwardings.put(config.getName(), config);
}
}
|
public void clearAuthenticationCache() {
SshAuthenticationClient auth;
Properties properties;
for (Iterator it = authMethods.values().iterator(); it.hasNext();) {
auth = (SshAuthenticationClient) it.next();
properties = auth.getPersistableProperties();
auth.reset();
auth.setPersistableProperties(properties);
}
}
|
public boolean disconnectOnSessionClose() {
return disconnectOnSessionClose;
}
|
public boolean getAllowAgentForwarding() {
return allowAgentForwarding;
}
|
public String getApplicationProperty(String name,
String defaultValue) {
String value = (String) applicationProperties.get(name);
if (value == null) {
return defaultValue;
} else {
return value;
}
}
|
public boolean getApplicationPropertyBoolean(String name,
boolean defaultValue) {
try {
return new Boolean(getApplicationProperty(name,
String.valueOf(defaultValue))).booleanValue();
} catch (NumberFormatException nfe) {
return defaultValue;
}
}
|
public Color getApplicationPropertyColor(String name,
Color defaultColor) {
return PropertyUtil.stringToColor(getApplicationProperty(name,
PropertyUtil.colorToString(defaultColor)));
}
|
public int getApplicationPropertyInt(String name,
int defaultValue) {
try {
return Integer.parseInt(getApplicationProperty(name,
String.valueOf(defaultValue)));
} catch (NumberFormatException nfe) {
return defaultValue;
}
}
|
public Map getAuthenticationMethods() {
return authMethods;
}
|
public String getCommandsToExecute() {
return executeCommands;
}
|
public int getOnceAuthenticatedCommand() {
return onceAuthenticated;
}
|
public Map getSftpFavorites() {
return sftpFavorites;
}
|
public void open(String file) throws InvalidProfileFileException {
connectionFile = file;
open(new File(file));
}
|
public void open(File file) throws InvalidProfileFileException {
InputStream in = null;
try {
in = new FileInputStream(file);
open(in);
} catch (FileNotFoundException fnfe) {
throw new InvalidProfileFileException(file + " was not found!");
} finally {
IOUtil.closeStream(in);
}
}
|
public void open(InputStream in) throws InvalidProfileFileException {
try {
SAXParserFactory saxFactory = SAXParserFactory.newInstance();
SAXParser saxParser = saxFactory.newSAXParser();
XMLHandler handler = new XMLHandler();
saxParser.parse(in, handler);
handler = null;
// in.close();
} catch (IOException ioe) {
throw new InvalidProfileFileException("IO error. " +
ioe.getMessage());
} catch (SAXException sax) {
throw new InvalidProfileFileException("SAX Error: " +
sax.getMessage());
} catch (ParserConfigurationException pce) {
throw new InvalidProfileFileException("SAX Parser Error: " +
pce.getMessage());
} finally {
}
}
|
public void removeAuthenticaitonMethod(String method) {
authMethods.remove(method);
}
|
public void removeAuthenticationMethods() {
authMethods.clear();
}
|
public void removeLocalForwarding(String name) {
localForwardings.remove(name);
}
|
public void removeRemoteForwarding(String name) {
remoteForwardings.remove(name);
}
|
public boolean requiresPseudoTerminal() {
return requestPseudoTerminal;
}
|
public void save() throws InvalidProfileFileException {
save(connectionFile);
}
|
public void save(String file) throws InvalidProfileFileException {
try {
File f = new File(file);
FileOutputStream out = new FileOutputStream(f);
out.write(toString().getBytes());
out.close();
} catch (FileNotFoundException fnfe) {
throw new InvalidProfileFileException(file + " was not found!");
} catch (IOException ioe) {
throw new InvalidProfileFileException("io error on " + file);
} finally {
}
}
|
public void setAllowAgentForwarding(boolean allowAgentForwarding) {
this.allowAgentForwarding = allowAgentForwarding;
}
|
public void setApplicationProperty(String name,
String value) {
applicationProperties.put(name, value);
}
|
public void setApplicationProperty(String name,
int value) {
applicationProperties.put(name, String.valueOf(value));
}
|
public void setApplicationProperty(String name,
boolean value) {
applicationProperties.put(name, String.valueOf(value));
}
|
public void setApplicationProperty(String name,
Color value) {
applicationProperties.put(name, PropertyUtil.colorToString(value));
}
|
public void setCommandsToExecute(String executeCommands) {
this.executeCommands = executeCommands;
}
|
public void setDisconnectOnSessionClose(boolean disconnectOnSessionClose) {
this.disconnectOnSessionClose = disconnectOnSessionClose;
}
|
public void setOnceAuthenticatedCommand(int onceAuthenticated) {
this.onceAuthenticated = onceAuthenticated;
}
|
public void setRequiresPseudoTerminal(boolean requiresPseudoTerminal) {
this.requestPseudoTerminal = requiresPseudoTerminal;
}
|
public void setSftpFavorite(String name,
String value) {
sftpFavorites.put(name, value);
}
|
public String toString() {
String xml = "< ?xml version=\"1.0\" encoding=\"UTF-8\"? >\n";
xml += ("< SshToolsConnectionProfile Hostname=\"" + host + "\" Port=\"" +
String.valueOf(port) + "\" Username=\"" + username + "\"" +
" Provider=\"" + getTransportProviderString() + "\" >");
xml += (" < PreferedCipher Client2Server=\"" + prefEncryption +
"\" Server2Client=\"" + prefDecryption + "\"/ >\n");
xml += (" < PreferedMac Client2Server=\"" + prefRecvMac +
"\" Server2Client=\"" + prefSendMac + "\"/ >\n");
xml += (" < PreferedCompression Client2Server=\"" + prefRecvComp +
"\" Server2Client=\"" + prefSendComp + "\"/ >\n");
xml += (" < PreferedPublicKey Name=\"" + prefPK + "\"/ >\n");
xml += (" < PreferedKeyExchange Name=\"" + prefKex + "\"/ >\n");
xml += (" < OnceAuthenticated value=\"" +
String.valueOf(onceAuthenticated) + "\"/ >\n");
if (onceAuthenticated == EXECUTE_COMMANDS) {
xml += (" < ExecuteCommands >" + executeCommands +
"< /ExecuteCommands >\n");
}
Iterator it = authMethods.entrySet().iterator();
Map.Entry entry;
Properties properties;
while (it.hasNext()) {
entry = (Map.Entry) it.next();
xml += (" < AuthenticationMethod Name=\"" + entry.getKey() +
"\" >\n");
SshAuthenticationClient auth = (SshAuthenticationClient) entry.getValue();
properties = auth.getPersistableProperties();
Iterator it2 = properties.entrySet().iterator();
while (it2.hasNext()) {
entry = (Map.Entry) it2.next();
xml += (" < AuthenticationProperty Name=\"" +
entry.getKey() + "\" Value=\"" + entry.getValue() + "\"/ >\n");
}
xml += " < /AuthenticationMethod >\n";
}
it = applicationProperties.entrySet().iterator();
while (it.hasNext()) {
entry = (Map.Entry) it.next();
xml += (" < ApplicationProperty Name=\"" + entry.getKey() +
"\" Value=\"" + entry.getValue() + "\"/ >\n");
}
// Write the SFTP Favorite entries to file
it = sftpFavorites.entrySet().iterator();
while (it.hasNext()) {
entry = (Map.Entry) it.next();
xml += (" < SftpFavorite Name=\"" + entry.getKey() +
"\" Value=\"" + entry.getValue() + "\"/ >\n");
}
it = localForwardings.values().iterator();
xml += (" < ForwardingAutoStart value=\"" +
String.valueOf(forwardingAutoStart) + "\"/ >\n");
while (it.hasNext()) {
ForwardingConfiguration config = (ForwardingConfiguration) it.next();
xml += (" < LocalPortForwarding Name=\"" + config.getName() +
"\" AddressToBind=\"" + config.getAddressToBind() +
"\" PortToBind=\"" + String.valueOf(config.getPortToBind()) +
"\" AddressToConnect=\"" + config.getHostToConnect() +
"\" PortToConnect=\"" + String.valueOf(config.getPortToConnect()) +
"\"/ >\n");
}
it = remoteForwardings.values().iterator();
while (it.hasNext()) {
ForwardingConfiguration config = (ForwardingConfiguration) it.next();
xml += (" < RemotePortForwarding Name=\"" + config.getName() +
"\" AddressToBind=\"" + config.getAddressToBind() +
"\" PortToBind=\"" + String.valueOf(config.getPortToBind()) +
"\" AddressToConnect=\"" + config.getHostToConnect() +
"\" PortToConnect=\"" + String.valueOf(config.getPortToConnect()) +
"\"/ >\n");
}
xml += "< /SshToolsConnectionProfile >";
return xml;
}
|