aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/protocol/ssh
diff options
context:
space:
mode:
authorSebastien Vincent <seb@jitsi.org>2012-03-09 14:54:07 +0000
committerSebastien Vincent <seb@jitsi.org>2012-03-09 14:54:07 +0000
commitd9bef7b03a7c81e26a25ec876cea7477bc3d9689 (patch)
tree5da81af9038d5660c6754cf0737b3171bb84a8ae /src/net/java/sip/communicator/impl/protocol/ssh
parentdc0feb41a073563e32e8ab212aeaa953f73d2bf8 (diff)
downloadjitsi-d9bef7b03a7c81e26a25ec876cea7477bc3d9689.zip
jitsi-d9bef7b03a7c81e26a25ec876cea7477bc3d9689.tar.gz
jitsi-d9bef7b03a7c81e26a25ec876cea7477bc3d9689.tar.bz2
Fixes style formating, javadoc and eclipse related warnings.
Diffstat (limited to 'src/net/java/sip/communicator/impl/protocol/ssh')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ContactSSH.java89
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ContactTimerSSHImpl.java2
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java18
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java175
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/Resources.java7
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java33
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java112
7 files changed, 230 insertions, 206 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSH.java b/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSH.java
index b666160..c609d7f 100644
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSH.java
+++ b/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSH.java
@@ -31,15 +31,15 @@ interface ContactSSH
* conversation message sent by another contact.
*/
public static final int CONVERSATION_MESSAGE_RECEIVED = 1;
-
+
/**
* An event type indicting that the message being received is a system
* message being sent by the server or a system administrator.
*/
public static final int SYSTEM_MESSAGE_RECEIVED = 2;
-
+
//Following eight function declations to be moved to Contact
-
+
/**
* This method is only called when the contact is added to a new
* <tt>ContactGroupSSHImpl</tt> by the
@@ -49,7 +49,7 @@ interface ContactSSH
* parent of this <tt>ContactSSHImpl</tt>
*/
void setParentGroup (ContactGroupSSHImpl newParentGroup);
-
+
/**
* Sets <tt>sshPresenceStatus</tt> as the PresenceStatus that this
* contact is currently in.
@@ -57,7 +57,7 @@ interface ContactSSH
* currently valid for this contact.
*/
public void setPresenceStatus (PresenceStatus sshPresenceStatus);
-
+
/**
* Returns the persistent presence operation set that this contact belongs
* to.
@@ -67,9 +67,9 @@ interface ContactSSH
*/
public OperationSetPersistentPresence
getParentPresenceOperationSet ();
-
+
/**
- * Returns the BasicInstant Messaging operation set that this contact
+ * Returns the BasicInstant Messaging operation set that this contact
* belongs to.
*
* @return the <tt>OperationSetBasicInstantMessagingSSHImpl</tt> that
@@ -77,7 +77,7 @@ interface ContactSSH
*/
public OperationSetBasicInstantMessaging
getParentBasicInstantMessagingOperationSet ();
-
+
/**
* Returns the File Transfer operation set that this contact belongs
* to.
@@ -87,28 +87,28 @@ interface ContactSSH
*/
public OperationSetFileTransfer
getFileTransferOperationSet ();
-
+
/**
* Return the type of message received from remote server
*
* @return messageType
*/
public int getMessageType ();
-
+
/**
* Sets the type of message received from remote server
*
* @param messageType
*/
public void setMessageType (int messageType);
-
+
/**
* Stores persistent data of the contact.
*
* @param persistentData of the contact
*/
public void setPersistentData (String persistentData);
-
+
/**
* Makes the contact resolved or unresolved.
*
@@ -116,7 +116,7 @@ interface ContactSSH
* make it unresolved
*/
public void setResolved (boolean resolved);
-
+
/**
* Specifies whether or not this contact is being stored by the server.
* Non persistent contacts are common in the case of simple, non-persistent
@@ -131,7 +131,7 @@ interface ContactSSH
* otherwise.
*/
public void setPersistent (boolean isPersistent);
-
+
/**
* Returns true if a command has been sent whos reply was not received yet
* false otherwise
@@ -139,7 +139,7 @@ interface ContactSSH
* @return commandSent
*/
public boolean isCommandSent ();
-
+
/**
* Set the state of commandSent variable which determines whether a reply
* to a command sent is awaited
@@ -147,7 +147,7 @@ interface ContactSSH
* @param commandSent
*/
public void setCommandSent (boolean commandSent);
-
+
/**
* Initializes the reader and writers associated with shell of this contact
*
@@ -156,26 +156,26 @@ interface ContactSSH
*/
void initializeShellIO (InputStream shellInputStream,
OutputStream shellOutputStream);
-
+
/**
* Closes the readers and writer associated with shell of this contact
*/
void closeShellIO ();
-
+
/**
* Determines whether a connection to a remote server is already underway
*
* @return connectionInProgress
*/
public boolean isConnectionInProgress ();
-
+
/**
* Sets the status of connection attempt to remote server
*
* @param connectionInProgress
*/
public void setConnectionInProgress (boolean connectionInProgress);
-
+
// /**
// * Sets the PS1 prompt of the current shell of Contact
// * This method is synchronized
@@ -190,110 +190,111 @@ interface ContactSSH
// * @return sshPrompt
// */
// public String getShellPrompt();
-
-
+
+
/**
* Saves the details of contact in persistentData
*/
public void savePersistentDetails ();
-
+
/*
* Returns the SSHContactInfo associated with this contact
*
* @return sshConfigurationForm
*/
public SSHContactInfo getSSHConfigurationForm ();
-
+
/**
* Returns the JSch Stack identified associated with this contact
*
* @return jsch
*/
JSch getJSch ();
-
+
/**
* Starts the timer and its task to periodically update the status of
* remote machine
*/
void startTimerTask ();
-
+
/**
* Stops the timer and its task to stop updating the status of
* remote machine
*/
void stopTimerTask ();
-
+
/**
* Sets the JSch Stack identified associated with this contact
*
* @param jsch to be associated
*/
void setJSch (JSch jsch);
-
+
/**
* Returns the Username associated with this contact
*
* @return userName
*/
String getUserName ();
-
+
/**
* Returns the Hostname associated with this contact
*
* @return hostName
*/
String getHostName ();
-
+
/**
* Returns the Password associated with this contact
*
* @return password
*/
String getPassword ();
-
+
/**
* Sets the Password associated with this contact
*
* @param password
*/
void setPassword (String password);
-
+
/**
* Returns the SSH Session associated with this contact
*
* @return sshSession
*/
Session getSSHSession ();
-
+
/**
* Sets the SSH Session associated with this contact
*
* @param sshSession the newly created SSH Session to be associated
*/
void setSSHSession (Session sshSession);
-
+
/**
* Returns the SSH Shell Channel associated with this contact
*
* @return shellChannel
*/
Channel getShellChannel ();
-
+
/**
* Sets the SSH Shell channel associated with this contact
*
* @param shellChannel to be associated with SSH Session of this contact
*/
void setShellChannel (Channel shellChannel);
-
+
/**
* Sends a message a line to remote machine via the Shell Writer
*
* @param message to be sent
+ * @throws IOException if message failed to be sent
*/
public void sendLine (String message)
- throws IOException;
-
+ throws IOException;
+
// /**
// * Reads a line from the remote machine via the Shell Reader
// *
@@ -301,14 +302,14 @@ interface ContactSSH
// */
// public String getLine()
// throws IOException;
-
+
/**
* Returns the Input Stream associated with SSH Channel of this contact
*
* @return shellInputStream associated with SSH Channel of this contact
*/
public InputStream getShellInputStream ();
-
+
// /**
// * Sets the Input Stream associated with SSH Channel of this contact
// *
@@ -316,14 +317,14 @@ interface ContactSSH
// * contact
// */
// public void setShellInputStream(InputStream shellInputStream);
-
+
/**
* Returns the Output Stream associated with SSH Channel of this contact
*
* @return shellOutputStream associated with SSH Channel of this contact
*/
public OutputStream getShellOutputStream ();
-
+
// /**
// * Sets the Output Stream associated with SSH Channel of this contact
// *
@@ -345,14 +346,14 @@ interface ContactSSH
// * @param shellReader to be associated with SSH Channel of this contact
// */
// public void setShellReader(BufferedReader shellReader);
-
+
/**
* Returns the PrintWriter associated with SSH Channel of this contact
*
* @return shellWriter associated with SSH Channel of this contact
*/
public PrintWriter getShellWriter ();
-
+
// /**
// * Sets the PrintWriter associated with SSH Channel of this contact
// *
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ContactTimerSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ContactTimerSSHImpl.java
index 33c5c90..4726d2b 100644
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ContactTimerSSHImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/ssh/ContactTimerSSHImpl.java
@@ -93,6 +93,8 @@ public class ContactTimerSSHImpl
}
/**
* Creates a new instance of ContactTimerSSHImpl
+ *
+ * @param sshContact the <tt>Contact</tt>
*/
public ContactTimerSSHImpl(ContactSSH sshContact)
{
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java
index 99db4ad..16872f5 100644
--- a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java
@@ -28,26 +28,30 @@ public class OperationSetFileTransferSSHImpl
{
private static final Logger logger
= Logger.getLogger(OperationSetFileTransferSSHImpl.class);
-
+
/**
* Currently registered message listeners.
*/
private Vector<FileTransferListener> fileTransferListeners
= new Vector<FileTransferListener>();
-
+
/**
* The protocol provider that created us.
*/
private ProtocolProviderServiceSSHImpl parentProvider = null;
-
-
- /** Creates a new instance of OperationSetFileTransferSSHImpl */
+
+
+ /**
+ * Creates a new instance of OperationSetFileTransferSSHImpl
+ *
+ * @param parentProvider the parent protocol provider service
+ */
public OperationSetFileTransferSSHImpl(
ProtocolProviderServiceSSHImpl parentProvider)
{
this.parentProvider = parentProvider;
}
-
+
/**
* Registers a FileTransferListener with this operation set so that it gets
* notifications of start, complete, failure of file transfers
@@ -74,7 +78,7 @@ public class OperationSetFileTransferSSHImpl
}
/**
- * Sends a file transfer request to the given <tt>toContact</tt>.
+ * Sends a file transfer request to the given <tt>toContact</tt>.
* @param toContact the contact that should receive the file
* @param file the file to send
*/
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java
index 35e21f1..ee303d3 100644
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java
@@ -34,72 +34,72 @@ public class ProtocolProviderServiceSSHImpl
{
private static final Logger logger
= Logger.getLogger(ProtocolProviderServiceSSHImpl.class);
-
+
/**
* The name of this protocol.
*/
public static final String SSH_PROTOCOL_NAME = ProtocolNames.SSH;
-
+
// /**
// * The identifier for SSH Stack
// * Java Secure Channel JSch
// */
// JSch jsch = new JSch();
-
+
/**
- * The test command given after each command to determine the reply length
+ * The test command given after each command to determine the reply length
* of the command
*/
- //private final String testCommand =
+ //private final String testCommand =
// Resources.getString("testCommand");
-
+
/**
* A reference to the protocol provider of UIService
*/
private static ServiceReference ppUIServiceRef;
-
+
/**
* Connection timeout to a remote server in milliseconds
*/
private static int connectionTimeout = 30000;
-
+
/**
* A reference to UI Service
*/
private static UIService uiService;
-
+
/**
* The id of the account that this protocol provider represents.
*/
private AccountID accountID = null;
-
+
/**
* We use this to lock access to initialization.
*/
private final Object initializationLock = new Object();
-
+
private OperationSetBasicInstantMessagingSSHImpl basicInstantMessaging;
-
+
private OperationSetFileTransferSSHImpl fileTranfer;
-
+
/**
* Indicates whether or not the provider is initialized and ready for use.
*/
private boolean isInitialized = false;
-
+
/**
* The logo corresponding to the ssh protocol.
*/
private ProtocolIconSSHImpl sshIcon
= new ProtocolIconSSHImpl();
-
+
/**
* The registration state of SSH Provider is taken to be registered by
* default as it doesn't correspond to the state on remote server
*/
private RegistrationState currentRegistrationState
= RegistrationState.REGISTERED;
-
+
/**
* The default constructor for the SSH protocol provider.
*/
@@ -107,7 +107,7 @@ public class ProtocolProviderServiceSSHImpl
{
if (logger.isTraceEnabled())
logger.trace("Creating a ssh provider.");
-
+
try
{
// converting to milliseconds
@@ -119,7 +119,7 @@ public class ProtocolProviderServiceSSHImpl
logger.error("Connection Timeout set to 30 seconds");
}
}
-
+
/**
* Initializes the service implementation, and puts it in a sate where it
* could interoperate with other services. It is strongly recomended that
@@ -140,11 +140,11 @@ public class ProtocolProviderServiceSSHImpl
synchronized(initializationLock)
{
this.accountID = accountID;
-
+
//initialize the presence operationset
OperationSetPersistentPresenceSSHImpl persistentPresence =
new OperationSetPersistentPresenceSSHImpl(this);
-
+
addSupportedOperationSet(
OperationSetPersistentPresence.class,
persistentPresence);
@@ -154,25 +154,25 @@ public class ProtocolProviderServiceSSHImpl
addSupportedOperationSet(
OperationSetPresence.class,
persistentPresence);
-
+
//initialize the IM operation set
- basicInstantMessaging = new
+ basicInstantMessaging = new
OperationSetBasicInstantMessagingSSHImpl(
this);
addSupportedOperationSet(
OperationSetBasicInstantMessaging.class,
basicInstantMessaging);
-
+
//initialze the file transfer operation set
fileTranfer = new OperationSetFileTransferSSHImpl(this);
addSupportedOperationSet(
OperationSetFileTransfer.class,
fileTranfer);
-
+
isInitialized = true;
}
}
-
+
/**
* Determines whether a vaild session exists for the contact of remote
* machine.
@@ -188,12 +188,12 @@ public class ProtocolProviderServiceSSHImpl
if( sshSession != null)
if(sshSession.isConnected())
return true;
-
+
// remove reference to an unconnected SSH Session, if any
sshContact.setSSHSession(null);
return false;
}
-
+
/**
* Determines whether the contact is connected to shell of remote machine
* as a precheck for any further operation
@@ -206,22 +206,22 @@ public class ProtocolProviderServiceSSHImpl
public boolean isShellConnected(ContactSSH sshContact)
{
// a test command may also be run here
-
+
if(isSessionValid(sshContact))
{
return(sshContact.getShellChannel() != null);
}
-
+
/*
* Above should be return(sshContact.getShellChannel() != null
* && sshContact.getShellChannel().isConnected());
*
* but incorrect reply from stack for isConnected()
*/
-
+
return false;
}
-
+
/**
* Creates a shell channel to the remote machine
* a new jsch session is also created if the current one is invalid
@@ -242,35 +242,35 @@ public class ProtocolProviderServiceSSHImpl
OperationSetPersistentPresenceSSHImpl persistentPresence
= (OperationSetPersistentPresenceSSHImpl)sshContact
.getParentPresenceOperationSet();
-
+
persistentPresence.changeContactPresenceStatus(
sshContact,
SSHStatusEnum.CONNECTING);
-
+
try
{
if(!isSessionValid(sshContact))
createSSHSessionAndLogin(sshContact);
-
+
createShellChannel(sshContact);
-
+
//initializing the reader and writers of ssh contact
-
+
persistentPresence.changeContactPresenceStatus(
sshContact,
SSHStatusEnum.CONNECTED);
-
+
showWelcomeMessage(sshContact);
-
+
sshContact.setMessageType(ContactSSH
.CONVERSATION_MESSAGE_RECEIVED);
-
+
sshContact.setConnectionInProgress(false);
-
+
Thread.sleep(1500);
-
+
sshContact.setCommandSent(true);
-
+
basicInstantMessaging.sendInstantMessage(
sshContact,
firstMessage);
@@ -281,7 +281,7 @@ public class ProtocolProviderServiceSSHImpl
persistentPresence.changeContactPresenceStatus(
sshContact,
SSHStatusEnum.NOT_AVAILABLE);
-
+
ex.printStackTrace();
}
finally
@@ -290,38 +290,38 @@ public class ProtocolProviderServiceSSHImpl
}
}
}));
-
+
newConnection.start();
}
-
+
/**
* Creates a channel for shell type in the current session
* channel types = shell, sftp, exec(X forwarding),
* direct-tcpip(stream forwarding) etc
*
* @param sshContact ID of SSH Contact
- *
+ * @throws IOException if the shell channel cannot be created
*/
public void createShellChannel(ContactSSH sshContact)
- throws IOException
+ throws IOException
{
try
{
Channel shellChannel = sshContact.getSSHSession()
.openChannel("shell");
-
+
//initalizing the reader and writers of ssh contact
sshContact.initializeShellIO(shellChannel.getInputStream(),
shellChannel.getOutputStream());
-
+
((ChannelShell)shellChannel).setPtyType(
sshContact.getSSHConfigurationForm().getTerminalType());
-
+
//initializing the shell
shellChannel.connect(1000);
-
+
sshContact.setShellChannel(shellChannel);
-
+
sshContact.sendLine("export PS1=");
}
catch (JSchException ex)
@@ -331,11 +331,13 @@ public class ProtocolProviderServiceSSHImpl
" server");
}
}
-
+
/**
* Closes the Shell channel are associated IO Streams
*
* @param sshContact ID of SSH Contact
+ * @throws JSchException if something went wrong in JSch
+ * @throws IOException if I/O exception occurred
*/
public void closeShellChannel(ContactSSH sshContact) throws
JSchException,
@@ -345,7 +347,7 @@ public class ProtocolProviderServiceSSHImpl
sshContact.getShellChannel().disconnect();
sshContact.setShellChannel(null);
}
-
+
/**
* Creates a SSH Session with a remote machine and tries to login
* according to the details specified by Contact
@@ -353,7 +355,7 @@ public class ProtocolProviderServiceSSHImpl
*
* @param sshContact ID of SSH Contact
*
- * @throws JSchException if a JSch is unable to create a SSH Session with
+ * @throws JSchException if a JSch is unable to create a SSH Session with
* the remote machine
* @throws InterruptedException if the thread is interrupted before session
* connected or is timed out
@@ -367,10 +369,10 @@ public class ProtocolProviderServiceSSHImpl
if (logger.isInfoEnabled())
logger.info("Creating a new SSH Session to "
+ sshContact.getHostName());
-
+
// creating a new JSch Stack identifier for contact
JSch jsch = new JSch();
-
+
String knownHosts =
accountID.getAccountPropertyString("KNOWN_HOSTS_FILE");
@@ -379,14 +381,14 @@ public class ProtocolProviderServiceSSHImpl
String identitiyKey =
accountID.getAccountPropertyString("IDENTITY_FILE");
-
+
String userName = sshContact.getUserName();
-
+
// use the name of system user if the contact has not supplied SSH
// details
if(userName.equals(""))
userName = System.getProperty("user.name");
-
+
if(!identitiyKey.equals("Optional"))
jsch.addIdentity(identitiyKey);
@@ -395,22 +397,22 @@ public class ProtocolProviderServiceSSHImpl
userName,
sshContact.getHostName(),
sshContact.getSSHConfigurationForm().getPort());
-
+
/**
* Creating and associating User Info with the session
* User Info passes authentication from sshContact to SSH Stack
*/
SSHUserInfo sshUserInfo = new SSHUserInfo(sshContact);
-
+
session.setUserInfo(sshUserInfo);
-
+
/**
* initializing the session
*/
session.connect(connectionTimeout);
-
+
int count = 0;
-
+
// wait for session to get connected
while(!session.isConnected() && count<=30000)
{
@@ -420,7 +422,7 @@ public class ProtocolProviderServiceSSHImpl
logger.trace("SSH:" + sshContact.getHostName()
+ ": Sleep zzz .. " );
}
-
+
// if timeout have exceeded
if(count>30000)
{
@@ -429,20 +431,20 @@ public class ProtocolProviderServiceSSHImpl
null,
"SSH Connection attempt to "
+ sshContact.getHostName() + " timed out");
-
+
// error codes are not defined yet
throw new OperationFailedException("SSH Connection attempt to " +
sshContact.getHostName() + " timed out", 2);
}
-
+
sshContact.setJSch(jsch);
sshContact.setSSHSession(session);
-
+
if (logger.isInfoEnabled())
logger.info("A new SSH Session to " + sshContact.getHostName()
+ " Created");
}
-
+
/**
* Closes the SSH Session associated with the contact
*
@@ -453,14 +455,15 @@ public class ProtocolProviderServiceSSHImpl
sshContact.getSSHSession().disconnect();
sshContact.setSSHSession(null);
}
-
+
/**
* Presents the login welcome message to user
*
* @param sshContact ID of SSH Contact
+ * @throws IOException if I/O exception occurred
*/
public void showWelcomeMessage(ContactSSH sshContact)
- throws IOException
+ throws IOException
{
/* //sending the command
sshContact.sendLine(testCommand);
@@ -487,7 +490,7 @@ public class ProtocolProviderServiceSSHImpl
if (logger.isDebugEnabled())
logger.debug("SSH: Welcome message shown");
}
-
+
/**
* Returns a reference to UIServce for accessing UI related services
*
@@ -497,7 +500,7 @@ public class ProtocolProviderServiceSSHImpl
{
return uiService;
}
-
+
/**
* Returns the AccountID that uniquely identifies the account represented
* by this instance of the ProtocolProviderService.
@@ -508,7 +511,7 @@ public class ProtocolProviderServiceSSHImpl
{
return accountID;
}
-
+
/**
* Returns the short name of the protocol that the implementation of this
* provider is based upon (like SIP, Jabber, ICQ/AIM, or others for
@@ -533,7 +536,7 @@ public class ProtocolProviderServiceSSHImpl
{
return currentRegistrationState;
}
-
+
/**
* Starts the registration process.
*
@@ -549,22 +552,22 @@ public class ProtocolProviderServiceSSHImpl
{
RegistrationState oldState = currentRegistrationState;
currentRegistrationState = RegistrationState.REGISTERED;
-
+
//get a reference to UI Service via its Service Reference
ppUIServiceRef = SSHActivator.getBundleContext()
.getServiceReference(UIService.class.getName());
-
+
uiService = (UIService)SSHActivator.getBundleContext()
.getService(ppUIServiceRef);
-
+
fireRegistrationStateChanged(
oldState
, currentRegistrationState
, RegistrationStateChangeEvent.REASON_USER_REQUEST
, null);
-
+
}
-
+
/**
* Makes the service implementation close all open sockets and release
* any resources that it might have taken and prepare for
@@ -578,7 +581,7 @@ public class ProtocolProviderServiceSSHImpl
}
if (logger.isTraceEnabled())
logger.trace("Killing the SSH Protocol Provider.");
-
+
if(isRegistered())
{
try
@@ -595,10 +598,10 @@ public class ProtocolProviderServiceSSHImpl
, ex);
}
}
-
+
isInitialized = false;
}
-
+
/**
* Ends the registration of this protocol provider with the current
* registration service.
@@ -612,7 +615,7 @@ public class ProtocolProviderServiceSSHImpl
{
RegistrationState oldState = currentRegistrationState;
currentRegistrationState = RegistrationState.UNREGISTERED;
-
+
fireRegistrationStateChanged(
oldState
, currentRegistrationState
@@ -622,7 +625,7 @@ public class ProtocolProviderServiceSSHImpl
/*
* (non-Javadoc)
- *
+ *
* @see net.java.sip.communicator.service.protocol.ProtocolProviderService#
* isSignallingTransportSecure()
*/
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/Resources.java b/src/net/java/sip/communicator/impl/protocol/ssh/Resources.java
index 238c507..6928794 100644
--- a/src/net/java/sip/communicator/impl/protocol/ssh/Resources.java
+++ b/src/net/java/sip/communicator/impl/protocol/ssh/Resources.java
@@ -18,8 +18,11 @@ import net.java.sip.communicator.service.resources.*;
*/
public class Resources
{
+ /**
+ * The SSH logo imageID.
+ */
public static ImageID SSH_LOGO = new ImageID("protocolIconSsh");
-
+
/**
* Returns an string corresponding to the given key.
*
@@ -31,7 +34,7 @@ public class Resources
{
return SSHActivator.getResources().getI18NString(key);
}
-
+
/**
* Loads an image from a given image identifier.
* @param imageID The identifier of the image.
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java
index 509034e..c799077 100644
--- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java
+++ b/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java
@@ -29,26 +29,26 @@ public class SSHActivator
{
private static final Logger logger
= Logger.getLogger(SSHActivator.class);
-
+
/**
* A reference to the registration of our SSH protocol provider
* factory.
*/
private ServiceRegistration sshPpFactoryServReg = null;
-
+
/**
* A reference to the SSH protocol provider factory.
*/
private static ProtocolProviderFactorySSHImpl
sshProviderFactory = null;
-
+
/**
* The currently valid bundle context.
*/
private static BundleContext bundleContext = null;
-
+
private static ResourceManagementService resourcesService;
-
+
/**
* Called when this bundle is started. In here we'll export the
* ssh ProtocolProviderFactory implementation so that it could be
@@ -63,8 +63,8 @@ public class SSHActivator
public void start(BundleContext context)
throws Exception
{
- this.bundleContext = context;
-
+ bundleContext = context;
+
Hashtable<String, String> hashtable = new Hashtable<String, String>();
hashtable.put(ProtocolProviderFactory.PROTOCOL, "SSH");
@@ -75,11 +75,11 @@ public class SSHActivator
ProtocolProviderFactory.class.getName(),
sshProviderFactory,
hashtable);
-
+
if (logger.isInfoEnabled())
logger.info("SSH protocol implementation [STARTED].");
}
-
+
/**
* Returns a reference to the bundle context that we were started with.
* @return bundleContext a reference to the BundleContext instance
@@ -89,7 +89,7 @@ public class SSHActivator
{
return bundleContext;
}
-
+
/**
* Retrurns a reference to the protocol provider factory that we have
* registered.
@@ -101,8 +101,8 @@ public class SSHActivator
{
return sshProviderFactory;
}
-
-
+
+
/**
* Called when this bundle is stopped so the Framework can perform the
* bundle-specific activities necessary to stop the bundle.
@@ -116,12 +116,17 @@ public class SSHActivator
public void stop(BundleContext context)
throws Exception
{
- this.sshProviderFactory.stop();
+ sshProviderFactory.stop();
sshPpFactoryServReg.unregister();
if (logger.isInfoEnabled())
logger.info("SSH protocol implementation [STOPPED].");
}
-
+
+ /**
+ * Returns the <tt>ResourceManagementService</tt>.
+ *
+ * @return the <tt>ResourceManagementService</tt>.
+ */
public static ResourceManagementService getResources()
{
if (resourcesService == null)
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java
index 9592ce2..1b5f31a 100644
--- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java
+++ b/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java
@@ -23,15 +23,21 @@ import net.java.sip.communicator.util.swing.*;
/**
* @author Shobhit Jindal
*/
-class SSHContactInfo extends SIPCommDialog {
+class SSHContactInfo extends SIPCommDialog
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
private ContactSSH sshContact;
-
+
private JPanel mainPanel = new TransparentPanel();
private JPanel machinePanel = new TransparentPanel();
private JPanel detailNamesPanel = new TransparentPanel();
private JPanel detailFieldsPanel = new TransparentPanel();
private JPanel detailsPanel = new TransparentPanel();
-
+
private JCheckBox addDetailsCheckBox = new SIPCommCheckBox("Add Details");
private JButton doneButton = new JButton("Done");
@@ -42,41 +48,41 @@ class SSHContactInfo extends SIPCommDialog {
private JLabel password = new JLabel("Password: ");
private JTextField passwordField = new JPasswordField();
private JLabel port = new JLabel("Port: ");
-
+
private JFormattedTextField portField;
private JLabel secs = new JLabel("secs");
private JLabel statusUpdate = new JLabel("Update Interval: ");
private JLabel terminalType = new JLabel("Terminal Type: ");
private JTextField terminalTypeField = new JTextField("SIP Communicator");
private JSpinner updateTimer = new JSpinner();
-
+
private JPanel emptyPanel1 = new TransparentPanel();
-
+
private JPanel emptyPanel2 = new TransparentPanel();
-
+
private JPanel emptyPanel3 = new TransparentPanel();
-
+
private JPanel emptyPanel4 = new TransparentPanel();
-
+
private JPanel emptyPanel5 = new TransparentPanel();
-
+
private JPanel emptyPanel6 = new TransparentPanel();
-
+
private JPanel emptyPanel7 = new TransparentPanel();
-
+
private JPanel emptyPanel8 = new TransparentPanel();
-
+
private JPanel emptyPanel9 = new TransparentPanel();
-
+
private JPanel emptyPanel10 = new TransparentPanel();
-
+
private JPanel emptyPanel11 = new TransparentPanel();
-
+
// private ContactGroup contactGroup = null;
-
+
/**
* Creates a new instance of SSHContactInfo
- *
+ *
* @param sshContact the concerned contact
*/
public SSHContactInfo(ContactSSH sshContact) {
@@ -84,27 +90,27 @@ class SSHContactInfo extends SIPCommDialog {
this.sshContact = sshContact;
initForm();
-
+
this.getContentPane().add(mainPanel);
-
+
this.setSize(370, 325);
-
+
this.setResizable(false);
-
+
this.setTitle("SSH: Account Details of " + sshContact.getDisplayName());
-
+
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
-
+
int x = (screenSize.width - this.getWidth()) / 2;
int y = (screenSize.height - this.getHeight()) / 2;
-
+
this.setLocation(x,y);
-
+
// ProtocolProviderServiceSSHImpl.getUIService().getConfigurationWindow().
// addConfigurationForm(this);
}
-
+
/**
* initialize the form.
*/
@@ -119,13 +125,13 @@ class SSHContactInfo extends SIPCommDialog {
maskFormatter.setAllowsInvalid(false);
portField = new JFormattedTextField(maskFormatter);
portField.setValue(22);
-
+
userNameField.setEnabled(false);
passwordField.setEditable(false);
portField.setEnabled(false);
terminalTypeField.setEnabled(false);
updateTimer.setEnabled(false);
-
+
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
machinePanel.setLayout(new BoxLayout(machinePanel, BoxLayout.X_AXIS));
detailNamesPanel.setLayout(new BoxLayout(detailNamesPanel,
@@ -133,10 +139,10 @@ class SSHContactInfo extends SIPCommDialog {
detailFieldsPanel.setLayout(new BoxLayout(detailFieldsPanel,
BoxLayout.Y_AXIS));
detailsPanel.setLayout(new BoxLayout(detailsPanel, BoxLayout.X_AXIS));
-
+
machinePanel.add(machineID);
machinePanel.add(machineIDField);
-
+
detailNamesPanel.add(userName);
detailNamesPanel.add(emptyPanel1);
detailNamesPanel.add(password);
@@ -146,7 +152,7 @@ class SSHContactInfo extends SIPCommDialog {
detailNamesPanel.add(statusUpdate);
detailNamesPanel.add(emptyPanel4);
detailNamesPanel.add(terminalType);
-
+
detailFieldsPanel.add(userNameField);
detailFieldsPanel.add(emptyPanel5);
detailFieldsPanel.add(passwordField);
@@ -156,12 +162,12 @@ class SSHContactInfo extends SIPCommDialog {
detailFieldsPanel.add(updateTimer);
detailFieldsPanel.add(emptyPanel8);
detailFieldsPanel.add(terminalTypeField);
-
+
detailsPanel.add(detailNamesPanel);
detailsPanel.add(detailFieldsPanel);
-
+
detailsPanel.setBorder(BorderFactory.createTitledBorder("Details"));
-
+
mainPanel.add(emptyPanel9);
mainPanel.add(machinePanel);
mainPanel.add(addDetailsCheckBox);
@@ -169,7 +175,7 @@ class SSHContactInfo extends SIPCommDialog {
mainPanel.add(emptyPanel10);
mainPanel.add(doneButton);
mainPanel.add(emptyPanel11);
-
+
addDetailsCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
addDetailsCheckBox.setEnabled(false);
@@ -178,18 +184,18 @@ class SSHContactInfo extends SIPCommDialog {
portField.setEnabled(true);
terminalTypeField.setEnabled(true);
updateTimer.setEnabled(true);
-
+
userNameField.grabFocus();
}
});
-
+
doneButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if(machineIDField.getText().equals("")) {
machineIDField.setText("Field needed");
return;
}
-
+
sshContact.savePersistentDetails();
//add contact to contact list
@@ -200,10 +206,10 @@ class SSHContactInfo extends SIPCommDialog {
sshContact);
setVisible(false);
- }
+ }
});
}
-
+
/**
* Return the ssh icon
*
@@ -223,7 +229,7 @@ class SSHContactInfo extends SIPCommDialog {
// {
// return this.contactGroup;
// }
-
+
/**
* Sets the UserName of the dialog
*
@@ -232,7 +238,7 @@ class SSHContactInfo extends SIPCommDialog {
public void setUserNameField(String userName) {
this.userNameField.setText(userName);
}
-
+
/**
* Sets the Password of the dialog
*
@@ -241,7 +247,7 @@ class SSHContactInfo extends SIPCommDialog {
public void setPasswordField(String password) {
this.passwordField.setText(password);
}
-
+
/**
* Return the hostname
*
@@ -250,7 +256,7 @@ class SSHContactInfo extends SIPCommDialog {
public String getHostName() {
return this.machineIDField.getText();
}
-
+
/**
* Return the username
*
@@ -259,7 +265,7 @@ class SSHContactInfo extends SIPCommDialog {
public String getUserName() {
return this.userNameField.getText();
}
-
+
/**
* Return the password
*
@@ -268,7 +274,7 @@ class SSHContactInfo extends SIPCommDialog {
public String getPassword() {
return this.passwordField.getText();
}
-
+
/**
* Return the terminal type
*
@@ -277,7 +283,7 @@ class SSHContactInfo extends SIPCommDialog {
public String getTerminalType() {
return this.terminalTypeField.getText();
}
-
+
/**
* Return the port
*
@@ -286,7 +292,7 @@ class SSHContactInfo extends SIPCommDialog {
public int getPort() {
return Integer.parseInt(this.portField.getText().trim());
}
-
+
/**
* Return the update interval
*
@@ -295,7 +301,7 @@ class SSHContactInfo extends SIPCommDialog {
public int getUpdateInterval() {
return Integer.parseInt(String.valueOf(this.updateTimer.getValue()));
}
-
+
/**
* Sets the HostName of the dialog
*
@@ -304,7 +310,7 @@ class SSHContactInfo extends SIPCommDialog {
public void setHostNameField(String hostName) {
this.machineIDField.setText(hostName);
}
-
+
/**
* Sets the Terminal Type of the dialog
*
@@ -313,7 +319,7 @@ class SSHContactInfo extends SIPCommDialog {
public void setTerminalType(String termType) {
this.terminalTypeField.setText(termType);
}
-
+
/**
* Sets the Update Interval of the dialog
*
@@ -322,7 +328,7 @@ class SSHContactInfo extends SIPCommDialog {
public void setUpdateInterval(int interval) {
this.updateTimer.setValue(interval);
}
-
+
/**
* Sets the Port of the dialog
*