|
|
|
|
@ -18,6 +18,7 @@
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import org.osgi.framework.*;
|
|
|
|
|
import net.java.sip.communicator.impl.gui.customcontrols.*;
|
|
|
|
|
import net.java.sip.communicator.service.gui.*;
|
|
|
|
|
import net.java.sip.communicator.service.protocol.*;
|
|
|
|
|
import net.java.sip.communicator.impl.protocol.ssh.*;
|
|
|
|
|
@ -30,58 +31,55 @@
|
|
|
|
|
* @author Shobhit Jindal
|
|
|
|
|
*/
|
|
|
|
|
public class SSHAccountRegistrationWizard
|
|
|
|
|
implements AccountRegistrationWizard
|
|
|
|
|
{
|
|
|
|
|
implements AccountRegistrationWizard {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The first page of the ssh account registration wizard.
|
|
|
|
|
*/
|
|
|
|
|
private FirstWizardPage firstWizardPage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The object that we use to store details on an account that we will be
|
|
|
|
|
* creating.
|
|
|
|
|
*/
|
|
|
|
|
private SSHAccountRegistration registration
|
|
|
|
|
= new SSHAccountRegistration();
|
|
|
|
|
|
|
|
|
|
= new SSHAccountRegistration();
|
|
|
|
|
|
|
|
|
|
private WizardContainer wizardContainer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ProtocolProviderService protocolProvider;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String propertiesPackage
|
|
|
|
|
= "net.java.sip.communicator.plugin.sshaccregwizz";
|
|
|
|
|
|
|
|
|
|
= "net.java.sip.communicator.plugin.sshaccregwizz";
|
|
|
|
|
|
|
|
|
|
private boolean isModification;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an instance of <tt>SSHAccountRegistrationWizard</tt>.
|
|
|
|
|
* @param wizardContainer the wizard container, where this wizard
|
|
|
|
|
* is added
|
|
|
|
|
*/
|
|
|
|
|
public SSHAccountRegistrationWizard(WizardContainer wizardContainer)
|
|
|
|
|
{
|
|
|
|
|
public SSHAccountRegistrationWizard(WizardContainer wizardContainer) {
|
|
|
|
|
this.wizardContainer = wizardContainer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements the <code>AccountRegistrationWizard.getIcon</code> method.
|
|
|
|
|
* Returns the icon to be used for this wizard.
|
|
|
|
|
* @return byte[]
|
|
|
|
|
*/
|
|
|
|
|
public byte[] getIcon()
|
|
|
|
|
{
|
|
|
|
|
public byte[] getIcon() {
|
|
|
|
|
return Resources.getImage(Resources.SSH_LOGO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements the <code>AccountRegistrationWizard.getPageImage</code>
|
|
|
|
|
* method.
|
|
|
|
|
* Returns the image used to decorate the wizard page
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @return byte[] the image used to decorate the wizard page
|
|
|
|
|
*/
|
|
|
|
|
public byte[] getPageImage()
|
|
|
|
|
{
|
|
|
|
|
public byte[] getPageImage() {
|
|
|
|
|
return Resources.getImage(Resources.PAGE_IMAGE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -90,208 +88,142 @@ public byte[] getPageImage()
|
|
|
|
|
* method. Returns the protocol name for this wizard.
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
|
|
|
|
public String getProtocolName()
|
|
|
|
|
{
|
|
|
|
|
public String getProtocolName() {
|
|
|
|
|
return Resources.getString("protocolName");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements the <code>AccountRegistrationWizard.getProtocolDescription
|
|
|
|
|
* </code> method. Returns the description of the protocol for this wizard.
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
|
|
|
|
public String getProtocolDescription()
|
|
|
|
|
{
|
|
|
|
|
public String getProtocolDescription() {
|
|
|
|
|
return Resources.getString("protocolDescription");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the set of pages contained in this wizard.
|
|
|
|
|
* @return Iterator
|
|
|
|
|
*/
|
|
|
|
|
public Iterator getPages()
|
|
|
|
|
{
|
|
|
|
|
public Iterator getPages() {
|
|
|
|
|
ArrayList pages = new ArrayList();
|
|
|
|
|
firstWizardPage = new FirstWizardPage(this);
|
|
|
|
|
|
|
|
|
|
firstWizardPage = new FirstWizardPage(registration, wizardContainer);
|
|
|
|
|
|
|
|
|
|
pages.add(firstWizardPage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return pages.iterator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the set of data that user has entered through this wizard.
|
|
|
|
|
* @return Iterator
|
|
|
|
|
*/
|
|
|
|
|
public Iterator getSummary()
|
|
|
|
|
{
|
|
|
|
|
public Iterator getSummary() {
|
|
|
|
|
Hashtable summaryTable = new Hashtable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Hashtable arranges the entries alphabetically so the order of
|
|
|
|
|
* appearance is:
|
|
|
|
|
* Hashtable arranges the entries alphabetically so the order
|
|
|
|
|
* of appearance is
|
|
|
|
|
* - Computer Name / IP
|
|
|
|
|
* - Port
|
|
|
|
|
* - User ID
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
summaryTable.put("Account ID", registration.getAccountID());
|
|
|
|
|
summaryTable.put("Known Hosts", registration.getKnownHostsFile());
|
|
|
|
|
summaryTable.put("Identity", registration.getIdentityFile());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return summaryTable.entrySet().iterator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Installs the account created through this wizard.
|
|
|
|
|
* @return ProtocolProviderService
|
|
|
|
|
*/
|
|
|
|
|
public ProtocolProviderService finish()
|
|
|
|
|
{
|
|
|
|
|
public ProtocolProviderService finish() {
|
|
|
|
|
firstWizardPage = null;
|
|
|
|
|
ProtocolProviderFactory factory
|
|
|
|
|
= SSHAccRegWizzActivator.getSSHProtocolProviderFactory();
|
|
|
|
|
|
|
|
|
|
= SSHAccRegWizzActivator.getSSHProtocolProviderFactory();
|
|
|
|
|
|
|
|
|
|
return this.installAccount(factory,
|
|
|
|
|
registration.getAccountID());
|
|
|
|
|
registration.getAccountID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an account for the given Account ID, Identity File and Known
|
|
|
|
|
* Hosts File
|
|
|
|
|
*
|
|
|
|
|
* @param providerFactory the ProtocolProviderFactory which will create
|
|
|
|
|
* the account
|
|
|
|
|
* @param user the user identifier
|
|
|
|
|
* @param user the user identifier
|
|
|
|
|
* @return the <tt>ProtocolProviderService</tt> for the new account.
|
|
|
|
|
*/
|
|
|
|
|
public ProtocolProviderService installAccount(
|
|
|
|
|
ProtocolProviderFactory providerFactory,
|
|
|
|
|
String user)
|
|
|
|
|
{
|
|
|
|
|
ProtocolProviderFactory providerFactory,
|
|
|
|
|
String user) {
|
|
|
|
|
|
|
|
|
|
Hashtable accountProperties = new Hashtable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
accountProperties.put(ProtocolProviderFactorySSHImpl.IDENTITY_FILE,
|
|
|
|
|
registration.getIdentityFile());
|
|
|
|
|
|
|
|
|
|
registration.getIdentityFile());
|
|
|
|
|
|
|
|
|
|
accountProperties.put(ProtocolProviderFactorySSH.KNOWN_HOSTS_FILE,
|
|
|
|
|
String.valueOf(registration.getKnownHostsFile()));
|
|
|
|
|
|
|
|
|
|
if (isModification)
|
|
|
|
|
{
|
|
|
|
|
providerFactory.uninstallAccount(protocolProvider.getAccountID());
|
|
|
|
|
this.protocolProvider = null;
|
|
|
|
|
this.isModification = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
String.valueOf(registration.getKnownHostsFile()));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
AccountID accountID = providerFactory.installAccount(
|
|
|
|
|
user, accountProperties);
|
|
|
|
|
|
|
|
|
|
user, accountProperties);
|
|
|
|
|
|
|
|
|
|
ServiceReference serRef = providerFactory
|
|
|
|
|
.getProviderForAccount(accountID);
|
|
|
|
|
|
|
|
|
|
.getProviderForAccount(accountID);
|
|
|
|
|
|
|
|
|
|
protocolProvider = (ProtocolProviderService)
|
|
|
|
|
SSHAccRegWizzActivator.bundleContext
|
|
|
|
|
.getService(serRef);
|
|
|
|
|
}
|
|
|
|
|
catch (IllegalArgumentException exc)
|
|
|
|
|
{
|
|
|
|
|
SSHAccRegWizzActivator.getUIService().getPopupDialog()
|
|
|
|
|
.showMessagePopupDialog(
|
|
|
|
|
exc.getMessage(),
|
|
|
|
|
Resources.getString("error"),
|
|
|
|
|
PopupDialog.ERROR_MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
catch (IllegalStateException exc)
|
|
|
|
|
{
|
|
|
|
|
SSHAccRegWizzActivator.getUIService().getPopupDialog()
|
|
|
|
|
.showMessagePopupDialog(
|
|
|
|
|
exc.getMessage(),
|
|
|
|
|
Resources.getString("error"),
|
|
|
|
|
PopupDialog.ERROR_MESSAGE);
|
|
|
|
|
SSHAccRegWizzActivator.bundleContext
|
|
|
|
|
.getService(serRef);
|
|
|
|
|
} catch (IllegalArgumentException exc) {
|
|
|
|
|
new ErrorDialog(null, "Error", exc.getMessage(), exc).showDialog();
|
|
|
|
|
} catch (IllegalStateException exc) {
|
|
|
|
|
new ErrorDialog(null, "Error", exc.getMessage(), exc).showDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return protocolProvider;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fills the UserID and Password fields in this panel with the data coming
|
|
|
|
|
* Fills the UserID and Password fields in this panel with the data comming
|
|
|
|
|
* from the given protocolProvider.
|
|
|
|
|
* @param protocolProvider The <tt>ProtocolProviderService</tt> to load the
|
|
|
|
|
* data from.
|
|
|
|
|
*/
|
|
|
|
|
public void loadAccount(ProtocolProviderService protocolProvider)
|
|
|
|
|
{
|
|
|
|
|
this.isModification = true;
|
|
|
|
|
|
|
|
|
|
public void loadAccount(ProtocolProviderService protocolProvider) {
|
|
|
|
|
|
|
|
|
|
this.protocolProvider = protocolProvider;
|
|
|
|
|
|
|
|
|
|
this.registration = new SSHAccountRegistration();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.firstWizardPage.loadAccount(protocolProvider);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates if this wizard is opened for modification or for creating a
|
|
|
|
|
* new account.
|
|
|
|
|
*
|
|
|
|
|
* @return <code>true</code> if this wizard is opened for modification and
|
|
|
|
|
* <code>false</code> otherwise.
|
|
|
|
|
*/
|
|
|
|
|
public boolean isModification()
|
|
|
|
|
{
|
|
|
|
|
return isModification;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the wizard container, where all pages are added.
|
|
|
|
|
*
|
|
|
|
|
* @return the wizard container, where all pages are added
|
|
|
|
|
*/
|
|
|
|
|
public WizardContainer getWizardContainer()
|
|
|
|
|
{
|
|
|
|
|
return wizardContainer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the registration object, which will store all the data through
|
|
|
|
|
* the wizard.
|
|
|
|
|
*
|
|
|
|
|
* @return the registration object, which will store all the data through
|
|
|
|
|
* the wizard
|
|
|
|
|
*/
|
|
|
|
|
public SSHAccountRegistration getRegistration()
|
|
|
|
|
{
|
|
|
|
|
return registration;
|
|
|
|
|
|
|
|
|
|
isModification = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the size of this wizard.
|
|
|
|
|
* @return the size of this wizard
|
|
|
|
|
*/
|
|
|
|
|
public Dimension getSize()
|
|
|
|
|
{
|
|
|
|
|
public Dimension getSize() {
|
|
|
|
|
return new Dimension(600, 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the identifier of the page to show first in the wizard.
|
|
|
|
|
* @return the identifier of the page to show first in the wizard.
|
|
|
|
|
* Returns the identifier of the first account registration wizard page.
|
|
|
|
|
* This method is meant to be used by the wizard container to determine,
|
|
|
|
|
* which is the first page to show to the user.
|
|
|
|
|
*
|
|
|
|
|
* @return the identifier of the first account registration wizard page
|
|
|
|
|
*/
|
|
|
|
|
public Object getFirstPageIdentifier()
|
|
|
|
|
{
|
|
|
|
|
public Object getFirstPageIdentifier() {
|
|
|
|
|
return firstWizardPage.getIdentifier();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the identifier of the page to show last in the wizard.
|
|
|
|
|
* @return the identifier of the page to show last in the wizard.
|
|
|
|
|
*/
|
|
|
|
|
public Object getLastPageIdentifier()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public Object getLastPageIdentifier() {
|
|
|
|
|
return firstWizardPage.getIdentifier();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|