perfsonar-dev - perfsonar: r3276 - in trunk/geant2_java-sshtelnet-mp: conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters lib/misc src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/encryption src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters src/main/java/org/perfsonar/service/measurementPoint/remote/ssh
Subject: perfsonar development work
List archive
perfsonar: r3276 - in trunk/geant2_java-sshtelnet-mp: conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters lib/misc src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/encryption src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters src/main/java/org/perfsonar/service/measurementPoint/remote/ssh
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3276 - in trunk/geant2_java-sshtelnet-mp: conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters lib/misc src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/encryption src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters src/main/java/org/perfsonar/service/measurementPoint/remote/ssh
- Date: Mon, 28 Jan 2008 10:28:14 -0500
Author: melis
Date: 2008-01-28 10:28:13 -0500 (Mon, 28 Jan 2008)
New Revision: 3276
Added:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/remote/ssh/MyUserInfo.java
Removed:
trunk/geant2_java-sshtelnet-mp/lib/misc/perfsonar-base-ant-1.0.20071210.jar
Modified:
trunk/geant2_java-sshtelnet-mp/conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.class
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/CiscoKeyBgpAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/CiscoSshBgpAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/JuniperKeyBgpAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/JuniperSshBgpAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/encryption/PasswordEncryptor.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/CiscoSshAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/RequestExecutingThread.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/WebserviceEngineAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/CiscoKeyIpAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/CiscoSshIpAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/JuniperKeyIpAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/JuniperSshIpAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/CiscoKeyIpv6Adapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/CiscoSshIpv6Adapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/JuniperKeyIpv6Adapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/JuniperSshIpv6Adapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/CiscoKeyStatusAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/CiscoSshStatusAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/JuniperKeyStatusAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/JuniperSshStatusAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/remote/ssh/SshKeyManager.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/remote/ssh/SshManager.java
Log:
added a bugfix which prevented the ssh side of the mp to fail
added a default value for the access rate to the configuration script
Modified:
trunk/geant2_java-sshtelnet-mp/conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.class
===================================================================
(Binary files differ)
Deleted:
trunk/geant2_java-sshtelnet-mp/lib/misc/perfsonar-base-ant-1.0.20071210.jar
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/CiscoKeyBgpAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/CiscoKeyBgpAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/CiscoKeyBgpAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -200,17 +200,18 @@
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
- manager = new SshKeyManager(url, username, keyUrl, false,
timeout);
-
+ if (passphrase == null || passphrase.equals("")) {
+ manager = new SshKeyManager(url, username, keyUrl,
false, timeout);
+ } else manager = new SshKeyManager(url, username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase), false, timeout);
}
logger.info("[CiscoKeyBgpAdapter] Trying to connect");
- if (passphrase == null || passphrase.equals("")) {
- manager.connect(username, keyUrl);
- } else {
- manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
- }
+ //if (passphrase == null || passphrase.equals("")) {
+ //manager.connect(username, keyUrl);
+ //} else {
+ //manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
+ //}
logger.info("[CiscoKeyBgpAdapter] Login");
} catch (Exception e) {
@@ -386,7 +387,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- CiscoKeyBgpAdapter adapter = new CiscoKeyBgpAdapter();
+ //CiscoKeyBgpAdapter adapter = new CiscoKeyBgpAdapter();
availableSpecificCommands = new ArrayList();
@@ -473,8 +474,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(bgpCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(bgpCommand).getResult();
}
@@ -509,8 +510,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(bgpCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(bgpCommand).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/CiscoSshBgpAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/CiscoSshBgpAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/CiscoSshBgpAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -206,7 +206,7 @@
logger.info("[CiscoSshBgpAdapter] Trying to connect");
- manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
+ //manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
logger.info("[CiscoSshBgpAdapter Login");
@@ -321,6 +321,8 @@
*/
private String filterResult(String temp, BgpCommandInterface bgpCommand)
{
+ //logger.debug("result: " + temp);
+
String temp1;
String temp2;
while (temp.indexOf(" --More-- ") > -1) {
@@ -331,11 +333,11 @@
}
- String tempResult = temp;
-// .substring((bgpCommand.getCommand() + " " +
bgpCommand
-//
.getParameterString()).length());
+ //String tempResult = temp
+ // .substring((bgpCommand.getCommand() + " " +
bgpCommand
+ // .getParameterString()).length());
- String t1 = tempResult.replaceAll("\\n", "");
+ String t1 = temp.replaceAll("\\n", "");
String t2 = t1.replaceAll("\\r", "@@@");
StringBuffer resultBuffer = new StringBuffer(t2);
@@ -385,7 +387,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- CiscoSshBgpAdapter adapter = new CiscoSshBgpAdapter();
+ //CiscoSshBgpAdapter adapter = new CiscoSshBgpAdapter();
// REPLACED
@@ -398,19 +400,21 @@
prompt = properties.getProperty(subject, "prompt");
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
+ username = properties.getProperty(subject, "username");
+ password = properties.getProperty(subject, "password");
manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
} catch (NumberFormatException e1) {
- logger.error("[CISCOSSHBGPADAPTER][TakeAction]" +
e1.getStackTrace().toString());
+ logger.error("[CISCOSSHBGPADAPTER][TakeAction]" +
e1.getStackTrace()[0].toString());
throw new PerfSONARException(
"error.mp.sshtelnet.configuration",
"Invalid port number in configuration");
} catch (PerfSONARException e1) {
- logger.error("[CISCOSSHBGPADAPTER][TakeAction]" +
e1.getStackTrace().toString());
+ logger.error("[CISCOSSHBGPADAPTER][TakeAction]" +
e1.getStackTrace()[0].toString());
throw new PerfSONARException("error.mp.sshtelnet.configuration",
"Unable to retrieve connection details");
@@ -474,8 +478,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(bgpCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(bgpCommand).getResult();
}
@@ -510,8 +514,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(bgpCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(bgpCommand).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/JuniperKeyBgpAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/JuniperKeyBgpAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/JuniperKeyBgpAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -199,17 +199,19 @@
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
- manager = new SshKeyManager(url, username, keyUrl, false,
timeout);
-
+ if (passphrase == null || passphrase.equals("")) {
+ manager = new SshKeyManager(url, username, keyUrl,
false, timeout);
+ } else manager = new SshKeyManager(url, username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase), false, timeout);
+
}
logger.info("[JuniperKeyBgpAdapter] Trying to connect");
- if (passphrase == null || passphrase.equals("")) {
- manager.connect(username, keyUrl);
- } else {
- manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
- }
+ //if (passphrase == null || passphrase.equals("")) {
+ //manager.connect(username, keyUrl);
+ //} else {
+ //manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
+ //}
logger.info("[JuniperKeyBgpAdapter] Login");
} catch (Exception e) {
@@ -399,7 +401,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- JuniperKeyBgpAdapter adapter = new JuniperKeyBgpAdapter();
+ //JuniperKeyBgpAdapter adapter = new JuniperKeyBgpAdapter();
availableSpecificCommands = new ArrayList();
@@ -486,8 +488,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(bgpCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(bgpCommand).getResult();
}
@@ -522,8 +524,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(bgpCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(bgpCommand).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/JuniperSshBgpAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/JuniperSshBgpAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/JuniperSshBgpAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -208,7 +208,7 @@
logger.info("[JuniperSshBgpAdapter] Trying to connect");
- manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
+ //manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
logger.info("[JuniperSshBgpAdapter Login");
@@ -401,7 +401,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- JuniperSshBgpAdapter adapter = new JuniperSshBgpAdapter();
+ //JuniperSshBgpAdapter adapter = new JuniperSshBgpAdapter();
// REPLACED
@@ -414,7 +414,9 @@
prompt = properties.getProperty(subject, "prompt");
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
-
+ username = properties.getProperty(subject, "username");
+ password = properties.getProperty(subject, "password");
+
manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
} catch (NumberFormatException e1) {
@@ -490,9 +492,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(bgpCommand).getResult();
-
+ this.connect(subject);
+ temp = this.executeCommand(bgpCommand).getResult();
}
} else if (valid) {
@@ -526,8 +527,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(bgpCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(bgpCommand).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/encryption/PasswordEncryptor.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/encryption/PasswordEncryptor.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/encryption/PasswordEncryptor.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -8,6 +8,7 @@
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
+
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
@@ -15,8 +16,11 @@
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
+
import org.apache.ws.security.util.Base64;
+
+
/**
* Class for encrypting and decrypting plain-text password fields in the
* metadataconfiguration-file.
@@ -32,6 +36,7 @@
* @param pass
* @return String encryptedPassword
*/
+
public static String encryptPassword(String pass) {
String result = "";
@@ -84,12 +89,14 @@
return result;
}
+
/**
* Decrypting the supplied parameter into a plain-text version
*
* @param pass
* @return String plain-text password
*/
+
public static String decryptPassword(String pass) {
String result = "";
@@ -141,4 +148,6 @@
return result;
}
+
+
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/CiscoSshAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/CiscoSshAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/CiscoSshAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -12,9 +12,17 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.security.Provider;
+import java.security.Security;
+import java.security.Provider.Service;
+import java.util.Iterator;
+import java.util.Set;
+import javax.swing.SwingUtilities;
+
import org.ggf.ns.nmwg.base.v2_0.EventType;
import org.ggf.ns.nmwg.base.v2_0.Message;
import org.ggf.ns.nmwg.base.v2_0.Metadata;
@@ -26,12 +34,14 @@
import org.perfsonar.base.exceptions.PerfSONARException;
import org.perfsonar.service.base.engine.ServiceEngine;
import
org.perfsonar.service.measurementPoint.lookingGlassType.bgp.adapters.CiscoSshBgpAdapter;
+
import
org.perfsonar.service.measurementPoint.lookingGlassType.ip.adapters.CiscoSshIpAdapter;
import
org.perfsonar.service.measurementPoint.lookingGlassType.ipv6.adapters.CiscoSshIpv6Adapter;
import
org.perfsonar.service.measurementPoint.lookingGlassType.metadata.DbMetadataConfiguration;
import
org.perfsonar.service.measurementPoint.lookingGlassType.metadata.MetadataConfiguration;
import
org.perfsonar.service.measurementPoint.lookingGlassType.status.adapters.CiscoSshStatusAdapter;
+
/**
* Implementation class that supports querying the device (Juniper) for
* ip information
@@ -101,6 +111,7 @@
}
+
/**
* @see ServiceEngine.java
*/
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/RequestExecutingThread.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/RequestExecutingThread.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/RequestExecutingThread.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -8,6 +8,16 @@
*/
package
org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.Provider;
+import java.security.Security;
+import java.security.Provider.Service;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.swing.SwingUtilities;
+
import org.ggf.ns.nmwg.base.v2_0.Data;
import org.ggf.ns.nmwg.base.v2_0.EventType;
import org.ggf.ns.nmwg.base.v2_0.Message;
@@ -18,6 +28,7 @@
import org.perfsonar.service.base.engine.ServiceEngine;
import org.perfsonar.service.base.engine.ServiceEngineFactory;
+
/**
* Thread for executing the retrieval process of a command on a certain
* device
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -677,11 +677,13 @@
param.setAttribute("name", "prompt");
param.setAttribute("value", input);
params.addContent(param);
- System.out.println("Please give the access rate for
device (in ms): " + device + ": ");
+ System.out.println("Please give the access rate for
device (in ms): " + device + ": [default: 100]");
input = br.readLine();
valid = false;
while (!valid){
try {
+ if (input == null || input.equals(""))
+ input = "100";
if (Integer.parseInt(input) < 0){
System.out.println("Please
provide a positive number.");
input = br.readLine();
@@ -719,11 +721,13 @@
param.setAttribute("value",
PasswordEncryptor.encryptPassword(input));
params.addContent(param);
- System.out.println("Please give the timeout for the
device: " + device + "(enter 0 if you don't want to use a timeout): ");
+ System.out.println("Please give the timeout for the
device: " + device + "\n(enter 0 or leave blank if you don't want to use a
timeout): ");
input = br.readLine();
valid = false;
while (!valid){
try {
+ if (input == null || input.equals(""))
+ input = "0";
if (Integer.parseInt(input) < 0){
System.out.println("Please
provide a positive number.");
input = br.readLine();
@@ -738,11 +742,13 @@
param.setAttribute("name", "timeout");
param.setAttribute("value", input);
params.addContent(param);
- System.out.println("Please give the maximum number
of users for the device: " + device + "(enter 0 if you want an unlimited
amount of users): ");
+ System.out.println("Please give the maximum number
of users for the device: " + device + "\n(enter 0 or leave blank if you want
an unlimited amount of users): ");
input = br.readLine();
valid = false;
while (!valid){
try {
+ if (input == null || input.equals(""))
+ input = "0";
if (Integer.parseInt(input) < 0){
System.out.println("Please
provide a positive number.");
input = br.readLine();
@@ -811,11 +817,13 @@
param.setAttribute("name", "prompt");
param.setAttribute("value", input);
params.addContent(param);
- System.out.println("Please give the access rate for
device (in ms): " + device + ": ");
+ System.out.println("Please give the access rate for
device (in ms): " + device + ": [default: 100]");
input = br.readLine();
valid = false;
while (!valid){
try {
+ if (input == null || input.equals(""))
+ input = "100";
if (Integer.parseInt(input) < 0){
System.out.println("Please
provide a positive number.");
input = br.readLine();
@@ -864,11 +872,13 @@
}
- System.out.println("Please give the timeout for the
device: " + device + "(enter 0 if you don't want to use a timeout): ");
+ System.out.println("Please give the timeout for the
device: " + device + "\n(enter 0 or leave blank if you don't want to use a
timeout): ");
input = br.readLine();
valid = false;
while (!valid){
try {
+ if (input == null || input.equals(""))
+ input = "0";
if (Integer.parseInt(input) < 0){
System.out.println("Please
provide a positive number.");
input = br.readLine();
@@ -883,11 +893,13 @@
param.setAttribute("name", "timeout");
param.setAttribute("value", input);
params.addContent(param);
- System.out.println("Please give the maximum number
of users for the device: " + device + "(enter 0 if you want an unlimited
amount of users): ");
+ System.out.println("Please give the maximum number
of users for the device: " + device + "\n(enter 0 or leave blank if you want
an unlimited amount of users): ");
input = br.readLine();
valid = false;
while (!valid){
try {
+ if (input == null || input.equals(""))
+ input = "0";
if (Integer.parseInt(input) < 0){
System.out.println("Please
provide a positive number.");
input = br.readLine();
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/WebserviceEngineAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/WebserviceEngineAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/WebserviceEngineAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -9,10 +9,19 @@
package
org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters;
import java.awt.Toolkit;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.Provider;
+import java.security.Security;
+import java.security.Provider.Service;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import java.util.StringTokenizer;
+import javax.crypto.Cipher;
+import javax.swing.SwingUtilities;
+
import org.ggf.ns.nmwg.base.v2_0.Data;
import org.ggf.ns.nmwg.base.v2_0.EventType;
import org.ggf.ns.nmwg.base.v2_0.Message;
@@ -28,9 +37,11 @@
import org.perfsonar.base.exceptions.PerfSONARException;
import org.perfsonar.service.base.engine.ActionType;
import org.perfsonar.service.base.engine.ServiceEngine;
+//import
org.perfsonar.service.measurementPoint.lookingGlassType.metadata.DbMetadataConfiguration;
import
org.perfsonar.service.measurementPoint.lookingGlassType.metadata.DbMetadataConfiguration;
import
org.perfsonar.service.measurementPoint.lookingGlassType.metadata.MetadataConfiguration;
+
/**
* Implementation class that filters and forwards request based upon the
* requested device in the subject of the requestMessage.
@@ -107,6 +118,8 @@
/**
* @see ServiceEngine.java
*/
+
+
public Message takeAction(String actionType, Message request)
throws PerfSONARException {
@@ -544,4 +557,5 @@
//e.printStackTrace();
}
}
+
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/CiscoKeyIpAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/CiscoKeyIpAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/CiscoKeyIpAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -240,15 +240,17 @@
caching =
Integer.parseInt(properties.getProperty(subject, "cache"));
timeout =
Integer.parseInt(properties.getProperty(subject, "timeout"));
- manager = new SshKeyManager(url, username,
keyUrl, false, timeout);
-
+ if (passphrase == null ||
passphrase.equals("")) {
+ manager = new SshKeyManager(url, username, keyUrl,
false, timeout);
+ } else manager = new SshKeyManager(url, username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase), false, timeout);
+
}
logger.info("[CiscoKeyIpAdapter] Trying to connect");
- if (passphrase == null || passphrase.equals(""))
- manager.connect(username, keyUrl);
- else manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
+ //if (passphrase == null || passphrase.equals(""))
+ //manager.connect(username, keyUrl);
+ //else manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
logger.info("[CiscoKeyIpAdapter] Login");
} catch (Exception e) {
@@ -432,7 +434,7 @@
//eventTypeString =
eventTypeString.substring(ServicePropertiesConfigurator.EVENTTYPE_PREFIX.length()-1,
eventTypeString.lastIndexOf("/"));
- CiscoKeyIpAdapter adapter = new CiscoKeyIpAdapter();
+ //CiscoKeyIpAdapter adapter = new CiscoKeyIpAdapter();
//adapter.connect(subject);
@@ -536,8 +538,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp =
adapter.executeCommand(ipCommand).getResult();
+ this.connect(subject);
+ temp =
this.executeCommand(ipCommand).getResult();
}
@@ -575,8 +577,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp =
adapter.executeCommand(ipCommand).getResult();
+ this.connect(subject);
+ temp =
this.executeCommand(ipCommand).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/CiscoSshIpAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/CiscoSshIpAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/CiscoSshIpAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -212,12 +212,12 @@
//System.out.println(username);
//System.out.println(password);
- manager = new SshManager(url, username, password, false,
timeout);
+ manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
}
logger.info("[CiscoSshIpAdapter] Trying to connect");
- manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
+ //manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
logger.info("[CiscoSshIpAdapter Login");
@@ -332,6 +332,8 @@
*/
private String filterResult(String temp, IpCommandInterface ipCommand) {
+ //logger.debug("result: " + temp);
+
String temp1;
String temp2;
while (temp.indexOf(" --More-- ") > -1) {
@@ -342,11 +344,9 @@
}
- String tempResult = temp;
-// .substring((ipCommand.getCommand() + " " +
ipCommand
-//
.getParameterString()).length());
+ //String tempResult = temp.substring((ipCommand.getCommand() + " "
+ ipCommand.getParameterString()).length());
- String t1 = tempResult.replaceAll("\\n", "");
+ String t1 = temp.replaceAll("\\n", "");
String t2 = t1.replaceAll("\\r", "@@@");
StringBuffer resultBuffer = new StringBuffer(t2);
@@ -396,7 +396,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- CiscoSshIpAdapter adapter = new CiscoSshIpAdapter();
+ //CiscoSshIpAdapter adapter = new CiscoSshIpAdapter();
// REPLACED
@@ -409,19 +409,21 @@
prompt = properties.getProperty(subject, "prompt");
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
+ username = properties.getProperty(subject, "username");
+ password = properties.getProperty(subject, "password");
manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
} catch (NumberFormatException e1) {
- logger.error("[CISCOSSHIPADAPTER][TakeAction]" +
e1.getStackTrace().toString());
+ logger.error("[CISCOSSHIPADAPTER][TakeAction]" +
e1.getStackTrace()[0].toString());
throw new PerfSONARException(
"error.mp.sshtelnet.configuration",
"Invalid port number in configuration");
} catch (PerfSONARException e1) {
- logger.error("[CISCOSSHIPADAPTER][TakeAction]" +
e1.getStackTrace().toString());
+ logger.error("[CISCOSSHIPADAPTER][TakeAction]" +
e1.getStackTrace()[0].toString());
throw new PerfSONARException("error.mp.sshtelnet.configuration",
"Unable to retrieve connection details");
@@ -485,8 +487,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipCommand).getResult();
}
@@ -521,8 +523,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipCommand).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/JuniperKeyIpAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/JuniperKeyIpAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/JuniperKeyIpAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -213,17 +213,19 @@
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
- manager = new SshKeyManager(url, username, keyUrl, false,
timeout);
-
+ if (passphrase == null || passphrase.equals("")) {
+ manager = new SshKeyManager(url, username, keyUrl,
false, timeout);
+ } else manager = new SshKeyManager(url, username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase), false, timeout);
+
}
logger.info("[JuniperKeyIpAdapter] Trying to connect");
- if (passphrase == null || passphrase.equals("")) {
- manager.connect(username, keyUrl);
- } else {
- manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
- }
+ //if (passphrase == null || passphrase.equals("")) {
+ //manager.connect(username, keyUrl);
+ //} else {
+ //manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
+ //}
logger.info("[JuniperKeyIpAdapter] Login");
} catch (Exception e) {
@@ -412,7 +414,7 @@
//eventTypeString =
eventTypeString.substring(ServicePropertiesConfigurator.EVENTTYPE_PREFIX.length()-1,
eventTypeString.lastIndexOf("/"));
- JuniperKeyIpAdapter adapter = new JuniperKeyIpAdapter();
+ //JuniperKeyIpAdapter adapter = new JuniperKeyIpAdapter();
//adapter.connect(subject);
@@ -509,8 +511,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipCommand).getResult();
}
@@ -545,8 +547,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipCommand).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/JuniperSshIpAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/JuniperSshIpAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/JuniperSshIpAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -213,13 +213,13 @@
//System.out.println(username);
//System.out.println(password);
- manager = new SshManager(url, username, password, false,
timeout);
+ manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
}
logger.info("[JuniperSshIpAdapter] Trying to connect");
- manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
+ //manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
logger.info("[JuniperSshIpAdapter Login");
@@ -412,7 +412,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- JuniperSshIpAdapter adapter = new JuniperSshIpAdapter();
+ //JuniperSshIpAdapter adapter = new JuniperSshIpAdapter();
// REPLACED
@@ -425,7 +425,9 @@
prompt = properties.getProperty(subject, "prompt");
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
-
+ username = properties.getProperty(subject, "username");
+ password = properties.getProperty(subject, "password");
+
manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
} catch (NumberFormatException e1) {
@@ -501,8 +503,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipCommand).getResult();
}
@@ -537,8 +539,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipCommand).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/CiscoKeyIpv6Adapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/CiscoKeyIpv6Adapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/CiscoKeyIpv6Adapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -204,17 +204,19 @@
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
- manager = new SshKeyManager(url, username, keyUrl, false,
timeout);
-
+ if (passphrase == null || passphrase.equals("")) {
+ manager = new SshKeyManager(url, username, keyUrl,
false, timeout);
+ } else manager = new SshKeyManager(url, username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase), false, timeout);
+
}
logger.info("[CiscoKeyIpv6Adapter] Trying to connect");
- if (passphrase == null || passphrase.equals("")) {
- manager.connect(username, keyUrl);
- } else {
- manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
- }
+ //if (passphrase == null || passphrase.equals("")) {
+ // manager.connect(username, keyUrl);
+ //} else {
+ // manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
+ //}
logger.info("[CiscoKeyIpv6Adapter] Login");
} catch (Exception e) {
@@ -391,7 +393,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- CiscoKeyIpv6Adapter adapter = new CiscoKeyIpv6Adapter();
+ //CiscoKeyIpv6Adapter adapter = new CiscoKeyIpv6Adapter();
availableSpecificCommands = new ArrayList();
@@ -478,8 +480,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipv6Command).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipv6Command).getResult();
}
@@ -514,8 +516,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipv6Command).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipv6Command).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/CiscoSshIpv6Adapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/CiscoSshIpv6Adapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/CiscoSshIpv6Adapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -202,13 +202,13 @@
//System.out.println(username);
//System.out.println(password);
- manager = new SshManager(url, username, password, false,
timeout);
+ manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
}
logger.info("[CiscoSshIpv6Adapter] Trying to connect");
- manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
+ //manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
logger.info("[CiscoSshIpv6Adapter Login");
@@ -323,6 +323,8 @@
*/
private String filterResult(String temp, Ipv6CommandInterface
ipv6Command) {
+ //logger.debug("result: "+temp);
+
String temp1;
String temp2;
while (temp.indexOf(" --More-- ") > -1) {
@@ -333,9 +335,9 @@
}
- String tempResult = temp.substring((ipv6Command.getCommand() + " "
+ ipv6Command.getParameterString()).length());
+ //String tempResult = temp.substring((ipv6Command.getCommand() + "
" + ipv6Command.getParameterString()).length());
- String t1 = tempResult.replaceAll("\\n", "");
+ String t1 = temp.replaceAll("\\n", "");
logger.debug(t1);
String t2 = t1.replaceAll("\\r", "@@@");
logger.debug(t2);
@@ -387,7 +389,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- CiscoSshIpv6Adapter adapter = new CiscoSshIpv6Adapter();
+ //CiscoSshIpv6Adapter adapter = new CiscoSshIpv6Adapter();
// REPLACED
@@ -400,31 +402,33 @@
prompt = properties.getProperty(subject, "prompt");
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
-
+ username = properties.getProperty(subject, "username");
+ password = properties.getProperty(subject, "password");
+
manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
} catch (NumberFormatException e1) {
- logger.error("[CISCOSSHIPv6ADAPTER][TakeAction]" +
e1.getStackTrace().toString());
+ logger.error("[CISCOSSHIPv6ADAPTER][TakeAction]" +
e1.getStackTrace()[0].toString());
throw new PerfSONARException(
"error.mp.sshtelnet.configuration",
"Invalid port number in configuration");
} catch (PerfSONARException e1) {
- logger.error("[CISCOSSHIPv6ADAPTER][TakeAction]" +
e1.getStackTrace().toString());
+ logger.error("[CISCOSSHIPv6ADAPTER][TakeAction]" +
e1.getStackTrace()[0].toString());
throw new PerfSONARException("error.mp.sshtelnet.configuration",
"Unable to retrieve connection details");
}
- logger.debug("[CiscoStatusAdapter] SshManager created: " + url + " "
+ port);
+ logger.debug("[CiscoSshIpv6Adapter] SshManager created: " + url + "
" + port);
//This private method call will include all supported methods
//that can be performed on the remote device
configureCommands(subject);
- //
+
Ipv6CommandInterface ipv6Command = this.getCommand(eventTypeString);
@@ -476,8 +480,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipv6Command).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipv6Command).getResult();
}
@@ -512,8 +516,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipv6Command).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipv6Command).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/JuniperKeyIpv6Adapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/JuniperKeyIpv6Adapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/JuniperKeyIpv6Adapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -204,17 +204,18 @@
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
- manager = new SshKeyManager(url, username, keyUrl, false,
timeout);
-
+ if (passphrase == null || passphrase.equals(""))
+ manager = new SshKeyManager(url, username, keyUrl,
false, timeout);
+ else manager = new SshKeyManager(url, username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase), false, timeout);
}
logger.info("[JuniperKeyIpv6Adapter] Trying to connect");
- if (passphrase == null || passphrase.equals("")) {
- manager.connect(username, keyUrl);
- } else {
- manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
- }
+ //if (passphrase == null || passphrase.equals("")) {
+ // manager.connect(username, keyUrl);
+ //} else {
+ // manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
+ //}
logger.info("[JuniperKeyIpv6Adapter] Login");
} catch (Exception e) {
@@ -405,7 +406,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- JuniperKeyIpv6Adapter adapter = new JuniperKeyIpv6Adapter();
+ //JuniperKeyIpv6Adapter adapter = new JuniperKeyIpv6Adapter();
availableSpecificCommands = new ArrayList();
@@ -492,8 +493,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipv6Command).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipv6Command).getResult();
}
@@ -528,8 +529,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipv6Command).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipv6Command).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/JuniperSshIpv6Adapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/JuniperSshIpv6Adapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/JuniperSshIpv6Adapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -202,13 +202,13 @@
//System.out.println(username);
//System.out.println(password);
- manager = new SshManager(url, username, password, false,
timeout);
+ manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
}
logger.info("[JuniperSshIpv6Adapter] Trying to connect");
- manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
+ //manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
logger.info("[JuniperSshIpv6Adapter Login");
@@ -401,7 +401,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- JuniperSshIpv6Adapter adapter = new JuniperSshIpv6Adapter();
+ //JuniperSshIpv6Adapter adapter = new JuniperSshIpv6Adapter();
// REPLACED
@@ -414,7 +414,9 @@
prompt = properties.getProperty(subject, "prompt");
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
-
+ username = properties.getProperty(subject, "username");
+ password = properties.getProperty(subject, "password");
+
manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
} catch (NumberFormatException e1) {
@@ -490,8 +492,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipv6Command).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipv6Command).getResult();
}
@@ -526,8 +528,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(ipv6Command).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(ipv6Command).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/CiscoKeyStatusAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/CiscoKeyStatusAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/CiscoKeyStatusAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -206,17 +206,18 @@
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
- manager = new SshKeyManager(url, username, keyUrl, false,
timeout);
-
+ if (passphrase == null || passphrase.equals(""))
+ manager = new SshKeyManager(url, username, keyUrl,
false, timeout);
+ else manager = new SshKeyManager(url, username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase), false, timeout);
}
logger.info("[CiscoKeyStatusAdapter] Trying to connect");
- if (passphrase == null || passphrase.equals("")) {
- manager.connect(username, keyUrl);
- } else {
- manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
- }
+ //if (passphrase == null || passphrase.equals("")) {
+ // manager.connect(username, keyUrl);
+ //} else {
+ // manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
+ //}
logger.info("[CiscoKeyStatusAdapter] Login");
} catch (Exception e) {
@@ -394,7 +395,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- CiscoKeyStatusAdapter adapter = new CiscoKeyStatusAdapter();
+ //CiscoKeyStatusAdapter adapter = new CiscoKeyStatusAdapter();
availableSpecificCommands = new ArrayList();
@@ -481,8 +482,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(statusCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(statusCommand).getResult();
}
@@ -517,8 +518,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(statusCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(statusCommand).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/CiscoSshStatusAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/CiscoSshStatusAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/CiscoSshStatusAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -5,10 +5,18 @@
*/
package
org.perfsonar.service.measurementPoint.lookingGlassType.status.adapters;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.Provider;
+import java.security.Security;
+import java.security.Provider.Service;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
+import javax.swing.SwingUtilities;
+
import org.ggf.ns.nmwg.base.v2_0.Data;
import org.ggf.ns.nmwg.base.v2_0.Datum;
import org.ggf.ns.nmwg.base.v2_0.EventType;
@@ -25,6 +33,7 @@
import org.perfsonar.service.base.engine.ServiceEngine;
import
org.perfsonar.service.measurementPoint.lookingGlassType.encryption.PasswordEncryptor;
import
org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.ServicePropertiesConfigurator;
+
import
org.perfsonar.service.measurementPoint.lookingGlassType.engine.commands.ParameterChecker;
import
org.perfsonar.service.measurementPoint.lookingGlassType.metadata.DbMetadataConfiguration;
import
org.perfsonar.service.measurementPoint.lookingGlassType.metadata.MetadataConfiguration;
@@ -77,14 +86,6 @@
this.properties = new DbMetadataConfiguration();
properties.initStorage();
- /*try {
- properties.getProperties().store(new
FileOutputStream("eend.properties"), "");
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }*/
-
this.serviceEngineType =
"service.MeasurementPoint.TELNETSSHType";
//FOR LOCAL TESTING
@@ -208,15 +209,16 @@
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
//System.out.println(username);
- //System.out.println(password);
+
//System.out.println(PasswordEncryptor.decryptPassword(password));
+ //System.out.println(url);
- manager = new SshManager(url, username, password, false,
timeout);
+ manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
}
logger.info("[CiscoSshStatusAdapter] Trying to connect");
- manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
+ //manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
logger.info("[CiscoSshStatusAdapter Login");
@@ -331,6 +333,8 @@
*/
private String filterResult(String temp, StatusCommandInterface
statusCommand) {
+ //logger.debug("result: " + temp);
+
String temp1;
String temp2;
while (temp.indexOf(" --More-- ") > -1) {
@@ -341,13 +345,11 @@
}
- String tempResult = temp.substring((statusCommand.getCommand() + "
" + statusCommand.getParameterString()).length());
+ //String tempResult = temp.substring((statusCommand.getCommand() + "
" + statusCommand.getParameterString()).length());
- String t1 = tempResult.replaceAll("\\n", "");
- logger.debug(t1);
+ String t1 = temp.replaceAll("\\n", "");
String t2 = t1.replaceAll("\\r", "@@@");
- logger.debug(t2);
-
+
StringBuffer resultBuffer = new StringBuffer(t2);
for (int i = 0; i < resultBuffer.length(); i++) {
@@ -372,6 +374,7 @@
}
+
/**
* @see ServiceEngine.java
*/
@@ -395,7 +398,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- CiscoSshStatusAdapter adapter = new CiscoSshStatusAdapter();
+ //CiscoSshStatusAdapter adapter = new CiscoSshStatusAdapter();
// REPLACED
@@ -404,6 +407,8 @@
try {
url = properties.getProperty(subject, "url");
+ username = properties.getProperty(subject, "username");
+ password = properties.getProperty(subject, "password");
port = Integer.parseInt(properties.getProperty(subject, "port"));
prompt = properties.getProperty(subject, "prompt");
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
@@ -413,14 +418,14 @@
} catch (NumberFormatException e1) {
- logger.error("[CISCOSSHSTATUSADAPTER][TakeAction]" +
e1.getStackTrace().toString());
+ logger.error("[CISCOSSHSTATUSADAPTER][TakeAction]" +
e1.getStackTrace()[0].toString());
throw new PerfSONARException(
"error.mp.sshtelnet.configuration",
"Invalid port number in configuration");
} catch (PerfSONARException e1) {
- logger.error("[CISCOSSHSTATUSADAPTER][TakeAction]" +
e1.getStackTrace().toString());
+ logger.error("[CISCOSSHSTATUSADAPTER][TakeAction]" +
e1.getStackTrace()[0].toString());
throw new PerfSONARException("error.mp.sshtelnet.configuration",
"Unable to retrieve connection details");
@@ -484,8 +489,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(statusCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(statusCommand).getResult();
}
@@ -520,8 +525,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(statusCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(statusCommand).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/JuniperKeyStatusAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/JuniperKeyStatusAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/JuniperKeyStatusAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -206,17 +206,18 @@
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
- manager = new SshKeyManager(url, username, keyUrl, false,
timeout);
-
+ if (passphrase == null || passphrase.equals(""))
+ manager = new SshKeyManager(url, username, keyUrl,
false, timeout);
+ else manager = new SshKeyManager(url, username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase), false, timeout);
}
logger.info("[JuniperKeyStatusAdapter] Trying to connect");
- if (passphrase == null || passphrase.equals("")) {
- manager.connect(username, keyUrl);
- } else {
- manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
- }
+ //if (passphrase == null || passphrase.equals("")) {
+ // manager.connect(username, keyUrl);
+ //} else {
+ // manager.connect(username, keyUrl,
PasswordEncryptor.decryptPassword(passphrase));
+ //}
logger.info("[JuniperKeyStatusAdapter] Login");
} catch (Exception e) {
@@ -408,7 +409,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- JuniperKeyStatusAdapter adapter = new JuniperKeyStatusAdapter();
+ //JuniperKeyStatusAdapter adapter = new JuniperKeyStatusAdapter();
availableSpecificCommands = new ArrayList();
@@ -495,8 +496,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(statusCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(statusCommand).getResult();
}
@@ -531,8 +532,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(statusCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(statusCommand).getResult();
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/JuniperSshStatusAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/JuniperSshStatusAdapter.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/JuniperSshStatusAdapter.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -202,13 +202,13 @@
//System.out.println(username);
//System.out.println(password);
- manager = new SshManager(url, username, password, false,
timeout);
+ manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
}
logger.info("[JuniperSshStatusAdapter] Trying to connect");
- manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
+ //manager.connect(username, "Username:",
PasswordEncryptor.decryptPassword(password), "Password:");
logger.info("[JuniperSshStatusAdapter Login");
@@ -401,7 +401,7 @@
logger.debug("EVENTTYPESTRING: " + eventTypeString);
- JuniperSshStatusAdapter adapter = new JuniperSshStatusAdapter();
+ //JuniperSshStatusAdapter adapter = new JuniperSshStatusAdapter();
// REPLACED
@@ -414,7 +414,9 @@
prompt = properties.getProperty(subject, "prompt");
caching = Integer.parseInt(properties.getProperty(subject,
"cache"));
timeout = Integer.parseInt(properties.getProperty(subject,
"timeout"));
-
+ username = properties.getProperty(subject, "username");
+ password = properties.getProperty(subject, "password");
+
manager = new SshManager(url, username,
PasswordEncryptor.decryptPassword(password), false, timeout);
} catch (NumberFormatException e1) {
@@ -490,8 +492,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(statusCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(statusCommand).getResult();
}
@@ -526,8 +528,8 @@
if (temp.equalsIgnoreCase("")) {
- adapter.connect(subject);
- temp = adapter.executeCommand(statusCommand).getResult();
+ this.connect(subject);
+ temp = this.executeCommand(statusCommand).getResult();
}
Added:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/remote/ssh/MyUserInfo.java
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/remote/ssh/SshKeyManager.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/remote/ssh/SshKeyManager.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/remote/ssh/SshKeyManager.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -7,6 +7,11 @@
import java.io.IOException;
import java.io.InputStream;
+import java.security.Provider;
+import java.security.Security;
+import java.security.Provider.Service;
+import java.util.Iterator;
+import java.util.Set;
import javax.swing.SwingUtilities;
@@ -33,10 +38,11 @@
// ------------------------------------- class - fields
private JSch jsch = null;
private Session session = null;
- private UserInfo ui = new MyUserInfo();
+ private UserInfo ui = null;
private String url = null;
private String userName = null;
private String keyUrl = null;
+ private String passphrase = null;
private LoggerComponent logger = null;
private boolean connected = false;
private int timeout = 0;
@@ -48,6 +54,7 @@
this.url = url;
this.userName = userName;
this.keyUrl = keyUrl;
+ ui = new MyUserInfo(keyUrl);
this.timeout = timeout;
try {
@@ -75,7 +82,44 @@
} // connect
} // SshKeyManager
+
+ public SshKeyManager(String url, String userName, String keyUrl,
+ String passphrase, boolean connect, int timeout) {
+ super();
+ this.url = url;
+ this.userName = userName;
+ this.keyUrl = keyUrl;
+ this.passphrase = passphrase;
+ ui = new MyUserInfo(keyUrl);
+ this.timeout = timeout;
+
+ try {
+
+ logger = (LoggerComponent)
AuxiliaryComponentManager.getInstance().getComponent(ComponentNames.LOGGER);
+
+ } catch (PerfSONARException e1) {
+
+ logger.error("[SSHKEYMANAGER][Constructor]" +
e1.getStackTrace().toString());
+
+ }
+
+ if (connect) {
+
+ try {
+
+ connect(userName, keyUrl);
+
+ } catch (PerfSONARException e) {
+
+ logger.error("[SshKeyManager] AuthenticationException during
connection");
+
+ }
+
+ } // connect
+
+ } // SshKeyManager
+
public void connect() throws PerfSONARException {
logger.debug("[SshKeyManager] connecting initiatec ...");
@@ -84,9 +128,11 @@
//Create a new Client for communication
jsch = new JSch();
-
+
//Set key identity file
- jsch.addIdentity(keyUrl);
+ if (passphrase == null)
+ jsch.addIdentity(keyUrl);
+ else jsch.addIdentity(keyUrl, passphrase);
//Create session
session = jsch.getSession(userName, url, 22);
@@ -212,8 +258,20 @@
public String executeCommand(String cmd) {
String result = "";
+
+ try {
+ if (jsch == null) {
+ ui = new MyUserInfo(this.keyUrl);
+ jsch = new JSch();
+ jsch.addIdentity(keyUrl);
+ session = jsch.getSession(this.userName, this.url,
22);
+ session.setUserInfo(ui);
+ }
+
+ if (!session.isConnected()) {
+ session.connect();
+ }
- try {
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(cmd);
channel.setInputStream(null);
@@ -285,30 +343,4 @@
} // disconnect
- public static class MyUserInfo implements UserInfo {
-
- public String getPassword() {
- return null;
- }
-
- public boolean promptYesNo(String str) {
- return true;
- }
-
- public String getPassphrase() {
- return null;
- }
-
- public boolean promptPassphrase(String message) {
- return true;
- }
-
- public boolean promptPassword(String message) {
- return true;
- }
-
- public void showMessage(String message) {
- //System.err.println(message);
- }
- }
}
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/remote/ssh/SshManager.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/remote/ssh/SshManager.java
2008-01-28 15:24:22 UTC (rev 3275)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/remote/ssh/SshManager.java
2008-01-28 15:28:13 UTC (rev 3276)
@@ -7,7 +7,13 @@
import java.io.IOException;
import java.io.InputStream;
+import java.security.Provider;
+import java.security.Security;
+import java.security.Provider.Service;
+import java.util.Iterator;
+import java.util.Set;
+import javax.crypto.Cipher;
import javax.swing.SwingUtilities;
import org.perfsonar.base.auxiliary.AuxiliaryComponentManager;
@@ -54,7 +60,9 @@
this.userName = userName;
this.password = password;
this.timeout = timeout;
- ui = new MyUserInfo(password);
+
+ //ui = new MyUserInfo(password);
+
try {
@@ -114,6 +122,7 @@
}
}// connect
+
/**
* Conects to the remote host
*
@@ -151,6 +160,7 @@
connect(username, keyUrl);
}// connect
+
/**
* Returns the SshChannelClient belonging to this Ssh connection
*
@@ -169,6 +179,7 @@
}
}// getSshChannel
+
/**
* Executes the command in the remote machine over the Ssh connection
*
@@ -180,6 +191,19 @@
String result = "";
try {
+
+ if (jsch == null) {
+ ui = new MyUserInfo(this.password);
+ jsch = new JSch();
+ session = jsch.getSession(this.userName, this.url,
22);
+ session.setUserInfo(ui);
+ }
+
+ if (!session.isConnected()) {
+ session.connect();
+
+ }
+
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(cmd);
channel.setInputStream(null);
@@ -201,9 +225,7 @@
channel2.disconnect();
session.disconnect();
} catch (InterruptedException ex) {
-
logger.error("[SshManager][ExecuteCommand]" +
ex.getStackTrace()[0].toString());
-
}
}
};
@@ -217,10 +239,10 @@
break;
}
result += new String(tmp, 0, i);
- System.out.println(new String(tmp, 0, i));
+ //System.out.println(new String(tmp, 0, i));
}
if (channel.isClosed()) {
- System.out.println("exit-status: " +
channel.getExitStatus());
+ //System.out.println("exit-status: " +
channel.getExitStatus());
break;
}
try {
@@ -233,7 +255,7 @@
channel.disconnect();
session.disconnect();
}
- logger.debug("result: " + result);
+ //logger.debug("result: " + result);
return result;
} catch (JSchException e) {
e.printStackTrace();
@@ -241,6 +263,9 @@
} catch (IOException e) {
e.printStackTrace();
return "An Error Occured";
+ } catch (Exception t){
+ t.printStackTrace();
+ return "An Error Occured";
}
}// executeCommand
@@ -261,39 +286,4 @@
}
- public static class MyUserInfo implements UserInfo {
-
- String passwd;
-
- public MyUserInfo(String passwd) {
-
- super();
- this.passwd = passwd;
-
- }
-
- public String getPassword() {
- return passwd;
- }
-
- public boolean promptYesNo(String str) {
- return true;
- }
-
- public String getPassphrase() {
- return null;
- }
-
- public boolean promptPassphrase(String message) {
- return true;
- }
-
- public boolean promptPassword(String message) {
- return true;
- }
-
- public void showMessage(String message) {
- //System.err.println(message);
- }
- }
}
- perfsonar: r3276 - in trunk/geant2_java-sshtelnet-mp: conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters lib/misc src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/encryption src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters src/main/java/org/perfsonar/service/measurementPoint/remote/ssh, svnlog, 01/28/2008
Archive powered by MHonArc 2.6.16.