From 54e5a418fb6cf1dee796248f54df739d77e30414 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Mon, 25 May 2009 11:32:10 +0000 Subject: [PATCH] Fix issue #666. Wrong resource names and not proper saving persistent data. --- .../impl/protocol/ssh/ContactSSHImpl.java | 102 ++++++++++-------- ...OperationSetPersistentPresenceSSHImpl.java | 9 +- .../impl/protocol/ssh/SSHContactInfo.java | 11 +- 3 files changed, 67 insertions(+), 55 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java index 995a79909..881eeef7d 100644 --- a/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java @@ -176,7 +176,7 @@ public ContactSSHImpl( this.sshConfigurationForm = new SSHContactInfo(this); - + this.savePersistentDetails(); } @@ -313,74 +313,81 @@ public void stopTimerTask() /** * Saves the details of contact in persistentData seperated by - * "service.gui.JANUARY" + * separator * Passowrd is saved unsecurely using Base64 encoding */ public void savePersistentDetails() { persistentData = this.sshConfigurationForm.getHostName() + - "service.gui.JANUARY" + + separator + this.sshConfigurationForm.getUserName() + - "service.gui.JANUARY" + + separator + new String(Base64.encode(this.sshConfigurationForm.getPassword() .getBytes())) + - "service.gui.JANUARY" + sshConfigurationForm.getPort() + - "service.gui.JANUARY" + + separator + sshConfigurationForm.getPort() + + separator + sshConfigurationForm.getTerminalType() + - "service.gui.JANUARY" + + separator + sshConfigurationForm.getUpdateInterval(); } /** * Stores persistent data in fields of the contact seperated by - * "service.gui.JANUARY". + * separator. * * @param persistentData of the contact */ public void setPersistentData(String persistentData) { - this.persistentData = persistentData; - int firstCommaIndex = this.persistentData.indexOf("service.gui.JANUARY"); - int secondCommaIndex = this.persistentData.indexOf("service.gui.JANUARY", - firstCommaIndex +1); - int thirdCommaIndex = this.persistentData.indexOf("service.gui.JANUARY", - secondCommaIndex +1); - int fourthCommaIndex = this.persistentData.indexOf("service.gui.JANUARY", - thirdCommaIndex +1); - int fifthCommaIndex = this.persistentData.indexOf("service.gui.JANUARY", - fourthCommaIndex +1); - - 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) + try { - if(this.persistentData.substring(secondCommaIndex+1).length()>0) - this.sshConfigurationForm.setPasswordField( - new String(Base64.decode(this.persistentData - .substring(secondCommaIndex+1, thirdCommaIndex)))); + 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); + + 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); } - - - 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))); } /** @@ -885,6 +892,7 @@ public String getPassword() public void setPassword(String password) { this.sshConfigurationForm.setPasswordField(password); + System.out.println("22222222222222222"); savePersistentDetails(); } diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetPersistentPresenceSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetPersistentPresenceSSHImpl.java index 095c19d01..ef45c2690 100644 --- a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetPersistentPresenceSSHImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetPersistentPresenceSSHImpl.java @@ -665,11 +665,12 @@ public void subscribe( /* 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 @@ -682,8 +683,6 @@ public void subscribe( // addContactToList method is called */ - //add contact to contact list - addContactToList(parent, sshContact); } /** @@ -815,7 +814,7 @@ public Contact createUnresolvedContact( ContactSSH contact = new ContactSSHImpl( address, parentProvider); - + contact.setPersistentData(persistentData); contact.startTimerTask(); diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java index 001eb3947..e92839bd1 100644 --- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java +++ b/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java @@ -191,9 +191,14 @@ public void actionPerformed(ActionEvent event) { } sshContact.savePersistentDetails(); -// ((OperationSetPersistentPresenceSSHImpl)sshContact -// .getParentPresenceOperationSet()) -// .addContactToList(contactGroup, sshContact); + + //add contact to contact list + ((OperationSetPersistentPresenceSSHImpl)sshContact + .getParentPresenceOperationSet()) + .addContactToList( + sshContact.getParentContactGroup(), + sshContact); + setVisible(false); } });