9
9
private static final String STRING_SEPARATOR = ";";
11
12
private String host;
12
13
private String path;
13
14
private String username;
14
15
private String password;
16
private String proxyUser;
17
private String proxyPwd;
18
private String proxyHost;
19
private int proxyPort;
16
public TGBrowserDataImpl(String host,String path,String username,String password){
21
public TGBrowserDataImpl(String name, String host, String path, String username, String password, String proxyUser, String proxyPwd, String proxyHost, int proxyPort) {
19
25
this.username = username;
20
26
this.password = password;
27
this.proxyUser = proxyUser;
28
this.proxyPwd = proxyPwd;
29
this.proxyHost = proxyHost;
30
this.proxyPort = proxyPort;
33
public String getName() {
23
37
public String getHost() {
31
45
public String getPassword() {
32
return ((this.username != null && this.username.length() > 0)?this.password:"anonymous");
46
return ((this.username != null && this.username.length() > 0)?this.password:TGBrowserFTPClient.DEFAULT_USER_PASSWORD);
35
49
public String getUsername() {
36
return ((this.username != null && this.username.length() > 0)?this.username:"anonymous");
50
return ((this.username != null && this.username.length() > 0)?this.username:TGBrowserFTPClient.DEFAULT_USER_NAME);
39
53
public String getTitle(){
40
return (getHost() + ":" + getPath());
57
public String getProxyHost() {
58
return this.proxyHost;
61
public int getProxyPort() {
62
return this.proxyPort;
65
public String getProxyUser() {
66
return this.proxyUser;
69
public String getProxyPwd() {
43
73
public String toString(){
44
74
String username = new String( Base64Encoder.encode( getUsername().getBytes() ) );
45
75
String password = new String( Base64Encoder.encode( getPassword().getBytes() ) );
46
return getHost() + STRING_SEPARATOR + getPath() + STRING_SEPARATOR + username + STRING_SEPARATOR + password;
76
String proxyUser = new String( Base64Encoder.encode( getProxyUser().getBytes() ));
77
String proxyPwd = new String( Base64Encoder.encode( getProxyPwd().getBytes() ));
79
return getName() + STRING_SEPARATOR + getHost() + STRING_SEPARATOR
80
+ getPath() + STRING_SEPARATOR + username + STRING_SEPARATOR
81
+ password + STRING_SEPARATOR + proxyUser + STRING_SEPARATOR
82
+ proxyPwd + STRING_SEPARATOR + getProxyHost()
83
+ STRING_SEPARATOR + getProxyPort();
49
86
public static TGBrowserData fromString(String string) {
50
87
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);
89
String username = new String( Base64Decoder.decode( data[3].getBytes() ) );
90
String password = new String( Base64Decoder.decode( data[4].getBytes() ) );
91
String proxyUser = new String( Base64Decoder.decode( data[5].getBytes() ));
92
String proxyPwd = new String( Base64Decoder.decode( data[6].getBytes() ) );
93
return new TGBrowserDataImpl(data[0], data[1], data[2], username, password, proxyUser, proxyPwd, data[7], Integer.parseInt(data[8]));