aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/protocol/ssh
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/sip/communicator/impl/protocol/ssh')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ContactGroupSSHImpl.java580
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ContactSSH.java370
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java918
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ContactTimerSSHImpl.java116
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/FileTransferSSHImpl.java96
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/MessageSSHImpl.java63
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/OperationSetBasicInstantMessagingSSHImpl.java312
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java161
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/OperationSetPersistentPresenceSSHImpl.java980
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ProtocolIconSSHImpl.java159
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSH.java49
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSHImpl.java179
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java662
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/Resources.java53
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/SSHAccountID.java45
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java145
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java352
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/SSHFileTransferDaemon.java468
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/SSHReaderDaemon.java211
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/SSHStatusEnum.java138
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/SSHUserInfo.java164
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ssh.provider.manifest.mf20
22 files changed, 0 insertions, 6241 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ContactGroupSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ContactGroupSSHImpl.java
deleted file mode 100644
index 7de2e16..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ContactGroupSSHImpl.java
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * A simple, straightforward implementation of a ssh ContactGroup. Since
- * the SSH protocol is not a real one, we simply store all group details
- * in class fields. You should know that when implementing a real protocol,
- * the contact group implementation would rather encapsulate group objects from
- * the protocol stack and group property values should be returned by
- * consulting the encapsulated object.
- *
- * @author Shobhit Jindal
- */
-public class ContactGroupSSHImpl
- implements ContactGroup
-{
-
- /**
- * The name of this SSH contact group.
- */
- private String groupName = null;
-
- /**
- * The list of this group's members.
- */
- private Vector<Contact> contacts = new Vector<Contact>();
-
- /**
- * The list of sub groups belonging to this group.
- */
- private Vector<ContactGroup> subGroups = new Vector<ContactGroup>();
-
- /**
- * The group that this group belongs to (or null if this is the root group).
- */
- private ContactGroupSSHImpl parentGroup = null;
-
- /**
- * Determines whether this group is really in the contact list or whether
- * it is here only temporarily and will be gone next time we restart.
- */
- private boolean isPersistent = true;
-
- /**
- * The protocol provider that created us.
- */
- private ProtocolProviderServiceSSHImpl parentProvider = null;
-
- /**
- * Determines whether this group has been resolved on the server.
- * Unresolved groups are groups that were available on previous runs and
- * that the meta contact list has stored. During all next runs, when
- * bootstrapping, the meta contact list would create these groups as
- * unresolved. Once a protocol provider implementation confirms that the
- * groups are still on the server, it would issue an event indicating that
- * the groups are now resolved.
- */
- private boolean isResolved = true;
-
- /**
- * An id uniquely identifying the group. For many protocols this could be
- * the group name itself.
- */
- private String uid = null;
- private static final String UID_SUFFIX = ".uid";
-
- /**
- * Creates a ContactGroupSSHImpl with the specified name.
- *
- * @param groupName the name of the group.
- * @param parentProvider the protocol provider that created this group.
- */
- public ContactGroupSSHImpl(
- String groupName,
- ProtocolProviderServiceSSHImpl parentProvider)
- {
- this.groupName = groupName;
- this.uid = groupName + UID_SUFFIX;
- this.parentProvider = parentProvider;
- }
-
- /**
- * Determines whether the group may contain subgroups or not.
- *
- * @return always true in this implementation.
- */
- public boolean canContainSubgroups()
- {
- return true;
- }
-
- /**
- * Returns the protocol provider that this group belongs to.
- * @return a regerence to the ProtocolProviderService instance that this
- * ContactGroup belongs to.
- */
- public ProtocolProviderService getProtocolProvider()
- {
- return parentProvider;
- }
-
- /**
- * Returns an Iterator over all contacts, member of this
- * <tt>ContactGroup</tt>.
- *
- * @return a java.util.Iterator over all contacts inside this
- * <tt>ContactGroup</tt>
- */
- public Iterator<Contact> contacts()
- {
- return contacts.iterator();
- }
-
- /**
- * Adds the specified contact to this group.
- * @param contactToAdd the ContactSSHImpl to add to this group.
- */
- public void addContact(ContactSSH contactToAdd)
- {
- this.contacts.add(contactToAdd);
- contactToAdd.setParentGroup(this);
- }
-
- /**
- * Returns the number of <tt>Contact</tt> members of this
- * <tt>ContactGroup</tt>
- *
- * @return an int indicating the number of <tt>Contact</tt>s, members of
- * this <tt>ContactGroup</tt>.
- */
- public int countContacts()
- {
- return contacts.size();
- }
-
- /**
- * Returns the number of subgroups contained by this
- * <tt>ContactGroup</tt>.
- *
- * @return the number of subGroups currently added to this group.
- */
- public int countSubgroups()
- {
- return subGroups.size();
- }
-
- /**
- * Adds the specified contact group to the contained by this group.
- * @param subgroup the ContactGroupSSHImpl to add as a subgroup to this
- * group.
- */
- public void addSubgroup(ContactGroupSSHImpl subgroup)
- {
- this.subGroups.add(subgroup);
- subgroup.setParentGroup(this);
- }
-
- /**
- * Sets the group that is the new parent of this group
- * @param parent ContactGroupSSHImpl
- */
- void setParentGroup(ContactGroupSSHImpl parent)
- {
- this.parentGroup = parent;
- }
-
- /**
- * Returns the contact group that currently contains this group or null if
- * this is the root contact group.
- * @return the contact group that currently contains this group or null if
- * this is the root contact group.
- */
- public ContactGroup getParentContactGroup()
- {
- return this.parentGroup;
- }
-
- /**
- * Removes the specified contact group from the this group's subgroups.
- * @param subgroup the ContactGroupSSHImpl subgroup to remove.
- */
- public void removeSubGroup(ContactGroupSSHImpl subgroup)
- {
- this.subGroups.remove(subgroup);
- subgroup.setParentGroup(null);
- }
-
- /**
- * Returns the group that is parent of the specified sshGroup or null
- * if no parent was found.
- * @param sshGroup the group whose parent we're looking for.
- * @return the ContactGroupSSHImpl instance that sshGroup
- * belongs to or null if no parent was found.
- */
- public ContactGroupSSHImpl findGroupParent(
- ContactGroupSSHImpl sshGroup)
- {
- if ( subGroups.contains(sshGroup) )
- return this;
-
- Iterator<ContactGroup> subGroupsIter = subgroups();
- while (subGroupsIter.hasNext())
- {
- ContactGroupSSHImpl subgroup
- = (ContactGroupSSHImpl) subGroupsIter.next();
-
- ContactGroupSSHImpl parent
- = subgroup.findGroupParent(sshGroup);
-
- if(parent != null)
- return parent;
- }
- return null;
- }
-
- /**
- * Returns the group that is parent of the specified sshContact or
- * null if no parent was found.
- *
- * @param sshContact the contact whose parent we're looking for.
- * @return the ContactGroupSSHImpl instance that sshContact
- * belongs to or <tt>null</tt> if no parent was found.
- */
- public ContactGroupSSHImpl findContactParent(
- ContactSSHImpl sshContact)
- {
- if ( contacts.contains(sshContact) )
- return this;
-
- Iterator<ContactGroup> subGroupsIter = subgroups();
- while (subGroupsIter.hasNext())
- {
- ContactGroupSSHImpl subgroup
- = (ContactGroupSSHImpl) subGroupsIter.next();
-
- ContactGroupSSHImpl parent
- = subgroup.findContactParent(sshContact);
-
- if(parent != null)
- return parent;
- }
- return null;
- }
-
-
-
- /**
- * Returns the <tt>Contact</tt> with the specified address or identifier.
- *
- * @param id the addres or identifier of the <tt>Contact</tt> we are
- * looking for.
- * @return the <tt>Contact</tt> with the specified id or address.
- */
- public Contact getContact(String id)
- {
- Iterator<Contact> contactsIter = contacts();
- while (contactsIter.hasNext())
- {
- ContactSSHImpl contact = (ContactSSHImpl) contactsIter.next();
- if (contact.getAddress().equals(id))
- return contact;
-
- }
- return null;
- }
-
- /**
- * Returns the subgroup with the specified index.
- *
- * @param index the index of the <tt>ContactGroup</tt> to retrieve.
- * @return the <tt>ContactGroup</tt> with the specified index.
- */
- public ContactGroup getGroup(int index)
- {
- return subGroups.get(index);
- }
-
- /**
- * Returns the subgroup with the specified name.
- *
- * @param groupName the name of the <tt>ContactGroup</tt> to retrieve.
- * @return the <tt>ContactGroup</tt> with the specified index.
- */
- public ContactGroup getGroup(String groupName)
- {
- Iterator<ContactGroup> groupsIter = subgroups();
- while (groupsIter.hasNext())
- {
- ContactGroupSSHImpl contactGroup
- = (ContactGroupSSHImpl) groupsIter.next();
- if (contactGroup.getGroupName().equals(groupName))
- return contactGroup;
-
- }
- return null;
-
- }
-
- /**
- * Returns the name of this group.
- *
- * @return a String containing the name of this group.
- */
- public String getGroupName()
- {
- return this.groupName;
- }
-
- /**
- * Sets this group a new name.
- * @param newGrpName a String containing the new name of this group.
- */
- public void setGroupName(String newGrpName)
- {
- this.groupName = newGrpName;
- }
-
- /**
- * Returns an iterator over the sub groups that this
- * <tt>ContactGroup</tt> contains.
- *
- * @return a java.util.Iterator over the <tt>ContactGroup</tt> children
- * of this group (i.e. subgroups).
- */
- public Iterator<ContactGroup> subgroups()
- {
- return subGroups.iterator();
- }
-
- /**
- * Removes the specified contact from this group.
- * @param contact the ContactSSHImpl to remove from this group
- */
- public void removeContact(ContactSSHImpl contact)
- {
- this.contacts.remove(contact);
- }
-
- /**
- * Returns the contact with the specified id or null if no such contact
- * exists.
- * @param id the id of the contact we're looking for.
- * @return ContactSSHImpl
- */
- public ContactSSHImpl findContactByID(String id)
- {
- //first go through the contacts that are direct children.
- Iterator<Contact> contactsIter = contacts();
-
- while(contactsIter.hasNext())
- {
- ContactSSHImpl mContact = (ContactSSHImpl)contactsIter.next();
-
- if( mContact.getAddress().equals(id) )
- return mContact;
- }
-
- //if we didn't find it here, let's try in the subougroups
- Iterator<ContactGroup> groupsIter = subgroups();
-
- while( groupsIter.hasNext() )
- {
- ContactGroupSSHImpl mGroup = (ContactGroupSSHImpl)groupsIter.next();
-
- ContactSSHImpl mContact = mGroup.findContactByID(id);
-
- if (mContact != null)
- return mContact;
- }
-
- return null;
- }
-
- /**
- * Returns a String representation of this group and the contacts it
- * contains (may turn out to be a relatively long string).
- * @return a String representing this group and its child contacts.
- */
- @Override
- public String toString()
- {
- StringBuffer buff = new StringBuffer(getGroupName());
- buff.append(".subGroups=" + countSubgroups() + ":\n");
-
- Iterator<ContactGroup> subGroups = subgroups();
- while (subGroups.hasNext())
- {
- ContactGroup group = subGroups.next();
- buff.append(group.toString());
- if (subGroups.hasNext())
- buff.append("\n");
- }
-
- buff.append("\nChildContacts="+countContacts()+":[");
-
- Iterator<Contact> contacts = contacts();
- while (contacts.hasNext())
- {
- Contact contact = contacts.next();
- buff.append(contact.toString());
- if(contacts.hasNext())
- buff.append(", ");
- }
- return buff.append("]").toString();
- }
-
- /**
- * Specifies whether or not this contact group is being stored by the
- * server.
- * Non persistent contact groups are common in the case of simple,
- * non-persistent presence operation sets. They could however also be seen
- * in persistent presence operation sets when for example we have received
- * an event from someone not on our contact list and the contact that we
- * associated with that user is placed in a non persistent group. Non
- * persistent contact groups are volatile even when coming from a
- * persistent presence op. set. They would only exist until the
- * application is closed and will not be there next time it is loaded.
- *
- * @param isPersistent true if the contact group is to be persistent and
- * false otherwise.
- */
- public void setPersistent(boolean isPersistent)
- {
- this.isPersistent = isPersistent;
- }
-
- /**
- * Determines whether or not this contact group is being stored by the
- * server. Non persistent contact groups exist for the sole purpose of
- * containing non persistent contacts.
- * @return true if the contact group is persistent and false otherwise.
- */
- public boolean isPersistent()
- {
- return isPersistent;
- }
-
- /**
- * Returns null as no persistent data is required and the contact address is
- * sufficient for restoring the contact.
- * <p>
- * @return null as no such data is needed.
- */
- public String getPersistentData()
- {
- return null;
- }
-
- /**
- * Determines whether or not this contact has been resolved against the
- * server. Unresolved contacts are used when initially loading a contact
- * list that has been stored in a local file until the presence operation
- * set has managed to retrieve all the contact list from the server and has
- * properly mapped contacts to their on-line buddies.
- * @return true if the contact has been resolved (mapped against a buddy)
- * and false otherwise.
- */
- public boolean isResolved()
- {
- return isResolved;
- }
-
- /**
- * Makes the group resolved or unresolved.
- *
- * @param resolved true to make the group resolved; false to
- * make it unresolved
- */
- public void setResolved(boolean resolved)
- {
- this.isResolved = resolved;
- }
-
- /**
- * Returns a <tt>String</tt> that uniquely represnets the group inside
- * the current protocol. The string MUST be persistent (it must not change
- * across connections or runs of the application). In many cases (Jabber,
- * ICQ) the string may match the name of the group as these protocols
- * only allow a single level of contact groups and there is no danger of
- * having the same name twice in the same contact list. Other protocols
- * (no examples come to mind but that doesn't bother me ;) ) may be
- * supporting mutilple levels of grooups so it might be possible for group
- * A and group B to both contain groups named C. In such cases the
- * implementation must find a way to return a unique identifier in this
- * method and this UID should never change for a given group.
- *
- * @return a String representing this group in a unique and persistent
- * way.
- */
- public String getUID()
- {
- return uid;
- }
-
- /**
- * Ugly but tricky conversion method.
- * @param uid the uid we'd like to get a name from
- * @return the name of the group with the specified <tt>uid</tt>.
- */
- static String createNameFromUID(String uid)
- {
- return uid.substring(0, uid.length() - (UID_SUFFIX.length()));
- }
-
- /**
- * Indicates whether some other object is "equal to" this one which in terms
- * of contact groups translates to having the equal names and matching
- * subgroups and child contacts. The resolved status of contactgroups and
- * contacts is deliberately ignored so that groups and/or contacts would
- * be assumed equal even if it differs.
- * <p>
- * @param obj the reference object with which to compare.
- * @return <code>true</code> if this contact group has the equal child
- * contacts and subgroups to those of the <code>obj</code> argument.
- */
- @Override
- public boolean equals(Object obj)
- {
- if(obj == null
- || !(obj instanceof ContactGroupSSHImpl))
- return false;
-
- ContactGroupSSHImpl sshGroup
- = (ContactGroupSSHImpl)obj;
-
- if( ! sshGroup.getGroupName().equals(getGroupName())
- || ! sshGroup.getUID().equals(getUID())
- || sshGroup.countContacts() != countContacts()
- || sshGroup.countSubgroups() != countSubgroups())
- return false;
-
- //traverse child contacts
- Iterator<Contact> theirContacts = sshGroup.contacts();
-
- while(theirContacts.hasNext())
- {
- Contact theirContact = theirContacts.next();
- Contact ourContact = getContact(theirContact.getAddress());
-
- if(ourContact == null
- || !ourContact.equals(theirContact))
- return false;
- }
-
- //traverse subgroups
- Iterator<ContactGroup> theirSubgroups = sshGroup.subgroups();
-
- while(theirSubgroups.hasNext())
- {
- ContactGroup theirSubgroup = theirSubgroups.next();
- ContactGroup ourSubgroup = getGroup(theirSubgroup.getGroupName());
-
- if(ourSubgroup == null
- || !ourSubgroup.equals(theirSubgroup))
- return false;
- }
-
- return true;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSH.java b/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSH.java
deleted file mode 100644
index a13414b..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSH.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.io.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-import com.jcraft.jsch.*;
-
-/**
- * This interface represents a Contact of SSH Type
- * As a SSH Session is specific to a contact, additional information needed
- * to maintain its state with the remote server is present here
- *
- * @author Shobhit Jindal
- */
-interface ContactSSH
- extends Contact
-{
- /**
- * An event type indicating that the message being received is a standard
- * 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
- * <tt>ContactGroupSSHImpl</tt> itself.
- *
- * @param newParentGroup the <tt>ContactGroupSSHImpl</tt> that is now
- * parent of this <tt>ContactSSHImpl</tt>
- */
- void setParentGroup (ContactGroupSSHImpl newParentGroup);
-
- /**
- * Sets <tt>sshPresenceStatus</tt> as the PresenceStatus that this
- * contact is currently in.
- * @param sshPresenceStatus the <tt>SSHPresenceStatus</tt>
- * currently valid for this contact.
- */
- public void setPresenceStatus (PresenceStatus sshPresenceStatus);
-
- /**
- * Returns the persistent presence operation set that this contact belongs
- * to.
- *
- * @return the <tt>OperationSetPersistentPresenceSSHImpl</tt> that
- * this contact belongs to.
- */
- public OperationSetPersistentPresence
- getParentPresenceOperationSet ();
-
- /**
- * Returns the BasicInstant Messaging operation set that this contact
- * belongs to.
- *
- * @return the <tt>OperationSetBasicInstantMessagingSSHImpl</tt> that
- * this contact belongs to.
- */
- public OperationSetBasicInstantMessaging
- getParentBasicInstantMessagingOperationSet ();
-
- /**
- * Returns the File Transfer operation set that this contact belongs
- * to.
- *
- * @return the <tt>OperationSetFileTransferSSHImpl</tt> that
- * this contact belongs to.
- */
- 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.
- *
- * @param resolved true to make the contact resolved; false to
- * 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
- * presence operation sets. They could however also be seen in persistent
- * presence operation sets when for example we have received an event
- * from someone not on our contact list. Non persistent contacts are
- * volatile even when coming from a persistent presence op. set. They would
- * only exist until the application is closed and will not be there next
- * time it is loaded.
- *
- * @param isPersistent true if the contact is persistent and false
- * otherwise.
- */
- public void setPersistent (boolean isPersistent);
-
- /**
- * Returns true if a command has been sent whos reply was not received yet
- * false otherwise
- *
- * @return commandSent
- */
- public boolean isCommandSent ();
-
- /**
- * Set the state of commandSent variable which determines whether a reply
- * to a command sent is awaited
- *
- * @param commandSent
- */
- public void setCommandSent (boolean commandSent);
-
- /**
- * Initializes the reader and writers associated with shell of this contact
- *
- * @param shellInputStream The InputStream of stack
- * @param shellOutputStream The OutputStream of stack
- */
- 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
-// *
-// * @param sshPrompt to be associated
-// */
-// public void setShellPrompt(String sshPrompt);
-//
-// /**
-// * Returns the PS1 prompt of the current shell of Contact
-// *
-// * @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;
-
-// /**
-// * Reads a line from the remote machine via the Shell Reader
-// *
-// * @return message read
-// */
-// 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
-// *
-// * @param shellInputStream to be associated with SSH Channel of this
-// * 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
-// *
-// * @param shellOutputStream to be associated with SSH Channel of this
-// * contact
-// */
-// public void setShellOutputStream(OutputStream shellOutputStream);
-//
- /**
- * Returns the BufferedReader associated with SSH Channel of this contact
- *
- * @return shellReader associated with SSH Channel of this contact
- */
- public InputStreamReader getShellReader ();
-//
-// /**
-// * Sets the BufferedReader associated with SSH Channel of this contact
-// *
-// * @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
-// *
-// * @param shellWriter to be associated with SSH Channel of this contact
-// */
-// public void setShellWriter(PrintWriter shellWriter);
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java
deleted file mode 100644
index 15da209..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java
+++ /dev/null
@@ -1,918 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.Base64; // disambiguation
-import net.java.sip.communicator.util.Logger;
-
-import com.jcraft.jsch.*;
-// disambiguation
-
-/**
- * A Contact of SSH Type
- *
- * @author Shobhit Jindal
- */
-public class ContactSSHImpl
- extends AbstractContact
- implements ContactSSH
-{
- private static final Logger logger
- = Logger.getLogger(ContactSSHImpl.class);
-
- /**
- * This acts as a separator between details stored in persistent data
- */
- private final String separator =
- Resources.getString("impl.protocol.ssh.DETAILS_SEPARATOR");
-
- /**
- * The identifier for SSH Stack
- * Java Secure Channel JSch
- */
- private JSch jsch;
-
- /**
- * Interface for user to provide details about machine
- */
- private SSHContactInfo sshConfigurationForm;
-
- /**
- * A Timer Daemon to update the status of this contact
- */
- private Timer timer = new Timer(true);
-
- /**
- * A Daemon to retrieve and fire messages received from remote machine
- */
- private SSHReaderDaemon contactSSHReaderDaemon;
-
- /**
- * The id of the contact.
- */
- private String contactID = null;
-
- /**
- * The persistentData of the contact.
- */
- private String persistentData = null;
-
-// /**
-// * This stores the prompt string of shell
-// */
-// private String sshPrompt;
-
- /**
- * The provider that created us.
- */
- private ProtocolProviderServiceSSHImpl parentProvider = null;
-
- /**
- * The identifier of the type of message received from server
- */
- private int messageType;
-
-
-
- /**
- * The identifier for SSH Session with the remote server
- */
- private Session sshSession = null;
-
- /**
- * The identifier for a sshShellChannel with the remote server is of type
- * shell - for an interactive SSH Session with the remote machine
- *
- * Other types
- * sftp - to tranfer files from/to the remote machine
- * exec - X forwarding
- * direct-tcpip - stream forwarding
- */
- private Channel sshShellChannel = null;
-
- /**
- * The identifier for the Shell Input Stream associated with SSH Sesion
- */
- private InputStream shellInputStream = null;
-
- /**
- * The identifier for the Shell Output Stream associated with SSH Sesion
- */
- private OutputStream shellOutputStream = null;
-
- /**
- * Higher wrapper for shellInputStream
- */
- private InputStreamReader shellReader = null;
-
- /**
- * Higher wrapper for shellOutputStream
- */
- private PrintWriter shellWriter = null;
-
- /**
- * The group that belong to.
- */
- private ContactGroupSSHImpl parentGroup = null;
-
- /**
- * The presence status of the contact.
- */
- private PresenceStatus presenceStatus = SSHStatusEnum.NOT_AVAILABLE;
-
- /**
- * Determines whether this contact is persistent, i.e. member of the contact
- * list or whether it is here only temporarily.
- */
- private boolean isPersistent = false;
-
- /**
- * Determines whether the contact has been resolved (i.e. we have a
- * confirmation that it is still on the server contact list).
- */
- private boolean isResolved = true;
-
- /**
- * Determines whether an connection attempt to remote server is already
- * underway
- */
- private boolean isConnectionInProgress = false;
-
- /**
- * Determines whether the message received from remote machine is as a
- * result of command sent to it
- */
- private boolean commandSent = false;
-
- /**
- * A lock to synchronize the access of commandSent boolean object
- * with the reader thread.
- */
- private final Object lock = new Object();
-
- /**
- * Creates an instance of a meta contact with the specified string used
- * as a name and identifier.
- *
- * @param id the identifier of this contact (also used as a name).
- * @param parentProvider the provider that created us.
- */
- public ContactSSHImpl(
- String id,
- ProtocolProviderServiceSSHImpl parentProvider)
- {
- this.contactID = id;
- this.parentProvider = parentProvider;
-
- this.sshConfigurationForm =
- new SSHContactInfo(this);
-
- this.savePersistentDetails();
- }
-
- /**
- * Initializes the reader and writers associated with shell of this contact
- *
- * @param shellInputStream The InputStream of stack
- * @param shellOutputStream The OutputStream of stack
- */
- public void initializeShellIO(
- InputStream shellInputStream,
- OutputStream shellOutputStream)
- {
- this.shellInputStream = shellInputStream;
- this.shellOutputStream = shellOutputStream;
- shellReader = new InputStreamReader(shellInputStream);
- shellWriter = new PrintWriter(shellOutputStream);
-
- contactSSHReaderDaemon = new SSHReaderDaemon(this);
- contactSSHReaderDaemon.setDaemon(true);
- contactSSHReaderDaemon.isActive(true);
- contactSSHReaderDaemon.start();
- }
-
- /**
- * Closes the readers and writer associated with shell of this contact
- */
- public void closeShellIO()
- {
- try
- {
- shellReader.close();
- shellInputStream.close();
- }
- catch(IOException ex)
- {}
-
- try
- {
- shellWriter.close();
- shellOutputStream.close();
- }
- catch(IOException ex)
- {}
-
- shellInputStream = null;
-
- shellReader = null;
-
- shellOutputStream = null;
-
- shellWriter = null;
-
- try
- {
- sshShellChannel.disconnect();
- }
- catch(Exception e)
- {}
-
- // Removing the reference to current channel
- // a new shell channel will be created for the next message
- sshShellChannel = null;
-
- // remove the reference of session if it were also disconnected
- // like in the case of exit command
- if(!sshSession.isConnected())
- {
- sshSession = null;
- jsch = null;
- }
-
- ((OperationSetPersistentPresenceSSHImpl)
- getParentPresenceOperationSet()).
- changeContactPresenceStatus(this, SSHStatusEnum.ONLINE);
- }
-
- /**
- * Sends a message a line to remote machine via the Shell Writer
- *
- * @param message to be sent
- */
- public void sendLine(String message)
- throws IOException
- {
-// logger.debug("SSH TO: " + this.contactID + ": " + message);
- shellWriter.println(message);
- shellWriter.flush();
- }
-
- /**
- * Reads a line from the remote machine via the Shell Reader
- *
- * @return message read
- */
-// public String getLine()
-// throws IOException
-// {
-// String line = shellReader.readLine();
-//// logger.debug("SSH FROM: " + this.contactID + ": " + line);
-//
-// // null is never returned normally, the reading attempt returs a
-// // string
-// // or blocks until one line is available
-// if(line == null)
-// {
-// sshShellChannel.disconnect();
-// sshShellChannel = null;
-// sshSession = null;
-// throw(new IOException("Unexpected Reply from remote Server"));
-// }
-// return line;
-// }
-
- /**
- * Starts the timer and its task to periodically update the status of
- * remote machine
- */
- public void startTimerTask()
- {
- timer.scheduleAtFixedRate(new ContactTimerSSHImpl(this),
- 2000, sshConfigurationForm.getUpdateInterval()*1000);
- }
-
- /**
- * Stops the timer and its task to stop updating the status of
- * remote machine
- */
- public void stopTimerTask()
- {
- timer.cancel();
- }
-
-
- /**
- * Saves the details of contact in persistentData seperated by
- * separator
- * Passowrd is saved unsecurely using Base64 encoding
- */
- public void savePersistentDetails()
- {
- persistentData =
- this.sshConfigurationForm.getHostName() +
- separator +
- this.sshConfigurationForm.getUserName() +
- separator +
- new String(Base64.encode(this.sshConfigurationForm.getPassword()
- .getBytes())) +
- separator + sshConfigurationForm.getPort() +
- separator +
- sshConfigurationForm.getTerminalType() +
- separator +
- sshConfigurationForm.getUpdateInterval();
- }
-
- /**
- * Stores persistent data in fields of the contact seperated by
- * separator.
- *
- * @param persistentData of the contact
- */
- public void setPersistentData(String persistentData)
- {
- try
- {
- this.persistentData = persistentData;
- int firstCommaIndex = this.persistentData.indexOf(separator);
- int secondCommaIndex = this.persistentData.indexOf(separator,
- firstCommaIndex +1);
- int thirdCommaIndex = this.persistentData.indexOf(separator,
- secondCommaIndex +1);
- int fourthCommaIndex = this.persistentData.indexOf(separator,
- thirdCommaIndex +1);
- int fifthCommaIndex = this.persistentData.indexOf(separator,
- fourthCommaIndex +1);
-
- if (logger.isDebugEnabled())
- logger.debug("Commas: " + firstCommaIndex + " " + secondCommaIndex + " "
- + thirdCommaIndex + " " +fourthCommaIndex + " "
- +fifthCommaIndex);
-
- this.sshConfigurationForm.setHostNameField(
- this.persistentData.substring(0,firstCommaIndex));
-
- this.sshConfigurationForm.setUserNameField(
- this.persistentData.substring(firstCommaIndex+1,
- secondCommaIndex));
-
- if( (thirdCommaIndex - secondCommaIndex) > 1)
- {
- if(this.persistentData.substring(secondCommaIndex+1).length()>0)
- this.sshConfigurationForm.setPasswordField(
- new String(Base64.decode(this.persistentData
- .substring(secondCommaIndex+1, thirdCommaIndex))));
- }
-
-
- this.sshConfigurationForm.setPort(
- this.persistentData.substring(thirdCommaIndex + 1,
- fourthCommaIndex));
-
- this.sshConfigurationForm.setTerminalType(
- this.persistentData.substring(fourthCommaIndex + 1,
- fifthCommaIndex));
-
- this.sshConfigurationForm.setUpdateInterval(
- Integer.parseInt(this.persistentData.substring(fifthCommaIndex+1)));
- }
- catch(Exception ex)
- {
- logger.error("Error setting persistent data!", ex);
- }
- }
-
- /**
- * Determines whether a connection to a remote server is already underway
- *
- * @return isConnectionInProgress
- */
- public boolean isConnectionInProgress()
- {
- return this.isConnectionInProgress;
- }
-
- /**
- * Sets the status of connection attempt to remote server
- * This method is synchronized
- *
- * @param isConnectionInProgress
- */
- public synchronized void setConnectionInProgress(
- boolean isConnectionInProgress)
- {
- this.isConnectionInProgress = isConnectionInProgress;
- }
-
- /**
- * Returns the SSHContactInfo associated with this contact
- *
- * @return sshConfigurationForm
- */
- public SSHContactInfo getSSHConfigurationForm()
- {
- return this.sshConfigurationForm;
- }
-
- /**
- * Returns the JSch Stack identified associated with this contact
- *
- * @return jsch
- */
- public JSch getJSch()
- {
- return this.jsch;
- }
-
- /**
- * Sets the JSch Stack identified associated with this contact
- *
- * @param jsch to be associated
- */
- public void setJSch(JSch jsch)
- {
- this.jsch = jsch;
- }
-
- /**
- * This method is only called when the contact is added to a new
- * <tt>ContactGroupSSHImpl</tt> by the
- * <tt>ContactGroupSSHImpl</tt> itself.
- *
- * @param newParentGroup the <tt>ContactGroupSSHImpl</tt> that is now
- * parent of this <tt>ContactSSHImpl</tt>
- */
- public void setParentGroup(ContactGroupSSHImpl newParentGroup)
- {
- this.parentGroup = newParentGroup;
- }
-
- /**
- * Returns the Hostname associated with this contact
- *
- * @return hostName
- */
- public String getHostName()
- {
- return sshConfigurationForm.getHostName();
- }
-
- /**
- * Returns a String that can be used for identifying the contact.
- *
- * @return a String id representing and uniquely identifying the contact.
- */
- public String getAddress()
- {
- return contactID;
- }
-
- /**
- * Returns a String that could be used by any user interacting modules
- * for referring to this contact.
- *
- * @return a String that can be used for referring to this contact when
- * interacting with the user.
- */
- public String getDisplayName()
- {
- return contactID;
- }
-
- /**
- * Returns a byte array containing an image (most often a photo or an
- * avatar) that the contact uses as a representation.
- *
- * @return byte[] an image representing the contact.
- */
- public byte[] getImage()
- {
- return null;
- }
-
- /**
- * Returns true if a command has been sent whos reply was not received yet
- * false otherwise
- *
- * @return commandSent
- */
- public boolean isCommandSent()
- {
- return this.commandSent;
- }
-
- /**
- * Set the state of commandSent variable which determines whether a reply
- * to a command sent is awaited
- */
- public void setCommandSent(boolean commandSent)
- {
- synchronized(lock)
- {
- this.commandSent = commandSent;
- }
- }
-
- /**
- * Return the type of message received from remote server
- *
- * @return messageType
- */
- public int getMessageType()
- {
- return this.messageType;
- }
-
- /**
- * Sets the type of message received from remote server
- *
- * @param messageType
- */
- public void setMessageType(int messageType)
- {
- this.messageType = messageType;
- }
-
- /**
- * Returns the status of the contact.
- *
- * @return presenceStatus
- */
- public PresenceStatus getPresenceStatus()
- {
- return this.presenceStatus;
- }
-
- /**
- * Sets <tt>sshPresenceStatus</tt> as the PresenceStatus that this
- * contact is currently in.
- * @param sshPresenceStatus the <tt>SSHPresenceStatus</tt>
- * currently valid for this contact.
- */
- public void setPresenceStatus(PresenceStatus sshPresenceStatus)
- {
- this.presenceStatus = sshPresenceStatus;
- }
-
- /**
- * Returns a reference to the protocol provider that created the contact.
- *
- * @return a refererence to an instance of the ProtocolProviderService
- */
- public ProtocolProviderService getProtocolProvider()
- {
- return parentProvider;
- }
-
- /**
- * Determines whether or not this contact represents our own identity.
- *
- * @return true
- */
- public boolean isLocal()
- {
- return true;
- }
-
- /**
- * Returns the group that contains this contact.
- * @return a reference to the <tt>ContactGroupSSHImpl</tt> that
- * contains this contact.
- */
- public ContactGroup getParentContactGroup()
- {
- return this.parentGroup;
- }
-
- /**
- * Returns a string representation of this contact, containing most of its
- * representative details.
- *
- * @return a string representation of this contact.
- */
- @Override
- public String toString()
- {
- StringBuffer buff
- = new StringBuffer("ContactSSHImpl[ DisplayName=")
- .append(getDisplayName()).append("]");
-
- return buff.toString();
- }
-
- /**
- * Determines whether or not this contact is being stored by the server.
- * Non persistent contacts are common in the case of simple, non-persistent
- * presence operation sets. They could however also be seen in persistent
- * presence operation sets when for example we have received an event
- * from someone not on our contact list. Non persistent contacts are
- * volatile even when coming from a persistent presence op. set. They would
- * only exist until the application is closed and will not be there next
- * time it is loaded.
- *
- * @return true if the contact is persistent and false otherwise.
- */
- public boolean isPersistent()
- {
- return isPersistent;
- }
-
- /**
- * Specifies whether or not this contact is being stored by the server.
- * Non persistent contacts are common in the case of simple, non-persistent
- * presence operation sets. They could however also be seen in persistent
- * presence operation sets when for example we have received an event
- * from someone not on our contact list. Non persistent contacts are
- * volatile even when coming from a persistent presence op. set. They would
- * only exist until the application is closed and will not be there next
- * time it is loaded.
- *
- * @param isPersistent true if the contact is persistent and false
- * otherwise.
- */
- public void setPersistent(boolean isPersistent)
- {
- this.isPersistent = isPersistent;
- }
-
-
- /**
- * Returns persistent data of the contact.
- *
- * @return persistentData of the contact
- */
- public String getPersistentData()
- {
- return persistentData;
- }
-
- /**
- * Determines whether or not this contact has been resolved against the
- * server. Unresolved contacts are used when initially loading a contact
- * list that has been stored in a local file until the presence operation
- * set has managed to retrieve all the contact list from the server and has
- * properly mapped contacts to their on-line buddies.
- *
- * @return true if the contact has been resolved (mapped against a buddy)
- * and false otherwise.
- */
- public boolean isResolved()
- {
- return isResolved;
- }
-
- /**
- * Makes the contact resolved or unresolved.
- *
- * @param resolved true to make the contact resolved; false to
- * make it unresolved
- */
- public void setResolved(boolean resolved)
- {
- this.isResolved = resolved;
- }
-
- /**
- * Returns the persistent presence operation set that this contact belongs
- * to.
- *
- * @return the <tt>OperationSetPersistentPresenceSSHImpl</tt> that
- * this contact belongs to.
- */
- public OperationSetPersistentPresence
- getParentPresenceOperationSet()
- {
- return
- parentProvider
- .getOperationSet(OperationSetPersistentPresence.class);
- }
-
- /**
- * Returns the BasicInstant Messaging operation set that this contact
- * belongs to.
- *
- * @return the <tt>OperationSetBasicInstantMessagingSSHImpl</tt> that
- * this contact belongs to.
- */
- public OperationSetBasicInstantMessaging
- getParentBasicInstantMessagingOperationSet()
- {
- return
- parentProvider
- .getOperationSet(OperationSetBasicInstantMessaging.class);
- }
-
- /**
- * Returns the File Transfer operation set that this contact belongs
- * to.
- *
- * @return the <tt>OperationSetFileTransferSSHImpl</tt> that
- * this contact belongs to.
- */
- public OperationSetFileTransfer
- getFileTransferOperationSet()
- {
- return parentProvider.getOperationSet(OperationSetFileTransfer.class);
- }
-
-
- /**
- * Returns the SSH Session associated with this contact
- *
- * @return sshSession
- */
- public Session getSSHSession()
- {
- return this.sshSession;
- }
-
- /**
- * Sets the SSH Session associated with this contact
- *
- * @param sshSession the newly created SSH Session to be associated
- */
- public void setSSHSession(Session sshSession)
- {
- this.sshSession = sshSession;
- }
-
- /**
- * Returns the SSH Shell Channel associated with this contact
- *
- * @return sshShellChannel
- */
- public Channel getShellChannel()
- {
- return this.sshShellChannel;
- }
-
- /**
- * Sets the SSH Shell channel associated with this contact
- *
- * @param sshShellChannel to be associated with SSH Session of this contact
- */
- public void setShellChannel(Channel sshShellChannel)
- {
- this.sshShellChannel = sshShellChannel;
- }
-
- /**
- * Returns the Input Stream associated with SSH Channel of this contact
- *
- * @return shellInputStream associated with SSH Channel of this contact
- */
- public InputStream getShellInputStream()
- {
- return this.shellInputStream;
- }
-
-// /**
-// * Sets the Input Stream associated with SSH Channel of this contact
-// *
-// * @param shellInputStream to be associated with SSH Channel of
-// * this contact
-// */
-// public void setShellInputStream(InputStream shellInputStream)
-// {
-// this.shellInputStream = shellInputStream;
-// }
-
- /**
- * Returns the Output Stream associated with SSH Channel of this contact
- *
- * @return shellOutputStream associated with SSH Channel of this contact
- */
- public OutputStream getShellOutputStream()
- {
- return this.shellOutputStream;
- }
-
-// /**
-// * Sets the Output Stream associated with SSH Channel of this contact
-// *
-// * @param shellOutputStream to be associated with SSH Channel of this contact
-// */
-// public void setShellOutputStream(OutputStream shellOutputStream)
-// {
-// this.shellOutputStream = shellOutputStream;
-// }
-
- /**
- * Returns the BufferedReader associated with SSH Channel of this contact
- *
- * @return shellReader associated with SSH Channel of this contact
- */
- public InputStreamReader getShellReader()
- {
- return this.shellReader;
- }
-
-// /**
-// * Sets the BufferedReader associated with SSH Channel of this contact
-// *
-// * @param shellReader to be associated with SSH Channel of this contact
-// */
-// public void setShellReader(BufferedReader shellReader)
-// {
-// this.shellReader = shellReader;
-// }
-
- /**
- * Returns the PrintWriter associated with SSH Channel of this contact
- *
- * @return shellWriter associated with SSH Channel of this contact
- */
- public PrintWriter getShellWriter()
- {
- return this.shellWriter;
- }
-
-// /**
-// * Sets the PrintWriter associated with SSH Channel of this contact
-// *
-// * @param shellWriter to be associated with SSH Channel of this contact
-// */
-// public void setShellWriter(PrintWriter shellWriter)
-// {
-// this.shellWriter = shellWriter;
-// }
-
- /**
- * Returns the userName associated with SSH Channel of this contact
- *
- * @return userName associated with SSH Channel of this contact
- */
- public String getUserName()
- {
- return sshConfigurationForm.getUserName();
- }
-
- /**
- * Returns the password associated with SSH Channel of this contact
- *
- * @return password associated with SSH Channel of this contact
- */
- public String getPassword()
- {
- return sshConfigurationForm.getPassword();
- }
-
- /**
- * Sets the Password associated with this contact
- *
- * @param password
- */
- public void setPassword(String password)
- {
- this.sshConfigurationForm.setPasswordField(password);
- savePersistentDetails();
- }
-
-// /**
-// * Sets the PS1 prompt of the current shell of Contact
-// *
-// * @param sshPrompt to be associated
-// */
-// public void setShellPrompt(String sshPrompt)
-// {
-// this.sshPrompt = sshPrompt;
-// }
-//
-// /**
-// * Returns the PS1 prompt of the current shell of Contact
-// *
-// * @return sshPrompt
-// */
-// public String getShellPrompt()
-// {
-// return this.sshPrompt;
-// }
-
- /**
- * Return the current status message of this contact.
- *
- * @return the current status message
- */
- public String getStatusMessage()
- {
- return presenceStatus.getStatusName();
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ContactTimerSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ContactTimerSSHImpl.java
deleted file mode 100644
index 4e3664d..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ContactTimerSSHImpl.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import net.java.sip.communicator.util.*;
-
-/**
- * Timer Task to update the reachability status of SSH Contact in contact list.
- * (Reachability of remote machine from user's machine)
- * The timer is started at either of the two places
- * - A new contact - OperationSetPersistentPresenceSSHImpl
- * .createUnresolvedContact
- * - Existing Contact - OperationSetPersistentPresenceSSHImpl.subscribe
- *
- * @author Shobhit Jindal
- */
-public class ContactTimerSSHImpl
- extends TimerTask
-{
- private static final Logger logger
- = Logger.getLogger(OperationSetFileTransferSSHImpl.class);
-
- /**
- * The contact ID of the remote machine
- */
- private ContactSSH sshContact;
-
- /**
- * PersistentPresence Identifer assoiciated with SSH Contact
- */
- private OperationSetPersistentPresenceSSHImpl persistentPresence;
-
- /**
- * The method which is called at regular intervals to update the status
- * of remote machines
- *
- * Presently only ONLINE and OFFILINE status are checked
- */
- @Override
- public void run()
- {
- try
- {
- InetAddress remoteMachine = InetAddress.getByName(
- sshContact.getSSHConfigurationForm().getHostName());
-
- //check if machine is reachable
- if(remoteMachine.isReachable(
- sshContact.getSSHConfigurationForm().getUpdateInterval()))
- {
- if (sshContact.getPresenceStatus().equals(SSHStatusEnum.OFFLINE)
- || sshContact.getPresenceStatus().equals(SSHStatusEnum
- .NOT_AVAILABLE))
- {
- // change status to online
- persistentPresence.changeContactPresenceStatus(
- sshContact, SSHStatusEnum.ONLINE);
-
- if (logger.isDebugEnabled())
- logger.debug("SSH Host " + sshContact
- .getSSHConfigurationForm().getHostName() + ": Online");
- }
-
- }
- else throw new IOException();
-
- }
- catch (IOException ex)
- {
- if (sshContact.getPresenceStatus().equals(SSHStatusEnum.ONLINE)
- || sshContact.getPresenceStatus().equals(
- SSHStatusEnum.NOT_AVAILABLE))
- {
- persistentPresence.changeContactPresenceStatus(
- sshContact, SSHStatusEnum.OFFLINE);
-
- if (logger.isDebugEnabled())
- logger.debug("SSH Host " + sshContact.getSSHConfigurationForm()
- .getHostName() + ": Offline");
- }
- }
- }
- /**
- * Creates a new instance of ContactTimerSSHImpl
- *
- * @param sshContact the <tt>Contact</tt>
- */
- public ContactTimerSSHImpl(ContactSSH sshContact)
- {
- super();
- this.sshContact = sshContact;
- this.persistentPresence = (OperationSetPersistentPresenceSSHImpl)
- sshContact.getParentPresenceOperationSet();
- }
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/FileTransferSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/FileTransferSSHImpl.java
deleted file mode 100644
index 1e95032..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/FileTransferSSHImpl.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * SSH implementation of the <tt>AbstractFileTransfer</tt>.
- *
- * @author Yana Stamcheva
- */
-public class FileTransferSSHImpl
- extends AbstractFileTransfer
-{
- private final SSHFileTransferDaemon fileTransfer;
-
- private final Date initialDate;
-
- /**
- * Creates an SSH implementation of the file transfer interface.
- *
- * @param fileTransfer the SSH file transfer
- * @param date the initial date of the transfer
- */
- public FileTransferSSHImpl( SSHFileTransferDaemon fileTransfer,
- Date date)
- {
- this.fileTransfer = fileTransfer;
- this.initialDate = date;
- }
-
- /**
- * Cancels this file transfer. When this method is called transfer should
- * be interrupted.
- */
- @Override
- public void cancel()
- {
- // TODO: Implement cancel() for SSH file transfer.
- }
-
- /**
- * Returns the number of bytes already transfered through this file transfer.
- *
- * @return the number of bytes already transfered through this file transfer
- */
- @Override
- public long getTransferedBytes()
- {
- // TODO: Implement getTransferedBytes() for SSH file transfer.
- return 0;
- }
-
- public int getDirection()
- {
- return IN;
- }
-
- public File getLocalFile()
- {
- return null;
- }
-
- public Contact getContact()
- {
- return null;
- }
-
- public String getID()
- {
- return null;
- }
-
- public Date getInitialDate()
- {
- return initialDate;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/MessageSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/MessageSSHImpl.java
deleted file mode 100644
index a8324f7..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/MessageSSHImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * Very simple message implementation for the SSH protocol.
- *
- * @author Shobhit Jindal
- * @author Lubomir Marinov
- */
-public class MessageSSHImpl
- extends AbstractMessage
-{
-
- /**
- * The content type of the message.
- */
- public static String contentType = "text/plain";
-
- /**
- * Creates a message instance according to the specified parameters.
- *
- * @param content the message body
- * @param contentType message content type or null for text/plain
- * @param contentEncoding message encoding or null for UTF8
- * @param subject the subject of the message or null for no subject.
- */
- public MessageSSHImpl(String content, String contentType,
- String contentEncoding, String subject)
- {
- super(content, null, contentEncoding, subject);
-
- MessageSSHImpl.contentType = contentType;
- }
-
- /**
- * Returns the type of the content of this message.
- *
- * @return the type of the content of this message.
- */
- @Override
- public String getContentType()
- {
- return contentType;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetBasicInstantMessagingSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetBasicInstantMessagingSSHImpl.java
deleted file mode 100644
index 9073ad5..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetBasicInstantMessagingSSHImpl.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-
-/**
- * Instant messaging functionality for the SSH protocol.
- *
- * @author Shobhit Jindal
- */
-public class OperationSetBasicInstantMessagingSSHImpl
- extends AbstractOperationSetBasicInstantMessaging
-{
-
- /**
- * The currently valid persistent presence operation set..
- */
- private OperationSetPersistentPresenceSSHImpl opSetPersPresence = null;
-
- /**
- * The currently valid file transfer operation set
- */
- private OperationSetFileTransferSSHImpl fileTransfer;
-
- /**
- * The protocol provider that created us.
- */
- private ProtocolProviderServiceSSHImpl parentProvider = null;
-
- /**
- * Creates an instance of this operation set keeping a reference to the
- * parent protocol provider and presence operation set.
- *
- * @param provider The provider instance that creates us.
- */
- public OperationSetBasicInstantMessagingSSHImpl(
- ProtocolProviderServiceSSHImpl provider)
- {
- this.parentProvider = provider;
-
- this.opSetPersPresence
- = (OperationSetPersistentPresenceSSHImpl)
- provider
- .getOperationSet(OperationSetPersistentPresence.class);
- }
-
- @Override
- public Message createMessage(String content, String contentType,
- String encoding, String subject)
- {
- return new MessageSSHImpl(content, contentType, encoding, subject);
- }
-
- /**
- * Sends the <tt>message</tt> to the destination indicated by the
- * <tt>to</tt> contact. An attempt is made to re-establish the shell
- * connection if the current one is invalid.
- * The reply from server is sent by a seperate reader thread
- *
- * @param to the <tt>Contact</tt> to send <tt>message</tt> to
- * @param message the <tt>Message</tt> to send.
- * @throws IllegalStateException if the underlying ICQ stack is not
- * registered and initialized.
- * @throws IllegalArgumentException if <tt>to</tt> is not an instance
- * belonging to the underlying implementation.
- */
- public void sendInstantMessage(
- Contact to,
- Message message)
- throws IllegalStateException,
- IllegalArgumentException
- {
- if( !(to instanceof ContactSSHImpl) )
- throw new IllegalArgumentException(
- "The specified contact is not a SSH contact."
- + to);
-
- ContactSSH sshContact = (ContactSSH)to;
-
- // making sure no messages are sent and no new threads are triggered,
- // until a thread trying to connect to remote server returns
- if(sshContact.isConnectionInProgress())
- {
- deliverMessage(
- createMessage("A connection attempt is in progress"),
- (ContactSSHImpl)to);
- return;
- }
-
- if( !parentProvider.isShellConnected(sshContact) )
- {
-
- try
- {
- /**
- * creating a new SSH session / shell channel
- * - first message
- * - session is timed out
- * - network problems
- */
- parentProvider.connectShell(sshContact, message);
-
- //the first message is ignored
- return;
- }
- catch (Exception ex)
- {
- throw new IllegalStateException(ex.getMessage());
- }
- }
-
- if(wrappedMessage(message.getContent(), sshContact))
- {
- fireMessageDelivered(message, to);
- return;
- }
-
- try
- {
- sshContact.sendLine(message.getContent());
- sshContact.setCommandSent(true);
- }
- catch (IOException ex)
- {
- // Closing IO Streams
- sshContact.closeShellIO();
-
- throw new IllegalStateException(ex.getMessage());
- }
-
- fireMessageDelivered(message, to);
- }
-
- /**
- * Check the message for wrapped Commands
- * All commands begin with /
- *
- * @param message from user
- * @param sshContact of the remote machine
- *
- * @return true if the message had commands, false otherwise
- */
- private boolean wrappedMessage(
- String message,
- ContactSSH sshContact)
- {
- if(message.startsWith("/upload"))
- {
- int firstSpace = message.indexOf(' ');
-
- try
- {
- sshContact.getFileTransferOperationSet().sendFile(
- sshContact,
- null,
- message.substring(message.indexOf(' ', firstSpace+1) + 1),
- message.substring(
- firstSpace+1,
- message.indexOf(' ', firstSpace+1)));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- return true;
- }
- else if(message.startsWith("/download"))
- {
- int firstSpace = message.indexOf(' ');
-
- try
- {
- sshContact.getFileTransferOperationSet().sendFile(
- null,
- sshContact,
- message.substring(firstSpace+1, message.indexOf(' ',
- firstSpace+1)),
- message.substring(message.indexOf(' ', firstSpace+1) + 1));
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- return true;
- }
- return false;
- }
-
- /**
- * In case the <tt>to</tt> Contact corresponds to another ssh
- * protocol provider registered with SIP Communicator, we deliver
- * the message to them, in case the <tt>to</tt> Contact represents us, we
- * fire a <tt>MessageReceivedEvent</tt>, and if <tt>to</tt> is simply
- * a contact in our contact list, then we simply echo the message.
- *
- * @param message the <tt>Message</tt> the message to deliver.
- * @param to the <tt>Contact</tt> that we should deliver the message to.
- */
- void deliverMessage(
- Message message,
- ContactSSH to)
- {
- String userID = to.getAddress();
-
- //if the user id is owr own id, then this message is being routed to us
- //from another instance of the ssh provider.
- if (userID.equals(this.parentProvider.getAccountID().getUserID()))
- {
- //check who is the provider sending the message
- String sourceUserID
- = to.getProtocolProvider().getAccountID().getUserID();
-
- //check whether they are in our contact list
- Contact from = opSetPersPresence.findContactByID(sourceUserID);
-
- //and if not - add them there as volatile.
- if(from == null)
- {
- from = opSetPersPresence.createVolatileContact(sourceUserID);
- }
-
- //and now fire the message received event.
- fireMessageReceived(message, from);
- }
- else
- {
- //if userID is not our own, try an check whether another provider
- //has that id and if yes - deliver the message to them.
- ProtocolProviderServiceSSHImpl sshProvider
- = this.opSetPersPresence.findProviderForSSHUserID(userID);
- if(sshProvider != null)
- {
- OperationSetBasicInstantMessagingSSHImpl opSetIM
- = (OperationSetBasicInstantMessagingSSHImpl)
- sshProvider
- .getOperationSet(
- OperationSetBasicInstantMessaging.class);
- opSetIM.deliverMessage(message, to);
- }
- else
- {
- //if we got here then "to" is simply someone in our contact
- //list so let's just echo the message.
- fireMessageReceived(message, to);
- }
- }
- }
-
- /**
- * Notifies all registered message listeners that a message has been
- * received.
- *
- * @param message the <tt>Message</tt> that has been received.
- * @param from the <tt>Contact</tt> that <tt>message</tt> was received from.
- */
- @Override
- protected void fireMessageReceived(Message message, Contact from)
- {
- fireMessageEvent(
- new MessageReceivedEvent(
- message,
- from,
- new Date(),
- ((ContactSSH) from).getMessageType()));
- }
-
- /**
- * Determines whether the SSH protocol provider supports
- * sending and receiving offline messages.
- *
- * @return <tt>false</tt>
- */
- public boolean isOfflineMessagingSupported()
- {
- return false;
- }
-
- /**
- * Determines wheter the protocol supports the supplied content type
- *
- * @param contentType the type we want to check
- * @return <tt>true</tt> if the protocol supports it and
- * <tt>false</tt> otherwise.
- */
- public boolean isContentTypeSupported(String contentType)
- {
- return MessageSSHImpl.contentType.equals(contentType);
- }
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java
deleted file mode 100644
index 61d8160..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * This class provides operations to upload/download files to remote machines
- *
- * @author Shobhit Jindal
- */
-public class OperationSetFileTransferSSHImpl
- implements OperationSetFileTransfer
-{
- 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
- *
- * @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
- *
- * @param listener the <tt>FileListener</tt> to register.
- */
- public void addFileTransferListener(
- FileTransferListener listener)
- {
- synchronized (fileTransferListeners)
- {
- if(!fileTransferListeners.contains(listener))
- fileTransferListeners.add(listener);
- }
- }
-
- public void removeFileTransferListener(
- FileTransferListener listener)
- {
- synchronized (fileTransferListeners)
- {
- fileTransferListeners.remove(listener);
- }
- }
-
- /**
- * 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
- */
- public FileTransfer sendFile( Contact toContact,
- File file)
- {
- return this.sendFile( toContact,
- null,
- file.getAbsolutePath(),
- file.getAbsolutePath());
- }
-
- /**
- * The file transfer method to/from the remote machine
- * either toContact is null(we are downloading file from remote machine
- * or fromContact is null(we are uploading file to remote machine
- *
- * @param toContact - the file recipient
- * @param fromContact - the file sender
- * @param remotePath - the identifier for the remote file
- * @param localPath - the identifier for the local file
- */
- public FileTransfer sendFile(
- Contact toContact,
- Contact fromContact,
- String remotePath,
- String localPath)
- {
- if(toContact == null)
- {
- SSHFileTransferDaemon fileTransferDaemon
- = new SSHFileTransferDaemon(
- (ContactSSH)fromContact,
- parentProvider);
-
- if(localPath.endsWith(System.getProperty("file.separator")))
- localPath += remotePath.substring(remotePath.lastIndexOf(
- System.getProperty("file.separator")) + 1);
-
- fileTransferDaemon.downloadFile(
- remotePath,
- localPath);
-
- return new FileTransferSSHImpl(fileTransferDaemon, new Date());
- }
- else if(fromContact == null)
- {
- SSHFileTransferDaemon fileTransferDaemon
- = new SSHFileTransferDaemon(
- (ContactSSH) toContact,
- parentProvider);
-
- fileTransferDaemon.uploadFile(
- remotePath,
- localPath);
-
- return new FileTransferSSHImpl(fileTransferDaemon, new Date());
- }
-
- // code should not reach here
- // assert false;
- logger.error("we should not be here !");
- return null;
- }
-
- /**
- * Returns the maximum file length supported by the protocol in bytes.
- * @return the file length that is supported.
- */
- public long getMaximumFileLength()
- {
- return 2048*1024*1024;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetPersistentPresenceSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetPersistentPresenceSSHImpl.java
deleted file mode 100644
index d4c63bd..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetPersistentPresenceSSHImpl.java
+++ /dev/null
@@ -1,980 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * A SSH implementation of a persistent presence operation set. In order
- * to simulate server persistence, this operation set would simply accept all
- * unresolved contacts and resolve them immediately. A real world protocol
- * implementation would save it on a server using methods provided by the
- * protocol stack.
- *
- * @author Shobhit Jindal
- */
-public class OperationSetPersistentPresenceSSHImpl
- extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceSSHImpl>
-{
- private static final Logger logger =
- Logger.getLogger(OperationSetPersistentPresenceSSHImpl.class);
-
- /**
- * The root of the ssh contact list.
- */
- private ContactGroupSSHImpl contactListRoot = null;
-
- /**
- * The currently active status message.
- */
- private String statusMessage = "Online";
-
- /**
- * Our default presence status.
- */
- private PresenceStatus presenceStatus = SSHStatusEnum.ONLINE;
-
- /**
- * Creates an instance of this operation set keeping a reference to the
- * specified parent <tt>provider</tt>.
- * @param provider the ProtocolProviderServiceSSHImpl instance that
- * created us.
- */
- public OperationSetPersistentPresenceSSHImpl(
- ProtocolProviderServiceSSHImpl provider)
- {
- super(provider);
-
- contactListRoot = new ContactGroupSSHImpl("RootGroup", provider);
-
- //add our unregistration listener
- parentProvider.addRegistrationStateChangeListener(
- new UnregistrationListener());
- }
-
- /**
- * This function changes the status of contact as well as that of the
- * provider
- *
- * @param sshContact the contact of the remote machine
- * @param newStatus new status of the contact
- */
- public void changeContactPresenceStatus(
- ContactSSH sshContact,
- PresenceStatus newStatus)
- {
- PresenceStatus oldStatus = sshContact.getPresenceStatus();
- sshContact.setPresenceStatus(newStatus);
- fireContactPresenceStatusChangeEvent(
- sshContact
- , sshContact.getParentContactGroup()
- , oldStatus);
- fireProviderStatusChangeEvent(oldStatus);
- }
-
- /**
- * Creates a group with the specified name and parent in the server
- * stored contact list.
- *
- * @param parent the group where the new group should be created
- * @param groupName the name of the new group to create.
- */
- public void createServerStoredContactGroup(
- ContactGroup parent,
- String groupName)
- {
- ContactGroupSSHImpl newGroup
- = new ContactGroupSSHImpl(groupName, parentProvider);
-
- ((ContactGroupSSHImpl)parent).addSubgroup(newGroup);
-
- this.fireServerStoredGroupEvent(
- newGroup, ServerStoredGroupEvent.GROUP_CREATED_EVENT);
- }
-
- /**
- * A SSH Provider method to use for fast filling of a contact list.
- *
- * @param contactGroup the group to add
- */
- public void addSSHGroup(ContactGroupSSHImpl contactGroup)
- {
- contactListRoot.addSubgroup(contactGroup);
- }
-
- /**
- * A SSH Provider method to use for fast filling of a contact list.
- * This method would add both the group and fire an event.
- *
- * @param parent the group where <tt>contactGroup</tt> should be added.
- * @param contactGroup the group to add
- */
- public void addSSHGroupAndFireEvent(
- ContactGroupSSHImpl parent,
- ContactGroupSSHImpl contactGroup)
- {
- parent.addSubgroup(contactGroup);
-
- this.fireServerStoredGroupEvent(
- contactGroup, ServerStoredGroupEvent.GROUP_CREATED_EVENT);
- }
-
-
- /**
- * Returns a reference to the contact with the specified ID in case we
- * have a subscription for it and null otherwise/
- *
- * @param contactID a String identifier of the contact which we're
- * seeking a reference of.
- * @return a reference to the Contact with the specified
- * <tt>contactID</tt> or null if we don't have a subscription for the
- * that identifier.
- */
- public Contact findContactByID(String contactID)
- {
- return contactListRoot.findContactByID(contactID);
- }
-
- /**
- * Sets the specified status message.
- * @param statusMessage a String containing the new status message.
- */
- public void setStatusMessage(String statusMessage)
- {
- this.statusMessage = statusMessage;
- }
-
- /**
- * Returns the status message that was last set through
- * setCurrentStatusMessage.
- *
- * @return the last status message that we have requested and the aim
- * server has confirmed.
- */
- public String getCurrentStatusMessage()
- {
- return statusMessage;
- }
-
- /**
- * Returns the protocol specific contact instance representing the local
- * user.
- *
- * @return the Contact (address, phone number, or uin) that the Provider
- * implementation is communicating on behalf of.
- */
- public Contact getLocalContact()
- {
- return null;
- }
-
- /**
- * Returns a PresenceStatus instance representing the state this provider
- * is currently in.
- *
- * @return the PresenceStatus last published by this provider.
- */
- public PresenceStatus getPresenceStatus()
- {
- return presenceStatus;
- }
-
- /**
- * Returns the root group of the server stored contact list.
- *
- * @return the root ContactGroup for the ContactList stored by this
- * service.
- */
- public ContactGroup getServerStoredContactListRoot()
- {
- return contactListRoot;
- }
-
- /**
- * Returns the set of PresenceStatus objects that a user of this service
- * may request the provider to enter.
- *
- * @return Iterator a PresenceStatus array containing "enterable" status
- * instances.
- */
- public Iterator<PresenceStatus> getSupportedStatusSet()
- {
- return SSHStatusEnum.supportedStatusSet();
- }
-
- /**
- * Removes the specified contact from its current parent and places it
- * under <tt>newParent</tt>.
- *
- * @param contactToMove the <tt>Contact</tt> to move
- * @param newParent the <tt>ContactGroup</tt> where <tt>Contact</tt>
- * would be placed.
- */
- public void moveContactToGroup(
- Contact contactToMove,
- ContactGroup newParent)
- {
- ContactSSHImpl sshContact
- = (ContactSSHImpl)contactToMove;
-
- ContactGroupSSHImpl parentSSHGroup
- = findContactParent(sshContact);
-
- parentSSHGroup.removeContact(sshContact);
-
- //if this is a volatile contact then we haven't really subscribed to
- //them so we'd need to do so here
- if(!sshContact.isPersistent())
- {
- //first tell everyone that the volatile contact was removed
- fireSubscriptionEvent(sshContact
- , parentSSHGroup
- , SubscriptionEvent.SUBSCRIPTION_REMOVED);
-
- try
- {
- //now subscribe
- this.subscribe(newParent, contactToMove.getAddress());
-
- //now tell everyone that we've added the contact
- fireSubscriptionEvent(sshContact
- , newParent
- , SubscriptionEvent.SUBSCRIPTION_CREATED);
- }
- catch (Exception ex)
- {
- logger.error("Failed to move contact "
- + sshContact.getAddress()
- , ex);
- }
- }
- else
- {
- ( (ContactGroupSSHImpl) newParent)
- .addContact(sshContact);
-
- fireSubscriptionMovedEvent(contactToMove
- , parentSSHGroup
- , newParent);
- }
- }
-
- /**
- * Requests the provider to enter into a status corresponding to the
- * specified paramters.
- *
- * @param status the PresenceStatus as returned by
- * getRequestableStatusSet
- * @param statusMessage the message that should be set as the reason to
- * enter that status
- * @throws IllegalArgumentException if the status requested is not a
- * valid PresenceStatus supported by this provider.
- * @throws IllegalStateException if the provider is not currently
- * registered.
- */
- public void publishPresenceStatus(
- PresenceStatus status,
- String statusMessage)
- throws IllegalArgumentException,
- IllegalStateException
- {
- PresenceStatus oldPresenceStatus = this.presenceStatus;
- this.presenceStatus = status;
- this.statusMessage = statusMessage;
-
- this.fireProviderStatusChangeEvent(oldPresenceStatus);
-
-
-// //since we are not a real protocol, we set the contact presence status
-// //ourselves and make them have the same status as ours.
-// changePresenceStatusForAllContacts( getServerStoredContactListRoot()
-// , getPresenceStatus());
-//
-// //now check whether we are in someone else's contact list and modify
-// //our status there
-// List contacts = findContactsPointingToUs();
-//
-// Iterator contactsIter = contacts.iterator();
-// while (contactsIter.hasNext())
-// {
-// ContactSSHImpl contact
-// = (ContactSSHImpl) contactsIter.next();
-//
-// PresenceStatus oldStatus = contact.getPresenceStatus();
-// contact.setPresenceStatus(status);
-// contact.getParentPresenceOperationSet()
-// .fireContactPresenceStatusChangeEvent(
-// contact
-// , contact.getParentContactGroup()
-// , oldStatus);
-//
-// }
- }
-
-
-
- /**
- * Get the PresenceStatus for a particular contact.
- *
- * @param contactIdentifier the identifier of the contact whose status
- * we're interested in.
- * @return PresenceStatus the <tt>PresenceStatus</tt> of the specified
- * <tt>contact</tt>
- * @throws IllegalArgumentException if <tt>contact</tt> is not a contact
- * known to the underlying protocol provider
- * @throws IllegalStateException if the underlying protocol provider is
- * not registered/signed on a public service.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * retrieving the status fails due to errors experienced during
- * network communication
- */
- public PresenceStatus queryContactStatus(String contactIdentifier)
- throws IllegalArgumentException,
- IllegalStateException,
- OperationFailedException
- {
- return findContactByID(contactIdentifier).getPresenceStatus();
- }
-
- /**
- * Sets the presence status of <tt>contact</tt> to <tt>newStatus</tt>.
- *
- * @param contact the <tt>ContactSSHImpl</tt> whose status we'd like
- * to set.
- * @param newStatus the new status we'd like to set to <tt>contact</tt>.
- */
- private void changePresenceStatusForContact(
- ContactSSH contact,
- PresenceStatus newStatus)
- {
- PresenceStatus oldStatus = contact.getPresenceStatus();
- contact.setPresenceStatus(newStatus);
-
- fireContactPresenceStatusChangeEvent(
- contact, findContactParent(contact), oldStatus);
- }
-
- /**
- * Sets the presence status of all <tt>contact</tt>s in our contact list
- * (except those that correspond to another provider registered with SC)
- * to <tt>newStatus</tt>.
- *
- * @param newStatus the new status we'd like to set to <tt>contact</tt>.
- * @param parent the group in which we'd have to update the status of all
- * direct and indirect child contacts.
- */
- private void changePresenceStatusForAllContacts(
- ContactGroup parent,
- PresenceStatus newStatus)
- {
- //first set the status for contacts in this group
- Iterator<Contact> childContacts = parent.contacts();
-
- while(childContacts.hasNext())
- {
- ContactSSHImpl contact
- = (ContactSSHImpl)childContacts.next();
-
- if(findProviderForSSHUserID(contact.getAddress()) != null)
- {
- //this is a contact corresponding to another SIP Communicator
- //provider so we won't change it's status here.
- continue;
- }
- PresenceStatus oldStatus = contact.getPresenceStatus();
- contact.setPresenceStatus(newStatus);
-
- fireContactPresenceStatusChangeEvent(
- contact, parent, oldStatus);
- }
-
- //now call this method recursively for all subgroups
- Iterator<ContactGroup> subgroups = parent.subgroups();
-
- while(subgroups.hasNext())
- {
- ContactGroup subgroup = subgroups.next();
- changePresenceStatusForAllContacts(subgroup, newStatus);
- }
- }
-
- /**
- * Returns the group that is parent of the specified sshGroup or null
- * if no parent was found.
- * @param sshGroup the group whose parent we're looking for.
- * @return the ContactGroupSSHImpl instance that sshGroup
- * belongs to or null if no parent was found.
- */
- public ContactGroupSSHImpl findGroupParent(
- ContactGroupSSHImpl sshGroup)
- {
- return contactListRoot.findGroupParent(sshGroup);
- }
-
- /**
- * Returns the group that is parent of the specified sshContact or
- * null if no parent was found.
- * @param sshContact the contact whose parent we're looking for.
- * @return the ContactGroupSSHImpl instance that sshContact
- * belongs to or null if no parent was found.
- */
- public ContactGroupSSHImpl findContactParent(
- ContactSSH sshContact)
- {
- return (ContactGroupSSHImpl)sshContact
- .getParentContactGroup();
- }
-
-
- /**
- * Removes the specified group from the server stored contact list.
- *
- * @param group the group to remove.
- *
- * @throws IllegalArgumentException if <tt>group</tt> was not found in this
- * protocol's contact list.
- */
- public void removeServerStoredContactGroup(ContactGroup group)
- throws IllegalArgumentException
- {
- ContactGroupSSHImpl sshGroup
- = (ContactGroupSSHImpl)group;
-
- ContactGroupSSHImpl parent = findGroupParent(sshGroup);
-
- if(parent == null)
- {
- throw new IllegalArgumentException(
- "group " + group
- + " does not seem to belong to this protocol's contact "
- + "list.");
- }
-
- parent.removeSubGroup(sshGroup);
-
- this.fireServerStoredGroupEvent(
- sshGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
- }
-
- /**
- * Renames the specified group from the server stored contact list.
- *
- * @param group the group to rename.
- * @param newName the new name of the group.
- */
- public void renameServerStoredContactGroup(
- ContactGroup group,
- String newName)
- {
- ((ContactGroupSSHImpl)group).setGroupName(newName);
-
- this.fireServerStoredGroupEvent(
- group, ServerStoredGroupEvent
- .GROUP_RENAMED_EVENT);
- }
-
-
- /**
- * Persistently adds a subscription for the presence status of the
- * contact corresponding to the specified contactIdentifier and indicates
- * that it should be added to the specified group of the server stored
- * contact list.
- *
- * @param parent the parent group of the server stored contact list
- * where the contact should be added. <p>
- * @param contactIdentifier the contact whose status updates we are
- * subscribing for.
- * @throws IllegalArgumentException if <tt>contact</tt> or
- * <tt>parent</tt> are not a contact known to the underlying protocol
- * provider.
- * @throws IllegalStateException if the underlying protocol provider is
- * not registered/signed on a public service.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * subscribing fails due to errors experienced during network
- * communication
- */
- public void subscribe(
- ContactGroup parent,
- String contactIdentifier)
- throws IllegalArgumentException,
- IllegalStateException,
- OperationFailedException
- {
- ContactSSH sshContact = new ContactSSHImpl(contactIdentifier,
- parentProvider);
-
-/* ProtocolProviderServiceSSHImpl.getUIService().getConfigurationWindow()
- .setVisible(true);
-*/
- sshContact.setParentGroup((ContactGroupSSHImpl)parent);
- sshContact.getSSHConfigurationForm().setVisible(true);
-
-
-
-/* Gets the domain name or IP address of the sshContact machine via the
- * UI Service Interface
- sshContact.setPersistentData(ProtocolProviderServiceSSHImpl
- .getUIService().getPopupDialog()
- .showInputPopupDialog("Enter Domain Name or IP Address of "
- + sshContact.getDisplayName()));
-
- // contact is added to list later after the user has provided
- // details in SSHConfigurationForm
-
- // addContactToList method is called
-*/
- }
-
- /**
- * Add a contact to the specified group
- *
- * @param parent the group
- * @param sshContact the contact
- */
- public void addContactToList(
- ContactGroup parent,
- ContactSSH sshContact)
- {
- // Adds the sshContact to the sshContact list
-
- ((ContactGroupSSHImpl)parent).addContact(sshContact);
-
- fireSubscriptionEvent(sshContact,
- parent,
- SubscriptionEvent.SUBSCRIPTION_CREATED);
-
- //notify presence listeners for the status change.
- fireContactPresenceStatusChangeEvent(sshContact
- , parent
- , SSHStatusEnum.NOT_AVAILABLE);
-
- sshContact.startTimerTask();
- }
-
- /**
- * Adds a subscription for the presence status of the contact
- * corresponding to the specified contactIdentifier.
- *
- * @param contactIdentifier the identifier of the contact whose status
- * updates we are subscribing for. <p>
- * @throws IllegalArgumentException if <tt>contact</tt> is not a contact
- * known to the underlying protocol provider
- * @throws IllegalStateException if the underlying protocol provider is
- * not registered/signed on a public service.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * subscribing fails due to errors experienced during network
- * communication
- */
- public void subscribe(String contactIdentifier) throws
- IllegalArgumentException,
- IllegalStateException,
- OperationFailedException
- {
- subscribe(contactListRoot, contactIdentifier);
-
- }
-
- /**
- * Removes a subscription for the presence status of the specified
- * contact.
- *
- * @param contact the contact whose status updates we are unsubscribing
- * from.
- * @throws IllegalArgumentException if <tt>contact</tt> is not a contact
- * known to the underlying protocol provider
- * @throws IllegalStateException if the underlying protocol provider is
- * not registered/signed on a public service.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * unsubscribing fails due to errors experienced during network
- * communication
- */
- public void unsubscribe(Contact contact) throws
- IllegalArgumentException,
- IllegalStateException,
- OperationFailedException
- {
- ContactGroupSSHImpl parentGroup
- = (ContactGroupSSHImpl)((ContactSSHImpl)contact)
- .getParentContactGroup();
-
- parentGroup.removeContact((ContactSSHImpl)contact);
-
- fireSubscriptionEvent(contact,
- ((ContactSSHImpl)contact).getParentContactGroup()
- , SubscriptionEvent.SUBSCRIPTION_REMOVED);
- }
-
- /**
- * Creates and returns a unresolved contact from the specified
- * <tt>address</tt> and <tt>persistentData</tt>. The method will not try
- * to establish a network connection and resolve the newly created Contact
- * against the server. The protocol provider may will later try and resolve
- * the contact. When this happens the corresponding event would notify
- * interested subscription listeners.
- *
- * @param address an identifier of the contact that we'll be creating.
- * @param persistentData a String returned Contact's getPersistentData()
- * method during a previous run and that has been persistently stored
- * locally.
- * @return the unresolved <tt>Contact</tt> created from the specified
- * <tt>address</tt> and <tt>persistentData</tt>
- */
- public Contact createUnresolvedContact(
- String address,
- String persistentData)
- {
- return createUnresolvedContact(address
- , persistentData
- , getServerStoredContactListRoot());
- }
-
- /**
- * Creates and returns a unresolved contact from the specified
- * <tt>address</tt> and <tt>persistentData</tt>. The method will not try
- * to establish a network connection and resolve the newly created Contact
- * against the server. The protocol provider may will later try and resolve
- * the contact. When this happens the corresponding event would notify
- * interested subscription listeners.
- *
- * @param address an identifier of the contact that we'll be creating.
- * @param persistentData a String returned Contact's getPersistentData()
- * method during a previous run and that has been persistently stored
- * locally.
- * @param parent the group where the unresolved contact is
- * supposed to belong to.
- *
- * @return the unresolved <tt>Contact</tt> created from the specified
- * <tt>address</tt> and <tt>persistentData</tt>
- */
- public Contact createUnresolvedContact(
- String address,
- String persistentData,
- ContactGroup parent)
- {
- ContactSSH contact = new ContactSSHImpl(
- address,
- parentProvider);
-
- contact.setPersistentData(persistentData);
- contact.startTimerTask();
-
- // SSH Contacts are resolved by default
- contact.setResolved(true);
-
- ( (ContactGroupSSHImpl) parent).addContact(contact);
-
- fireSubscriptionEvent(contact,
- parent,
- SubscriptionEvent.SUBSCRIPTION_CREATED);
-
- //since we don't have any server, we'll simply resolve the contact
- //ourselves as if we've just received an event from the server telling
- //us that it has been resolved.
- fireSubscriptionEvent(
- contact, parent, SubscriptionEvent.SUBSCRIPTION_RESOLVED);
-
- return contact;
- }
-
- /**
- * Looks for a ssh protocol provider registered for a user id matching
- * <tt>sshUserID</tt>.
- *
- * @param sshUserID the ID of the SSH user whose corresponding
- * protocol provider we'd like to find.
- * @return ProtocolProviderServiceSSHImpl a ssh protocol
- * provider registered for a user with id <tt>sshUserID</tt> or null
- * if there is no such protocol provider.
- */
- public ProtocolProviderServiceSSHImpl
- findProviderForSSHUserID(String sshUserID)
- {
- BundleContext bc = SSHActivator.getBundleContext();
-
- String osgiQuery = "(&"
- + "(" + ProtocolProviderFactory.PROTOCOL
- + "=" + ProtocolNames.SSH + ")"
- + "(" + ProtocolProviderFactory.USER_ID
- + "=" + sshUserID + ")"
- + ")";
-
- ServiceReference[] refs = null;
- try
- {
- refs = bc.getServiceReferences(
- ProtocolProviderService.class.getName()
- ,osgiQuery);
- }
- catch (InvalidSyntaxException ex)
- {
- logger.error("Failed to execute the following osgi query: "
- + osgiQuery
- , ex);
- }
-
- if(refs != null && refs.length > 0)
- {
- return (ProtocolProviderServiceSSHImpl)bc.getService(refs[0]);
- }
-
- return null;
- }
-
- /**
- * Looks for ssh protocol providers that have added us to their
- * contact list and returns list of all contacts representing us in these
- * providers.
- *
- * @return a list of all contacts in other providers' contact lists that
- * point to us.
- */
- public List<Contact> findContactsPointingToUs()
- {
- List<Contact> contacts = new LinkedList<Contact>();
- BundleContext bc = SSHActivator.getBundleContext();
-
- String osgiQuery =
- "(" + ProtocolProviderFactory.PROTOCOL
- + "=SSH)";
-
- ServiceReference[] refs = null;
- try
- {
- refs = bc.getServiceReferences(
- ProtocolProviderService.class.getName()
- ,osgiQuery);
- }
- catch (InvalidSyntaxException ex)
- {
- logger.error("Failed to execute the following osgi query: "
- + osgiQuery
- , ex);
- }
-
- for (int i =0; refs != null && i < refs.length; i++)
- {
- ProtocolProviderServiceSSHImpl gibProvider
- = (ProtocolProviderServiceSSHImpl)bc.getService(refs[i]);
-
- OperationSetPersistentPresenceSSHImpl opSetPersPresence
- = (OperationSetPersistentPresenceSSHImpl)gibProvider
- .getOperationSet(OperationSetPersistentPresence.class);
-
- Contact contact = opSetPersPresence.findContactByID(
- parentProvider.getAccountID().getUserID());
-
- if (contact != null)
- contacts.add(contact);
- }
-
- return contacts;
- }
-
-
- /**
- * Creates and returns a unresolved contact group from the specified
- * <tt>address</tt> and <tt>persistentData</tt>. The method will not try
- * to establish a network connection and resolve the newly created
- * <tt>ContactGroup</tt> against the server or the contact itself. The
- * protocol provider will later resolve the contact group. When this happens
- * the corresponding event would notify interested subscription listeners.
- *
- * @param groupUID an identifier, returned by ContactGroup's getGroupUID,
- * that the protocol provider may use in order to create the group.
- * @param persistentData a String returned ContactGroups's
- * getPersistentData() method during a previous run and that has been
- * persistently stored locally.
- * @param parentGroup the group under which the new group is to be created
- * or null if this is group directly underneath the root.
- * @return the unresolved <tt>ContactGroup</tt> created from the specified
- * <tt>uid</tt> and <tt>persistentData</tt>
- */
- public ContactGroup createUnresolvedContactGroup(
- String groupUID,
- String persistentData,
- ContactGroup parentGroup)
- {
- ContactGroupSSHImpl newGroup
- = new ContactGroupSSHImpl(
- ContactGroupSSHImpl.createNameFromUID(groupUID)
- , parentProvider);
- newGroup.setResolved(false);
-
- //if parent is null then we're adding under root.
- if(parentGroup == null)
- parentGroup = getServerStoredContactListRoot();
-
- ((ContactGroupSSHImpl)parentGroup).addSubgroup(newGroup);
-
- this.fireServerStoredGroupEvent(
- newGroup, ServerStoredGroupEvent.GROUP_CREATED_EVENT);
-
- return newGroup;
- }
-
- private class UnregistrationListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenver
- * a change in the registration state of the corresponding provider had
- * occurred. The method is particularly interested in events stating
- * that the ssh provider has unregistered so that it would fire
- * status change events for all contacts in our buddy list.
- *
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (! evt.getNewState().equals(RegistrationState.UNREGISTERED)
- && !evt.getNewState().equals(RegistrationState
- .AUTHENTICATION_FAILED)
- && !evt.getNewState().equals(RegistrationState.CONNECTION_FAILED))
- {
- return;
- }
-
- //send event notifications saying that all our buddies are
- //offline. The icq protocol does not implement top level buddies
- //nor subgroups for top level groups so a simple nested loop
- //would be enough.
- Iterator<ContactGroup> groupsIter
- = getServerStoredContactListRoot().subgroups();
- while (groupsIter.hasNext())
- {
- ContactGroup group = groupsIter.next();
- Iterator<Contact> contactsIter = group.contacts();
-
- while (contactsIter.hasNext())
- {
- ContactSSHImpl contact
- = (ContactSSHImpl) contactsIter.next();
-
- PresenceStatus oldContactStatus
- = contact.getPresenceStatus();
-
- if (!oldContactStatus.isOnline())
- continue;
-
- contact.setPresenceStatus(SSHStatusEnum.OFFLINE);
-
- fireContactPresenceStatusChangeEvent(
- contact
- , contact.getParentContactGroup()
- , oldContactStatus);
- }
- }
- }
- }
-
- /**
- * Returns the volatile group or null if this group has not yet been
- * created.
- *
- * @return a volatile group existing in our contact list or <tt>null</tt>
- * if such a group has not yet been created.
- */
- private ContactGroupSSHImpl getNonPersistentGroup()
- {
- for (int i = 0
- ; i < getServerStoredContactListRoot().countSubgroups()
- ; i++)
- {
- ContactGroupSSHImpl gr =
- (ContactGroupSSHImpl)getServerStoredContactListRoot()
- .getGroup(i);
-
- if(!gr.isPersistent())
- return gr;
- }
-
- return null;
- }
-
-
- /**
- * Creates a non persistent contact for the specified address. This would
- * also create (if necessary) a group for volatile contacts that would not
- * be added to the server stored contact list. This method would have no
- * effect on the server stored contact list.
- *
- * @param contactAddress the address of the volatile contact we'd like to
- * create.
- * @return the newly created volatile contact.
- */
- public ContactSSHImpl createVolatileContact(String contactAddress)
- {
- //First create the new volatile contact;
- ContactSSHImpl newVolatileContact = new ContactSSHImpl(
- contactAddress,
- this.parentProvider);
-
- newVolatileContact.setPersistent(false);
-
-
- //Check whether a volatile group already exists and if not create
- //one
- ContactGroupSSHImpl theVolatileGroup = getNonPersistentGroup();
-
-
- //if the parent volatile group is null then we create it
- if (theVolatileGroup == null)
- {
- theVolatileGroup = new ContactGroupSSHImpl(
- SSHActivator.getResources().getI18NString(
- "service.gui.NOT_IN_CONTACT_LIST_GROUP_NAME")
- , parentProvider);
- theVolatileGroup.setResolved(false);
- theVolatileGroup.setPersistent(false);
- theVolatileGroup.addContact(newVolatileContact);
-
- this.contactListRoot.addSubgroup(theVolatileGroup);
-
- fireServerStoredGroupEvent(theVolatileGroup
- , ServerStoredGroupEvent.GROUP_CREATED_EVENT);
- }
-
- //now add the volatile contact instide it
- theVolatileGroup.addContact(newVolatileContact);
- fireSubscriptionEvent(newVolatileContact
- , theVolatileGroup
- , SubscriptionEvent.SUBSCRIPTION_CREATED);
-
- return newVolatileContact;
- }
-
- /**
- * DUMMY METHOD
- * Handler for incoming authorization requests.
- *
- * @param handler an instance of an AuthorizationHandler for
- * authorization requests coming from other users requesting
- * permission add us to their contact list.
- */
- public void setAuthorizationHandler(AuthorizationHandler handler)
- {
- }
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolIconSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolIconSSHImpl.java
deleted file mode 100644
index 592b2b1..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolIconSSHImpl.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Represents the SSH protocol icon. Implements the <tt>ProtocolIcon</tt>
- * interface in order to provide a SSH logo image in two different sizes.
- *
- * @author Shobhit Jindal
- */
-public class ProtocolIconSSHImpl
- implements ProtocolIcon
-{
- private static Logger logger
- = Logger.getLogger(ProtocolIconSSHImpl.class);
-
- /**
- * A hash table containing the protocol icon in different sizes.
- */
- private static Hashtable<String, byte[]> iconsTable
- = new Hashtable<String, byte[]>();
- static {
- iconsTable.put(ProtocolIcon.ICON_SIZE_16x16,
- getImageInBytes("service.protocol.ssh.SSH_16x16"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_32x32,
- getImageInBytes("service.protocol.ssh.SSH_32x32"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_48x48,
- getImageInBytes("service.protocol.ssh.SSH_48x48"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_64x64,
- getImageInBytes("service.protocol.ssh.SSH_64x64"));
- }
-
- /**
- * A hash table containing the protocol icon in different sizes.
- */
- private static Hashtable<String, String> iconPathsTable
- = new Hashtable<String, String>();
- static {
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_16x16,
- SSHActivator.getResources().getImagePath(
- "service.protocol.ssh.SSH_16x16"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_32x32,
- SSHActivator.getResources().getImagePath(
- "service.protocol.ssh.SSH_32x32"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_48x48,
- SSHActivator.getResources().getImagePath(
- "service.protocol.ssh.SSH_48x48"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_64x64,
- SSHActivator.getResources().getImagePath(
- "service.protocol.ssh.SSH_64x64"));
- }
-
- /**
- * Implements the <tt>ProtocolIcon.getSupportedSizes()</tt> method. Returns
- * an iterator to a set containing the supported icon sizes.
- * @return an iterator to a set containing the supported icon sizes
- */
- public Iterator<String> getSupportedSizes()
- {
- return iconsTable.keySet().iterator();
- }
-
- /**
- * Returns TRUE if a icon with the given size is supported, FALSE-otherwise.
- *
- * @return TRUE if a icon with the given size is supported, FALSE otherwise
- */
- public boolean isSizeSupported(String iconSize)
- {
- return iconsTable.containsKey(iconSize);
- }
-
- /**
- * Returns the icon image in the given size.
- * @param iconSize the icon size; one of ICON_SIZE_XXX constants
- * @return the icon
- */
- public byte[] getIcon(String iconSize)
- {
- return iconsTable.get(iconSize);
- }
-
- /**
- * Returns a path to the icon with the given size.
- * @param iconSize the size of the icon we're looking for
- * @return the path to the icon with the given size
- */
- public String getIconPath(String iconSize)
- {
- return iconPathsTable.get(iconSize);
- }
-
- /**
- * Returns the icon image used to represent the protocol connecting state.
- * @return the icon image used to represent the protocol connecting state
- */
- public byte[] getConnectingIcon()
- {
- return getImageInBytes("protocolIconSsh");
- }
-
- /**
- * Returns the byte representation of the image corresponding to the given
- * identifier.
- *
- * @param imageID the identifier of the image
- * @return the byte representation of the image corresponding to the given
- * identifier.
- */
- public static byte[] getImageInBytes(String imageID)
- {
- InputStream in = SSHActivator.getResources().
- getImageInputStream(imageID);
-
- if (in == null)
- return null;
- byte[] image = null;
- try
- {
- image = new byte[in.available()];
-
- in.read(image);
- }
- catch (IOException e)
- {
- logger.error("Failed to load image:" + imageID, e);
- }
-
- return image;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSH.java b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSH.java
deleted file mode 100644
index 8c38f60..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSH.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import net.java.sip.communicator.service.protocol.*;
-
-import org.osgi.framework.*;
-
-/**
- *
- * @author Shobhit Jindal
- */
-public abstract class ProtocolProviderFactorySSH
- extends ProtocolProviderFactory
-{
- /**
- * The name of a property representing the IDENTITY_FILE of the protocol for
- * a ProtocolProviderFactory.
- */
- public static final String IDENTITY_FILE = "IDENTITY_FILE";
-
- /**
- * The name of a property representing the KNOWN_HOSTS_FILE of the protocol
- * for a ProtocolProviderFactory.
- */
- public static final String KNOWN_HOSTS_FILE = "KNOWN_HOSTS_FILE";
-
- protected ProtocolProviderFactorySSH(BundleContext bundleContext,
- String protocolName)
- {
- super(bundleContext, protocolName);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSHImpl.java
deleted file mode 100644
index 68e33bc..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSHImpl.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-import org.osgi.framework.*;
-
-/**
- * The SSH protocol provider factory creates instances of the SSH
- * protocol provider service. One Service instance corresponds to one account.
- *
- * @author Shobhit Jindal
- */
-public class ProtocolProviderFactorySSHImpl
- extends ProtocolProviderFactorySSH
-{
-
- /**
- * Creates an instance of the ProtocolProviderFactorySSHImpl.
- */
- public ProtocolProviderFactorySSHImpl()
- {
- super(SSHActivator.getBundleContext(), ProtocolNames.SSH);
- }
-
- /**
- * Initializaed and creates an account corresponding to the specified
- * accountProperties and registers the resulting ProtocolProvider in the
- * <tt>context</tt> BundleContext parameter.
- *
- * @param userIDStr tha/a user identifier uniquely representing the newly
- * created account within the protocol namespace.
- * @param accountProperties a set of protocol (or implementation)
- * specific properties defining the new account.
- * @return the AccountID of the newly created account.
- */
- @Override
- public AccountID installAccount(
- String userIDStr,
- Map<String, String> accountProperties)
- {
- BundleContext context = SSHActivator.getBundleContext();
- if (context == null)
- throw new NullPointerException("The specified BundleContext was " +
- "null");
-
- if (userIDStr == null)
- throw new NullPointerException("The specified AccountID was null");
-
- if (accountProperties == null)
- throw new NullPointerException("The specified property map was" +
- " null");
-
- accountProperties.put(USER_ID, userIDStr);
-
- AccountID accountID = new SSHAccountID(userIDStr, accountProperties);
-
- //make sure we haven't seen this account id before.
- if (registeredAccounts.containsKey(accountID))
- throw new IllegalStateException(
- "An account for id " + userIDStr + " was already" +
- " installed!");
-
- //first store the account and only then load it as the load generates
- //an osgi event, the osgi event triggers (through the UI) a call to the
- //ProtocolProviderService.register() method and it needs to acces
- //the configuration service and check for a stored password.
- this.storeAccount(accountID, false);
-
- accountID = loadAccount(accountProperties);
-
-/* ServiceReference ppServiceRef = context
- .getServiceReference(ProtocolProviderService.class.getName());
-
- ProtocolProviderService ppService = (ProtocolProviderService)
- context.getService(ppServiceRef);
-
- OperationSetPersistentPresence operationSetPersistentPresence =
- (OperationSetPersistentPresence) ppService.getOperationSet(
- OperationSetPersistentPresence.class);
-
- try
- {
- // The below should never fail for SSH accounts
- operationSetPersistentPresence.subscribe(userIDStr);
-
- }
- catch(OperationFailedException ex)
- {
- ex.printStackTrace();
- }
-*/
- return accountID;
- }
-
- @Override
- protected AccountID createAccountID(String userID, Map<String, String> accountProperties)
- {
- return new SSHAccountID(userID, accountProperties);
- }
-
- @Override
- protected ProtocolProviderService createService(String userID,
- AccountID accountID)
- {
- ProtocolProviderServiceSSHImpl service =
- new ProtocolProviderServiceSSHImpl();
-
- service.initialize(userID, accountID);
- return service;
- }
-
-// /**
-// * Saves the password for the specified account after scrambling it a bit
-// * so that it is not visible from first sight (Method remains highly
-// * insecure).
-// *
-// * @param accountID the AccountID for the account whose password we're
-// * storing.
-// * @param passwd the password itself.
-// *
-// * @throws java.lang.IllegalArgumentException if no account corresponding
-// * to <tt>accountID</tt> has been previously stored.
-// */
-// public void storePassword(AccountID accountID, String passwd)
-// throws IllegalArgumentException
-// {
-// super.storePassword(SSHActivator.getBundleContext(),
-// accountID,
-// String.valueOf(Base64.encode(passwd.getBytes())));
-// }
-//
-// /**
-// * Returns the password last saved for the specified account.
-// *
-// * @param accountID the AccountID for the account whose password we're
-// * looking for..
-// *
-// * @return a String containing the password for the specified accountID.
-// *
-// * @throws java.lang.IllegalArgumentException if no account corresponding
-// * to <tt>accountID</tt> has been previously stored.
-// */
-// public String loadPassword(AccountID accountID)
-// throws IllegalArgumentException
-// {
-// String password = super.loadPassword(SSHActivator.getBundleContext()
-// , accountID );
-// return(String.valueOf(Base64.decode(password)));
-// }
-
- @Override
- public void modifyAccount( ProtocolProviderService protocolProvider,
- Map<String, String> accountProperties)
- throws NullPointerException
- {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java
deleted file mode 100644
index a4b16e6..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java
+++ /dev/null
@@ -1,662 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.io.*;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.Logger;
-
-import org.osgi.framework.*;
-
-import com.jcraft.jsch.*;
-
-/**
- * A SSH implementation of the ProtocolProviderService.
- *
- * @author Shobhit Jindal
- */
-public class ProtocolProviderServiceSSHImpl
- extends AbstractProtocolProviderService
-{
- 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
- * of the command
- */
- //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.
- */
- public ProtocolProviderServiceSSHImpl()
- {
- if (logger.isTraceEnabled())
- logger.trace("Creating a ssh provider.");
-
- try
- {
- // converting to milliseconds
- connectionTimeout = Integer.parseInt(Resources.getString(
- "connectionTimeout")) * 1000;
- }
- catch(NumberFormatException ex)
- {
- 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
- * properties in this Map be mapped to property names as specified by
- * <tt>AccountProperties</tt>.
- *
- * @param userID the user id of the ssh account we're currently
- * initializing
- * @param accountID the identifier of the account that this protocol
- * provider represents.
- *
- * @see net.java.sip.communicator.service.protocol.AccountID
- */
- protected void initialize(
- String userID,
- AccountID accountID)
- {
- synchronized(initializationLock)
- {
- this.accountID = accountID;
-
- //initialize the presence operationset
- OperationSetPersistentPresenceSSHImpl persistentPresence =
- new OperationSetPersistentPresenceSSHImpl(this);
-
- addSupportedOperationSet(
- OperationSetPersistentPresence.class,
- persistentPresence);
- //register it once again for those that simply need presence and
- //won't be smart enough to check for a persistent presence
- //alternative
- addSupportedOperationSet(
- OperationSetPresence.class,
- persistentPresence);
-
- //initialize the IM operation set
- 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.
- *
- * @param sshContact ID of SSH Contact
- *
- * @return <tt>true</tt> if the session is connected
- * <tt>false</tt> otherwise
- */
- public boolean isSessionValid(ContactSSH sshContact)
- {
- Session sshSession = sshContact.getSSHSession();
- 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
- *
- * @param sshContact ID of SSH Contact
- *
- * @return <tt>true</tt> if the contact is connected
- * <tt>false</tt> if the contact is not connected
- */
- 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
- *
- * @param sshContact the contact of the remote machine
- * @param firstMessage the first message
- */
- public void connectShell(
- final ContactSSH sshContact,
- final Message firstMessage)
- {
- sshContact.setConnectionInProgress(true);
-
- final Thread newConnection = new Thread((new Runnable()
- {
- public void run()
- {
- 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);
- }
- // rigorous Exception Checking in future
- catch (Exception ex)
- {
- persistentPresence.changeContactPresenceStatus(
- sshContact,
- SSHStatusEnum.NOT_AVAILABLE);
-
- ex.printStackTrace();
- }
- finally
- {
- sshContact.setConnectionInProgress(false);
- }
- }
- }));
-
- 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
- {
- 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)
- {
- sshContact.setSSHSession(null);
- throw new IOException("Unable to create shell channel to remote" +
- " 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,
- IOException
- {
- sshContact.closeShellIO();
- 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
- * An appropriate message is shown to the end user in case the login fails
- *
- * @param sshContact ID of SSH Contact
- *
- * @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
- * @throws OperationFailedException if not of above reasons :-)
- */
- public void createSSHSessionAndLogin(ContactSSH sshContact) throws
- JSchException,
- OperationFailedException,
- InterruptedException
- {
- 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");
-
- if(!knownHosts.equals("Optional"))
- jsch.setKnownHosts(knownHosts);
-
- 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);
-
- // creating a new session for the contact
- Session session = jsch.getSession(
- 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)
- {
- Thread.sleep(1000);
- count += 1000;
- if (logger.isTraceEnabled())
- logger.trace("SSH:" + sshContact.getHostName()
- + ": Sleep zzz .. " );
- }
-
- // if timeout have exceeded
- if(count>30000)
- {
- sshContact.setSSHSession(null);
- JOptionPane.showMessageDialog(
- 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
- *
- * @param sshContact ID of SSH Contact
- */
- void closeSSHSession(ContactSSH sshContact)
- {
- 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
- {
-/* //sending the command
- sshContact.sendLine(testCommand);
-
- String reply = "", line = "";
-
- // message is extracted until the test Command ie echoed back
- while(line.indexOf(testCommand) == -1)
- {
- reply += line + "\n";
- line = sshContact.getLine();
- }
-
- uiService.getPopupDialog().showMessagePopupDialog
- (reply,"Message from " + sshContact.getDisplayName(),
- uiService.getPopupDialog().INFORMATION_MESSAGE);
-
- if(line.startsWith(testCommand))
- while(!sshContact.getLine().contains(testCommand));
-
- //one line output of testCommand
- sshContact.getLine();
-*/
- if (logger.isDebugEnabled())
- logger.debug("SSH: Welcome message shown");
- }
-
- /**
- * Returns a reference to UIServce for accessing UI related services
- *
- * @return uiService a reference to UIService
- */
- public static UIService getUIService()
- {
- return uiService;
- }
-
- /**
- * Returns the AccountID that uniquely identifies the account represented
- * by this instance of the ProtocolProviderService.
- *
- * @return the id of the account represented by this provider.
- */
- public AccountID getAccountID()
- {
- 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
- * example).
- *
- * @return a String containing the short name of the protocol this
- * service is implementing (most often that would be a name in
- * ProtocolNames).
- */
- public String getProtocolName()
- {
- return SSH_PROTOCOL_NAME;
- }
-
- /**
- * Returns the state of the registration of this protocol provider with
- * the corresponding registration service.
- *
- * @return ProviderRegistrationState
- */
- public RegistrationState getRegistrationState()
- {
- return currentRegistrationState;
- }
-
- /**
- * Starts the registration process.
- *
- * @param authority the security authority that will be used for
- * resolving any security challenges that may be returned during the
- * registration or at any moment while wer're registered.
- * @throws OperationFailedException with the corresponding code it the
- * registration fails for some reason (e.g. a networking error or an
- * implementation problem).
- */
- public void register(SecurityAuthority authority)
- throws OperationFailedException
- {
- 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
- * shutdown/garbage collection.
- */
- public void shutdown()
- {
- if(!isInitialized)
- {
- return;
- }
- if (logger.isTraceEnabled())
- logger.trace("Killing the SSH Protocol Provider.");
-
- if(isRegistered())
- {
- try
- {
- //do the unregistration
- unregister();
- }
- catch (OperationFailedException ex)
- {
- //we're shutting down so we need to silence the exception here
- logger.error(
- "Failed to properly unregister before shutting down. "
- + getAccountID()
- , ex);
- }
- }
-
- isInitialized = false;
- }
-
- /**
- * Ends the registration of this protocol provider with the current
- * registration service.
- *
- * @throws OperationFailedException with the corresponding code it the
- * registration fails for some reason (e.g. a networking error or an
- * implementation problem).
- */
- public void unregister()
- throws OperationFailedException
- {
- RegistrationState oldState = currentRegistrationState;
- currentRegistrationState = RegistrationState.UNREGISTERED;
-
- fireRegistrationStateChanged(
- oldState
- , currentRegistrationState
- , RegistrationStateChangeEvent.REASON_USER_REQUEST
- , null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see net.java.sip.communicator.service.protocol.ProtocolProviderService#
- * isSignallingTransportSecure()
- */
- public boolean isSignalingTransportSecure()
- {
- return false;
- }
-
- /**
- * Returns the "transport" protocol of this instance used to carry the
- * control channel for the current protocol service.
- *
- * @return The "transport" protocol of this instance: TCP.
- */
- public TransportProtocol getTransportProtocol()
- {
- return TransportProtocol.TCP;
- }
-
- /**
- * Returns the ssh protocol icon.
- * @return the ssh protocol icon
- */
- public ProtocolIcon getProtocolIcon()
- {
- return sshIcon;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/Resources.java b/src/net/java/sip/communicator/impl/protocol/ssh/Resources.java
deleted file mode 100644
index 48b9b49..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/Resources.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import net.java.sip.communicator.service.resources.*;
-
-/**
- * @author Shobhit Jindal
- */
-public class Resources
-{
- /**
- * The SSH logo imageID.
- */
- public static ImageID SSH_LOGO = new ImageID("protocolIconSsh");
-
- /**
- * Returns an string corresponding to the given key.
- *
- * @param key The key of the string.
- *
- * @return a string corresponding to the given key.
- */
- public static String getString(String key)
- {
- return SSHActivator.getResources().getI18NString(key);
- }
-
- /**
- * Loads an image from a given image identifier.
- * @param imageID The identifier of the image.
- * @return The image for the given identifier.
- */
- public static byte[] getImage(ImageID imageID)
- {
- return SSHActivator.getResources().getImageInBytes(imageID.getId());
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHAccountID.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHAccountID.java
deleted file mode 100644
index 8f9dda7..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHAccountID.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The SSH implementation of a sip-communicator account id.
- * @author Shobhit Jindal
- */
-public class SSHAccountID
- extends AccountID
-{
- /**
- * Creates an account id from the specified id and account properties.
- *
- * @param userID the user identifier correspnding to thi account
- * @param accountProperties any other properties necessary for the account.
- */
- SSHAccountID(String userID, Map<String, String> accountProperties)
- {
- super(userID
- , accountProperties
- , "SSH"
- , "sip-communicator.org");
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java
deleted file mode 100644
index 7108020..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.resources.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.resources.*;
-import org.osgi.framework.*;
-
-/**
- * Loads the SSH provider factory and registers its services in the OSGI
- * bundle context.
- *
- * @author Shobhit Jindal
- */
-public class SSHActivator
- implements BundleActivator
-{
- 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
- * possible to register accounts with it in SIP Communicator.
- *
- * @param context The execution context of the bundle being started.
- * @throws Exception If this method throws an exception, this bundle is
- * marked as stopped and the Framework will remove this bundle's
- * listeners, unregister all services registered by this bundle, and
- * release all services used by this bundle.
- */
- public void start(BundleContext context)
- throws Exception
- {
- bundleContext = context;
-
- Hashtable<String, String> hashtable = new Hashtable<String, String>();
- hashtable.put(ProtocolProviderFactory.PROTOCOL, "SSH");
-
- sshProviderFactory = new ProtocolProviderFactorySSHImpl();
-
- //reg the ssh provider factory.
- sshPpFactoryServReg = context.registerService(
- 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
- * that we were started with.
- */
- public static BundleContext getBundleContext()
- {
- return bundleContext;
- }
-
- /**
- * Retrurns a reference to the protocol provider factory that we have
- * registered.
- * @return a reference to the <tt>ProtocolProviderFactoryJabberImpl</tt>
- * instance that we have registered from this package.
- */
- public static ProtocolProviderFactorySSHImpl
- getProtocolProviderFactory()
- {
- return sshProviderFactory;
- }
-
-
- /**
- * Called when this bundle is stopped so the Framework can perform the
- * bundle-specific activities necessary to stop the bundle.
- *
- * @param context The execution context of the bundle being stopped.
- * @throws Exception If this method throws an exception, the bundle is
- * still marked as stopped, and the Framework will remove the bundle's
- * listeners, unregister all services registered by the bundle, and
- * release all services used by the bundle.
- */
- public void stop(BundleContext context)
- throws Exception
- {
- 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)
- resourcesService =
- ResourceManagementServiceUtils.getService(bundleContext);
- return resourcesService;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java
deleted file mode 100644
index 47bb484..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.text.*;
-
-import javax.swing.*;
-import javax.swing.text.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-/**
- * @author Shobhit Jindal
- */
-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");
- private JLabel machineID = new JLabel("Hostname / IP: ");
- private JTextField machineIDField = new JTextField();
- private JLabel userName = new JLabel("User Name: ");
- private JTextField userNameField = new JTextField();
- 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) {
- super(true);
-
- 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.
- */
- public void initForm() {
- updateTimer.setValue(30);
- MaskFormatter maskFormatter = new MaskFormatter();
- try {
- maskFormatter.setMask("#####");
- } catch (ParseException ex) {
- ex.printStackTrace();
- }
- 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,
- BoxLayout.Y_AXIS));
- 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);
- detailNamesPanel.add(emptyPanel2);
- detailNamesPanel.add(port);
- detailNamesPanel.add(emptyPanel3);
- detailNamesPanel.add(statusUpdate);
- detailNamesPanel.add(emptyPanel4);
- detailNamesPanel.add(terminalType);
-
- detailFieldsPanel.add(userNameField);
- detailFieldsPanel.add(emptyPanel5);
- detailFieldsPanel.add(passwordField);
- detailFieldsPanel.add(emptyPanel6);
- detailFieldsPanel.add(portField);
- detailFieldsPanel.add(emptyPanel7);
- 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);
- mainPanel.add(detailsPanel);
- mainPanel.add(emptyPanel10);
- mainPanel.add(doneButton);
- mainPanel.add(emptyPanel11);
-
- addDetailsCheckBox.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- addDetailsCheckBox.setEnabled(false);
- userNameField.setEnabled(true);
- passwordField.setEditable(true);
- 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
- ((OperationSetPersistentPresenceSSHImpl)sshContact
- .getParentPresenceOperationSet())
- .addContactToList(
- sshContact.getParentContactGroup(),
- sshContact);
-
- setVisible(false);
- }
- });
- }
-
- /**
- * Return the ssh icon
- *
- * @return the ssh icon
- */
- public byte[] getIcon() {
- return Resources.getImage(Resources.SSH_LOGO);
- }
-
-//
-// public void setContactGroup(ContactGroup contactGroup)
-// {
-// this.contactGroup = contactGroup;
-// }
-//
-// public ContactGroup getContactGroup()
-// {
-// return this.contactGroup;
-// }
-
- /**
- * Sets the UserName of the dialog
- *
- * @param userName to be associated
- */
- public void setUserNameField(String userName) {
- this.userNameField.setText(userName);
- }
-
- /**
- * Sets the Password of the dialog
- *
- * @param password to be associated
- */
- public void setPasswordField(String password) {
- this.passwordField.setText(password);
- }
-
- /**
- * Return the hostname
- *
- * @return the hostname
- */
- public String getHostName() {
- return this.machineIDField.getText();
- }
-
- /**
- * Return the username
- *
- * @return the username
- */
- public String getUserName() {
- return this.userNameField.getText();
- }
-
- /**
- * Return the password
- *
- * @return the password in a clear form
- */
- public String getPassword() {
- return this.passwordField.getText();
- }
-
- /**
- * Return the terminal type
- *
- * @return the terminal type
- */
- public String getTerminalType() {
- return this.terminalTypeField.getText();
- }
-
- /**
- * Return the port
- *
- * @return the port value
- */
- public int getPort() {
- return Integer.parseInt(this.portField.getText().trim());
- }
-
- /**
- * Return the update interval
- *
- * @return the update interval
- */
- public int getUpdateInterval() {
- return Integer.parseInt(String.valueOf(this.updateTimer.getValue()));
- }
-
- /**
- * Sets the HostName of the dialog
- *
- * @param hostName to be associated
- */
- public void setHostNameField(String hostName) {
- this.machineIDField.setText(hostName);
- }
-
- /**
- * Sets the Terminal Type of the dialog
- *
- * @param termType to be associated
- */
- public void setTerminalType(String termType) {
- this.terminalTypeField.setText(termType);
- }
-
- /**
- * Sets the Update Interval of the dialog
- *
- * @param interval to be associated
- */
- public void setUpdateInterval(int interval) {
- this.updateTimer.setValue(interval);
- }
-
- /**
- * Sets the Port of the dialog
- *
- * @param port to be associated
- */
- public void setPort(String port) {
- this.portField.setText(port);
- }
-
- @Override
- protected void close(boolean isEscaped)
- {
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHFileTransferDaemon.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHFileTransferDaemon.java
deleted file mode 100644
index 3b522ed..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHFileTransferDaemon.java
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.io.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.Logger;
-
-import com.jcraft.jsch.*;
-
-/**
- * @author Shobhit Jindal
- */
-public class SSHFileTransferDaemon
- extends Thread
-{
- private static final Logger logger =
- Logger.getLogger(SSHFileTransferDaemon .class);
-
- /**
- * The contact of the remote machine
- */
- private ContactSSH sshContact;
-
- /**
- * The currently valid ssh protocol provider
- */
- private ProtocolProviderServiceSSHImpl ppService;
-
- /**
- * JSch Channel to be used for file transfer
- */
- private Channel fileTransferChannel;
-
- /**
- * The identifier for the Input Stream associated with SCP Channel
- */
- private InputStream scpInputStream = null;
-
- /**
- * The identifier for the Output Stream associated with SCP Channel
- */
- private OutputStream scpOutputStream = null;
-
- /**
- * Identifier of local file
- */
- private String localPath;
-
- /**
- * Identifier of remote file
- */
- private String remotePath;
-
- /**
- * File to be uploaded or saved
- */
- private File file;
-
- /**
- * The file input stream associated with the file to be uploaded
- */
- private FileInputStream fileInputStream;
-
- /**
- * The file output stream associated with the file to be uploaded
- */
- private FileOutputStream fileOutputStream;
-
- /**
- * The boolean which determines whether we are uploading or downloading
- * files
- */
- private boolean uploadFile;
-
- /**
- * The currently valid ssh persistent presence operation set
- */
- private OperationSetPersistentPresenceSSHImpl opSetPersPresence = null;
-
- /**
- * The currently valid ssh instant messaging operation set
- */
- private OperationSetBasicInstantMessagingSSHImpl instantMessaging = null;
-
- /**
- * Creates a new instance of SSHFileTransferDaemon
- *
- *
- * @param sshContact The contact of the remote machine
- * @param ppService The current ssh protocol provider
- */
- public SSHFileTransferDaemon(
- ContactSSH sshContact,
- ProtocolProviderServiceSSHImpl ppService)
- {
- super();
- this.sshContact = sshContact;
- this.opSetPersPresence = (OperationSetPersistentPresenceSSHImpl)
- ppService.getOperationSet(OperationSetPersistentPresence.class);
- this.instantMessaging = (OperationSetBasicInstantMessagingSSHImpl)
- ppService.getOperationSet(
- OperationSetBasicInstantMessaging.class);
- this.ppService = ppService;
- }
-
- /**
- * This method is called when file is to be transfered from local machine
- * to remote machine
- *
- * @param remotePath - the identifier for the remote file
- * @param localPath - the identifier for the local file
- */
- public void uploadFile(
- String remotePath,
- String localPath)
- {
- this.uploadFile = true;
- this.remotePath = remotePath;
- this.localPath = localPath;
-
- file = new File(localPath);
-
- start();
- }
-
- /**
- * This method is called when a file is to be downloaded from remote machine
- * to local machine
- *
- * @param remotePath - the identifier for the remote file
- * @param localPath - the identifier for the local file
- */
- public void downloadFile(
- String remotePath,
- String localPath)
- {
- this.uploadFile = false;
- this.remotePath = remotePath;
- this.localPath = localPath;
-
- file = new File(localPath);
-
- start();
- }
-
- /**
- * Background thread for the file transfer
- */
- @Override
- public void run()
- {
- //oldStatus to be resumed earlier
- PresenceStatus oldStatus = sshContact.getPresenceStatus();
-
- opSetPersPresence.changeContactPresenceStatus(
- sshContact,
- SSHStatusEnum.CONNECTING);
-
- try
- {
- //create a new JSch session if current is invalid
- if( !ppService.isSessionValid(sshContact))
- ppService.createSSHSessionAndLogin(sshContact);
-
- fileTransferChannel = sshContact.getSSHSession()
- .openChannel("exec");
- String command;
-
- // -p = Preserves modification times, access times, and modes from
- // the original file
- if(uploadFile)
- command = "scp -p -t " + remotePath;
- else
- command = "scp -f " + remotePath;
-
- //the command to be executed on the remote terminal
- ((ChannelExec)fileTransferChannel).setCommand(command);
-
- scpInputStream = fileTransferChannel.getInputStream();
- scpOutputStream = fileTransferChannel.getOutputStream();
-
- fileTransferChannel.connect();
-
- //file transfer is setup
- opSetPersPresence.changeContactPresenceStatus(
- sshContact,
- SSHStatusEnum.FILE_TRANSFER);
-
- if(uploadFile)
- {
- instantMessaging.deliverMessage(
- instantMessaging.createMessage(
- "Uploading " + file.getName() + " to server"),
- sshContact);
-
- upload();
- }
- else
- {
- instantMessaging.deliverMessage(
- instantMessaging.createMessage(
- "Downloading " + file.getName() + " from server"),
- sshContact);
-
- download();
- }
-
- }
- catch(Exception ex)
- {
- //presently errors(any type) are directly logged directly in chat
- instantMessaging.deliverMessage(
- instantMessaging.createMessage(ex.getMessage()),
- sshContact);
-
- logger.error(ex.getMessage());
-
- try
- {
- if(fileInputStream!=null)
- {
- fileInputStream.close();
- }
-
- if(fileOutputStream!=null)
- {
- fileOutputStream.close();
- }
- }
- catch(Exception e)
- {}
- }
-
- // restore old status
- opSetPersPresence.changeContactPresenceStatus(
- sshContact,
- oldStatus);
- }
-
- /**
- * Check for error in reading stream of remote machine
- *
- * @return 0 for success, 1 for error, 2 for fatal error, -1 otherwise
- * @throws IOException when the network goes down
- */
- private int checkAck(InputStream inputStream)
- throws IOException
- {
- int result = inputStream.read();
-
- // read error message
- if(result==1 || result==2)
- {
- StringBuffer buffer = new StringBuffer();
-
- int ch;
-
- do
- {
- //read a line of message
- ch = inputStream.read();
- buffer.append((char)ch);
-
- }while(ch != '\n');
-
- ProtocolProviderServiceSSHImpl
- .getUIService()
- .getPopupDialog()
- .showMessagePopupDialog(
- buffer.toString(),
- "File Transfer Error: "
- + sshContact.getDisplayName(),
- PopupDialog.ERROR_MESSAGE);
-
- logger.error(buffer.toString());
- }
-
- return result;
- }
-
- /**
- * Uploads the file to the remote server
- *
- * @throws IOException when the network goes down
- * @throws OperationFailedException when server behaves unexpectedly
- */
- private void upload()
- throws IOException,
- OperationFailedException
- {
- fileInputStream = new FileInputStream(file);
-
- byte[] buffer = new byte[1024];
- int result, bytesRead;
-
- if( (result = checkAck(scpInputStream)) !=0)
- throw new OperationFailedException("Error in Ack", result);
-
- // send "C0644 filesize filename", where filename should not include '/'
- long filesize= file.length();
- String command = "C0644 " + filesize + " ";
-
-// if(lfile.lastIndexOf('/')>0)
-// {
-// command+=lfile.substring(lfile.lastIndexOf('/')+1);
-// }
-// else
-// {
-// command+=lfile;
-// }
-
- command += file.getName() + "\n";
- if (logger.isTraceEnabled())
- logger.trace(command);
- scpOutputStream.write(command.getBytes());
- scpOutputStream.flush();
-
- if( (result = checkAck(scpInputStream)) !=0)
- throw new OperationFailedException("Error in Ack", result);
-
- while(true)
- {
- bytesRead = fileInputStream.read(buffer, 0, buffer.length);
- if(bytesRead <= 0)
- break;
-
- scpOutputStream.write(buffer, 0, bytesRead); //out.flush();
- }
- fileInputStream.close();
- fileInputStream = null;
-
- // send '\0'
- buffer[0]=0; scpOutputStream.write(buffer, 0, 1);
- scpOutputStream.flush();
-
- if( (result = checkAck(scpInputStream)) !=0)
- throw new OperationFailedException("Error in Ack", result);
-
- scpInputStream.close();
- scpOutputStream.close();
-
- fileTransferChannel.disconnect();
-
- instantMessaging.deliverMessage(
- instantMessaging.createMessage(file.getName()
- + " uploaded to Server"),
- sshContact);
- }
-
- /**
- * Downloads a file from the remote machine
- *
- * @throws IOException when the network goes down
- * @throws OperationFailedException when server behaves unexpectedly
- */
- private void download()
- throws IOException,
- OperationFailedException
- {
- fileOutputStream = new FileOutputStream(file);
-
- int result;
-
- byte[] buffer = new byte[1024];
-
- // send '\0'
- buffer[0]=0;
-
- scpOutputStream.write(buffer, 0, 1);
- scpOutputStream.flush();
-
- int ch = checkAck(scpInputStream);
-
- if(ch!='C')
- {
- throw new OperationFailedException("Invalid reply from server", 12);
- }
-
- // read '0644 '
- scpInputStream.read(buffer, 0, 5);
-
- long filesize=0L;
- while(true)
- {
- if(scpInputStream.read(buffer, 0, 1) < 0)
- {
- // error
- break;
- }
- if(buffer[0]==' ')break;
- filesize=filesize*10L+buffer[0]-'0';
- }
-
- String file=null;
- for(int i=0;true;i++)
- {
- scpInputStream.read(buffer, i, 1);
- if(buffer[i]==(byte)0x0a)
- {
- file=new String(buffer, 0, i);
- break;
- }
- }
-
- //System.out.println("filesize="+filesize+", file="+file);
-
- // send '\0'
- buffer[0]=0;
- scpOutputStream.write(buffer, 0, 1);
- scpOutputStream.flush();
-
- // read a content of lfile
- int foo;
- while(true)
- {
- if(buffer.length<filesize)
- foo=buffer.length;
- else
- foo=(int)filesize;
-
- foo = scpInputStream.read(buffer, 0, foo);
- if(foo<0)
- break;
-
- fileOutputStream.write(buffer, 0, foo);
- filesize-=foo;
- if(filesize==0L) break;
- }
- fileOutputStream.close();
- fileOutputStream=null;
-
- if( (result = checkAck(scpInputStream)) !=0)
- throw new OperationFailedException("Error in Ack", result);
-
- // send '\0'
- buffer[0]=0;
- scpOutputStream.write(buffer, 0, 1);
- scpOutputStream.flush();
-
- scpInputStream.close();
- scpOutputStream.close();
-
- fileTransferChannel.disconnect();
-
- instantMessaging.deliverMessage(
- instantMessaging.createMessage(
- this.file.getName() + " downloaded from Server"),
- sshContact);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHReaderDaemon.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHReaderDaemon.java
deleted file mode 100644
index 2c33b5d..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHReaderDaemon.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.io.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- *
- * @author Shobhit Jindal
- */
-public class SSHReaderDaemon
- extends Thread
-{
-
- /**
- * A Buffer to aggregate replies to be sent as one message
- */
- private StringBuffer replyBuffer;
-
- /**
- * The identifier of Contact representing the remote machine
- */
- private ContactSSHImpl sshContact;
-
- /**
- * The identifier of the message received from server
- */
- private String message;
-
- /**
- * An identifier representing the state of Reader Daemon
- */
- private boolean isActive = false;
-
- /**
- * This OperationSet delivers incoming message
- */
- private OperationSetBasicInstantMessagingSSHImpl instantMessaging;
-
- /**
- * Input Stream of remote user to be read
- */
- private InputStream shellInputStream;
-
- /**
- * Buffered Reader associated with above input stream
- */
- private InputStreamReader shellReader;
-
-// /**
-// * This OperationSet delivers incoming message
-// */
-// private OperationSetPersistentPresenceSSHImpl persistentPresence;
-
- /**
- * Bytes available in Input Stream before reading
- */
- private int bytesAvailable;
-
- private int bytesRead;
-
- int bufferCount;
-
- char buf;
-
- /**
- * Creates a new instance of SSHReaderDaemon
- */
- public SSHReaderDaemon(ContactSSH sshContact)
- {
- this.sshContact = (ContactSSHImpl)sshContact;
- instantMessaging =
- (OperationSetBasicInstantMessagingSSHImpl)
- sshContact
- .getProtocolProvider()
- .getOperationSet(
- OperationSetBasicInstantMessaging.class);
- }
-
- /**
- * Reads the remote machine, updating the chat window as necessary
- * in a background thread
- */
- @Override
- public void run()
- {
- shellInputStream = sshContact.getShellInputStream();
- shellReader = sshContact.getShellReader();
- replyBuffer = new StringBuffer();
-
-
- try
- {
- do
- {
- bytesAvailable = shellInputStream.available();
-
- if(bytesAvailable == 0 )
- {
- // wait if more data is available
- // for a slower connection this value need to be raised
- // to avoid splitting of messages
- Thread.sleep(250);
- continue;
- }
-
- bufferCount = 0;
-
-// if(replyBuffer > 0)
-
- do
- {
- // store the responses in a buffer
- storeMessage(replyBuffer);
-
- Thread.sleep(250);
-
- bytesAvailable = shellInputStream.available();
-
- }while(bytesAvailable > 0 && bufferCount<16384);
-
- message = replyBuffer.toString();
-
- if(sshContact.isCommandSent())
- {
- // if the response is as a result of a command sent
- sshContact.setMessageType(
- ContactSSH.CONVERSATION_MESSAGE_RECEIVED);
-
- message = message.substring(message.indexOf('\n') + 1);
-
- sshContact.setCommandSent(false);
- }
- else
- {
- // server sent an asynchronous message to the terminal
- // display it as a system message
- sshContact.setMessageType(
- ContactSSH.SYSTEM_MESSAGE_RECEIVED);
-
- //popup disabled
-// JOptionPane.showMessageDialog(
-// null,
-// message,
-// "Message from " + sshContact.getDisplayName(),
-// JOptionPane.INFORMATION_MESSAGE);
- }
-
- instantMessaging.deliverMessage(
- instantMessaging.createMessage(message),
- sshContact);
-
- replyBuffer.delete(0, replyBuffer.length());
-
- }while(isActive);
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- /**
- * Stores the response from server in a temporary buffer
- * the bytes available are determined before the function is called
- *
- * @param replyBuffer to store the response from server
- *
- * @throws IOException if the network goes down
- */
- private void storeMessage(StringBuffer replyBuffer) throws IOException
- {
- do
- {
- buf = (char)shellInputStream.read();
-
-// System.out.println(String.valueOf(buf)+ " " + (int)buf);
-
- replyBuffer.append(String.valueOf(buf));
-
-// logger.debug(shellReader.readLine());
-
- bufferCount++;
-
- bytesAvailable--;
-
- }while(bytesAvailable>0 && bufferCount<32700);
- }
-
- public void isActive(boolean isActive)
- {
- this.isActive = isActive;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHStatusEnum.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHStatusEnum.java
deleted file mode 100644
index 0877399..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHStatusEnum.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * An implementation of <tt>PresenceStatus</tt> that enumerates all states that
- * a SSH contact can fall into.
- *
- * @author Shobhit Jindal
- */
-public class SSHStatusEnum
- extends PresenceStatus
-{
-
- /**
- * Indicates an Offline status or status with 0 connectivity.
- */
- public static final SSHStatusEnum OFFLINE
- = new SSHStatusEnum(
- 0,
- "Offline",
- ProtocolIconSSHImpl
- .getImageInBytes("service.protocol.ssh.OFFLINE_STATUS_ICON"));
-
- /**
- * The Not Available status. Indicates that the user has connectivity
- * but might not be able to immediately act (i.e. even less immediately
- * than when in an Away status ;-P ) upon initiation of communication.
- *
- */
- public static final SSHStatusEnum NOT_AVAILABLE
- = new SSHStatusEnum(
- 35,
- "Not Available",
- ProtocolIconSSHImpl
- .getImageInBytes("service.protocol.ssh.NA_STATUS_ICON"));
-
- /**
- * The Connecting status. Indicate that the user is connecting to remote
- * server
- */
- public static final SSHStatusEnum CONNECTING
- = new SSHStatusEnum(
- 55,
- "Connecting",
- ProtocolIconSSHImpl
- .getImageInBytes("service.protocol.ssh.CONNECTING_ICON"));
-
- /**
- * The Online status. Indicate that the user is able and willing to
- * communicate.
- */
- public static final SSHStatusEnum ONLINE
- = new SSHStatusEnum(
- 65,
- "Online",
- ProtocolIconSSHImpl
- .getImageInBytes("service.protocol.ssh.SSH_16x16"));
-
-
- /**
- * The Connecting status. Indicate that the user is connecting to remote
- * server
- */
- public static final SSHStatusEnum CONNECTED
- = new SSHStatusEnum(
- 70,
- "Connecting",
- ProtocolIconSSHImpl
- .getImageInBytes("service.protocol.ssh.CONNECTED_ICON"));
-
- /**
- * The File Transfer status. Indicate that the user is transfering a file
- * to/from a remote server
- */
- public static final SSHStatusEnum FILE_TRANSFER
- = new SSHStatusEnum(
- 75,
- "Transfering File",
- ProtocolIconSSHImpl
- .getImageInBytes("service.protocol.ssh.FILE_TRANSFER_ICON"));
-
- /**
- * Initialize the list of supported status states.
- */
- private static List<PresenceStatus> supportedStatusSet = new LinkedList<PresenceStatus>();
- static
- {
- supportedStatusSet.add(OFFLINE);
-// supportedStatusSet.add(NOT_AVAILABLE);
- supportedStatusSet.add(ONLINE);
-// supportedStatusSet.add(CONNECTING);
- }
-
- /**
- * Creates an instance of <tt>SSHPresneceStatus</tt> with the
- * specified parameters.
- * @param status the connectivity level of the new presence status instance
- * @param statusName the name of the presence status.
- * @param statusIcon the icon associated with this status
- */
- private SSHStatusEnum(int status,
- String statusName,
- byte[] statusIcon)
- {
- super(status, statusName, statusIcon);
- }
-
- /**
- * Returns an iterator over all status instances supproted by the ssh
- * provider.
- * @return an <tt>Iterator</tt> over all status instances supported by the
- * ssh provider.
- */
- static Iterator<PresenceStatus> supportedStatusSet()
- {
- return supportedStatusSet.iterator();
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHUserInfo.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHUserInfo.java
deleted file mode 100644
index 082b05f..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHUserInfo.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.java.sip.communicator.impl.protocol.ssh;
-
-import javax.swing.*;
-
-import com.jcraft.jsch.*;
-
-/**
- * SSHUserInfo passes authentication details to JSch SSH Stack
- *
- * @author Shobhit Jindal
- */
-class SSHUserInfo
- implements UserInfo,
- UIKeyboardInteractive
-{
- /**
- * The Contact of the remote machine
- */
- private ContactSSH sshContact;
-
- /**
- * Identifier for failure of authentication
- * more explanation below in promptPassword function
- */
- private boolean failedOnce = false;
-
- /**
- * Password field for requesting auth details from user
- */
- JTextField passwordField=new JPasswordField(20);
-
- /**
- * Creates a UserInfo instance
- *
- * @param sshContact the contact concerned
- */
- SSHUserInfo(ContactSSH sshContact)
- {
- this.sshContact = sshContact;
- }
-
- /**
- * Returns the password of account associated with this contact
- *
- * @return the password of account associated with this contact
- */
- public String getPassword()
- {
- return sshContact.getPassword();
- }
-
- /**
- * Prompt for accepting the cipher information of the remote server
- *
- * @param str the string to display
- *
- * @return the user's answer
- */
- public boolean promptYesNo(String str)
- {
- Object[] options={ "yes", "no" };
- int foo=JOptionPane.showOptionDialog(null,
- str,
- "Warning",
- JOptionPane.DEFAULT_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null, options, options[0]);
- return foo==0;
- }
-
- /**
- * Passphrase authentication presently not implemented
- *
- * @return null
- */
- public String getPassphrase()
- { return null; }
-
- /**
- * Passphrase authentication presently not implemented
- *
- * @return true
- */
- public boolean promptPassphrase(String message)
- { return true; }
-
- /**
- * Asks user to re-enter password information in case of an auth failure
- *
- * @param message the message to display
- *
- * @return the user's answer
- */
- public boolean promptPassword(String message)
- {
- /**
- * Auth always fails for the first time for Redhat based machines.
- * Trying again with the same password
- */
- if(!failedOnce)
- {
- failedOnce = true;
- return true;
- }
-
- Object[] ob={passwordField};
- int result=JOptionPane.showConfirmDialog(null, ob, "Auth Failed: "
- + message,
- JOptionPane.OK_CANCEL_OPTION);
-
- if(result==JOptionPane.OK_OPTION)
- {
- sshContact.setPassword(passwordField.getText());
- return true;
- }
-
- return false;
- }
-
- /**
- * Shows a message from server
- *
- * @param message The message to display
- */
- public void showMessage(String message)
- {
- JOptionPane.showMessageDialog(null, message);
- }
-
- /**
- * Keyboard Interactive Auth - not implemented
- */
- public String[] promptKeyboardInteractive(
- String destination,
- String name,
- String instruction,
- String[] prompt,
- boolean[] echo)
- {
- String response[] = new String[prompt.length];
- response[0] = sshContact.getPassword();
- return response;
- }
-
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ssh.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/ssh/ssh.provider.manifest.mf
deleted file mode 100644
index eb9472f..0000000
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ssh.provider.manifest.mf
+++ /dev/null
@@ -1,20 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.impl.protocol.ssh.SSHActivator
-Bundle-Name: SSH Protocol Provider
-Bundle-Description: A bundle providing support for the SSH protocol.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 0.0.1
-Bundle-SymbolicName: net.java.sip.communicator.protocol.ssh
-Import-Package: org.osgi.framework,
- javax.crypto,
- javax.crypto.interfaces,
- javax.crypto.spec,
- javax.swing,
- javax.swing.border,
- javax.swing.text,
- org.jitsi.service.configuration,
- net.java.sip.communicator.service.gui,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.event,
- org.jitsi.service.resources, net.java.sip.communicator.service.resources,
- net.java.sip.communicator.util,
- net.java.sip.communicator.plugin.desktoputil