1
package org.herac.tuxguitar.gui.tools.browser.ftp;
3
import org.herac.tuxguitar.gui.tools.browser.base.TGBrowserData;
4
import org.herac.tuxguitar.gui.tools.browser.ftp.utils.Base64Decoder;
5
import org.herac.tuxguitar.gui.tools.browser.ftp.utils.Base64Encoder;
7
public class TGBrowserDataImpl implements TGBrowserData{
9
private static final String STRING_SEPARATOR = ";";
13
private String username;
14
private String password;
16
public TGBrowserDataImpl(String host,String path,String username,String password){
19
this.username = username;
20
this.password = password;
23
public String getHost() {
27
public String getPath() {
31
public String getPassword() {
32
return ((this.username != null && this.username.length() > 0)?this.password:"anonymous");
35
public String getUsername() {
36
return ((this.username != null && this.username.length() > 0)?this.username:"anonymous");
39
public String getTitle(){
40
return (getHost() + ":" + getPath());
43
public String toString(){
44
String username = new String( Base64Encoder.encode( getUsername().getBytes() ) );
45
String password = new String( Base64Encoder.encode( getPassword().getBytes() ) );
46
return getHost() + STRING_SEPARATOR + getPath() + STRING_SEPARATOR + username + STRING_SEPARATOR + password;
49
public static TGBrowserData fromString(String string) {
50
String[] data = string.split(STRING_SEPARATOR);
52
String username = new String( Base64Decoder.decode( data[2].getBytes() ) );
53
String password = new String( Base64Decoder.decode( data[3].getBytes() ) );
54
return new TGBrowserDataImpl(data[0],data[1],username,password);