Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/flexstor/common/data/ejb/address/FtpAddressData.java


1   /*
2    * FtpAddressData.java
3    *
4    * Copyright $Date: 2003/08/11 02:22:47 $ FLEXSTOR.net Inc.
5    *
6    * This work is licensed for use and distribution under license terms found at
7    * http://www.flexstor.org/license.html
8    *
9    */
10  
11  package com.flexstor.common.data.ejb.address;
12  
13  import com.flexstor.common.data.ejb.SettingData;
14  import com.flexstor.common.keys.ejb.FtpAddressKey;
15  import com.flexstor.common.keys.ejb.SettingKey;
16  
17  /**
18   * This class supports state data for <code>FtpAddress</code>.  A Data class holds <br>
19   * all of the state information for a corresponding class and reference <br>
20   * pointers to other classes <br>
21   *
22   * @author  Perry Hoekstra
23   * @version 1.0, 12/19/98
24   *
25   * @since   FLEXSTOR.db 3.0
26   */
27  public class FtpAddressData 
28     extends AddressData 
29  {
30    // MKS macro expander
31    public final static String IDENTIFIER = "$Id: FtpAddressData.java,v 1.3 2003/08/11 02:22:47 aleric Exp $";
32    
33    //id of an authorized user of the ftp server
34    protected String userid = null;
35  
36    //password of the authorized user of the ftp address
37    protected String password = null;
38  
39    //initial directory assigned once a user successfully logs into an ftp server
40    protected String remoteDirectory = null;
41  
42    //name of the firewall server
43    protected String proxyHost = null;
44  
45    //password of an proxy user authorized for ftp access through the firewall
46    protected String proxyPassword = null;
47  
48    //port that the firewall allows ftp traffic through
49    protected int proxyPort;
50  
51    // userid of a proxy user authorized for ftp access through the firewall
52    protected String proxyUserID = null;
53  
54     /** 
55     * Default constructor for the FtpAddressData class<p>
56     *
57     * <b>Warning</b> Any objects created with this constructor are not updatable or insertable to the database 
58     */ 
59      
60     public FtpAddressData() 
61     {
62       super();
63     }
64     
65     /** 
66     * Constructor for the FtpAddressData class<p>
67     *
68     * <b>Warning</b> Any objects created with this constructor are not updatable (insertable, but not updatable) to the database
69     *
70     * @param java.lang.String  an ftp server name
71     */ 
72     public FtpAddressData(String aName) 
73     {
74       super(aName);
75     }
76  
77     /**
78      * Creates a FtpAddressData object based on an orginal FtpAddressData object.
79      * This constructor is intended to be used when duplicating this object.
80      *
81      * @param orginal the object to be copied.
82      */
83     public FtpAddressData ( FtpAddressData orginal )
84     {
85        synchronize(orginal);
86        setKey ( null );
87     }
88      
89     /**
90      * Clones this object.
91      */   
92     public SettingData cloneObject ( )
93     {
94        return new FtpAddressData ( this );
95     }
96  
97     /**
98      * Copies all members from the argument into the current object.
99      * This methods is used when the server returns an updated object
100     * to synchronize the client instance.
101     * @param AddressData
102     */
103    public void synchronize(FtpAddressData original )
104    {
105       super.synchronize(original);
106       setUserID (original.getUserID() );
107       setPassword (original.getPassword() );
108       setRemoteDirectory (original.getRemoteDirectory() );
109       setProxyHost (original.getProxyHost() );
110       setProxyPort (original.getProxyPort() );
111       setProxyUserID (original.getProxyUserID() );
112    }
113       
114    
115 
116    /**
117     * Determine if these two objects are equal, i.e. their attributes are equal.  This method <b>will not</b> test the
118     * equality of references to other objects
119     *
120     * @param com.flexstor.common.data.ejb.address.FtpAddressData  a data object
121     *
122     * @return boolean 
123     */
124    public boolean equals( Object o ) 
125    {
126       if ( super.equals(o) && o instanceof FtpAddressData )
127       {
128          FtpAddressData aDataObject = (FtpAddressData) o;
129          if ( isUserIDEqual(aDataObject.getUserID())
130               && isPasswordEqual(aDataObject.getPassword())
131               && isRemoteDirectoryEqual(aDataObject.getRemoteDirectory())
132               && isProxyHostEqual(aDataObject.getProxyHost())
133               && isProxyPasswordEqual(aDataObject.getProxyPassword())
134               && isProxyUserIDEqual(aDataObject.getProxyUserID())
135               && getProxyPort() == aDataObject.getProxyPort() )
136             return true;
137       }       
138   
139       return false;
140    }
141    
142    /**
143    * Return the password of the authorized user of the ftp address
144    *
145    * @return java.lang.String  - a password in plain text format
146    */
147     
148    public String getPassword() {
149      return password;
150    }
151    /**
152    * Return the name of the firewall server in dnsname.domain.tld format
153    *
154    * @return java.lang.String  - a server name
155    */
156     
157    public String getProxyHost() {
158      return proxyHost;
159    }
160    /**
161    * Return the password of an proxy user authorized for ftp access through the firewall
162    *
163    * @return java.lang.String  - a password in clear text format
164    */
165     
166    public String getProxyPassword() {
167      return proxyPassword;
168    }
169    /**
170    * Return the port that the firewall allows ftp traffic through
171    *
172    * @return int  - a port number
173    */
174     
175    public int getProxyPort() {
176      return proxyPort;
177    }
178    /**
179    * Return the userid of a proxy user authorized for ftp access through the firewall
180    *
181    * @return java.lang.String  - A userid
182    */
183     
184    public String getProxyUserID() {
185      return proxyUserID;
186    }
187 
188    /**
189    * Return this instance's database object reference
190    *
191    * @return com.flexstor.common.keys.ejb.FtpAddressKey - an object reference to a row in the database
192    * @deprecated see getKey()
193    */
194    public FtpAddressKey getReference() 
195    {
196      return (FtpAddressKey)key;
197    }
198 
199    /**
200    * Return this instance's database object reference
201    *
202    * @return com.flexstor.common.keys.ejb.FtpAddressKey - an object reference to a row in the database
203    * @deprecated see setKey(FtpAddressKey aKey)
204    */
205    public void setReference(FtpAddressKey aKey) 
206    {
207     setKey(aKey);
208    }
209 
210 
211    /**
212    * Return the initial directory assigned once a user successfully logs into an ftp server 
213    *
214    * @return java.lang.String  - a directory or directory path
215    */
216    public String getRemoteDirectory() {
217      return remoteDirectory;
218    }
219    /**
220    * Return the id of an authorized user of the ftp server
221    *
222    * @return java.lang.String  - A userid
223    */
224     
225    public String getUserID() {
226      return userid;
227    }
228    /**
229    * Checks whether two password strings have equal values.
230    *
231    * @param java.lang.String  a password
232    *
233    * @return boolean 
234    */
235     
236    private boolean isPasswordEqual(String aPassword) {
237      boolean objectsEqual = true;
238      
239      //check Password
240      if (getPassword() != null) {
241        if (aPassword != null) {
242          if (getPassword().equals(aPassword)) {
243            //continue on
244          }
245          else {
246            objectsEqual = false;
247          }
248        }
249        else {
250          objectsEqual = false;
251        }
252      }
253      else {
254        if (aPassword != null) {
255          if (aPassword.equals("null"))  {
256            // continue on
257          }
258          else {
259            objectsEqual = false;
260          }
261        }    
262      }
263 
264      return objectsEqual;
265    }
266    /**
267    * Checks whether two proxy host strings have equal values.
268    *
269    * @param java.lang.String  a proxy host name
270    *
271    * @return boolean 
272    */
273     
274    private boolean isProxyHostEqual(String aProxyHost) {
275      boolean objectsEqual = true;
276      
277      //check ProxyHost
278      if (getProxyHost() != null) {
279        if (aProxyHost != null) {
280          if (getProxyHost().equals(aProxyHost)) {
281            //continue on
282          }
283          else {
284            objectsEqual = false;
285          }
286        }
287        else {
288          objectsEqual = false;
289        }
290      }
291      else {
292        if (aProxyHost != null) {
293          if (aProxyHost.equals("null"))  {
294            // continue on
295          }
296          else {
297            objectsEqual = false;
298          }
299        }    
300      }
301 
302      return objectsEqual;
303    }
304    /**
305    * Checks whether two proxy password strings have equal values.
306    *
307    * @param java.lang.String  a proxy password
308    *
309    * @return boolean 
310    */
311     
312    private boolean isProxyPasswordEqual(String aProxyPassword) {
313      boolean objectsEqual = true;
314      
315      //check ProxyPassword
316      if (getProxyPassword() != null) {
317        if (aProxyPassword != null) {
318          if (getProxyPassword().equals(aProxyPassword)) {
319            //continue on
320          }
321          else {
322            objectsEqual = false;
323          }
324        }
325        else {
326          objectsEqual = false;
327        }
328      }
329      else {
330        if (aProxyPassword != null) {
331          if (aProxyPassword.equals("null"))  {
332            // continue on
333          }
334          else {
335            objectsEqual = false;
336          }
337        }    
338      }
339 
340      return objectsEqual;
341    }
342    /**
343    * Checks whether two proxy userid strings have equal values.
344    *
345    * @param java.lang.String  a userid
346    *
347    * @return boolean 
348    */
349     
350    private boolean isProxyUserIDEqual(String aProxyUserID) {
351      boolean objectsEqual = true;
352      
353      //check ProxyUserID
354      if (getProxyUserID() != null) {
355        if (aProxyUserID != null) {
356          if (getProxyUserID().equals(aProxyUserID)) {
357            //continue on
358          }
359          else {
360            objectsEqual = false;
361          }
362        }
363        else {
364          objectsEqual = false;
365        }
366      }
367      else {
368        if (aProxyUserID != null) {
369          if (aProxyUserID.equals("null"))  {
370            // continue on
371          }
372          else {
373            objectsEqual = false;
374          }
375        }    
376      }
377 
378      return objectsEqual;
379    }
380    /**
381    * Checks whether two remote directory strings have equal values.
382    *
383    * @param java.lang.String  a remote directory
384    *
385    * @return boolean 
386    */
387     
388    private boolean isRemoteDirectoryEqual(String aRemoteDirectory) {
389      boolean objectsEqual = true;
390      
391      //check RemoteDirectory
392      if (getRemoteDirectory() != null) {
393        if (aRemoteDirectory != null) {
394          if (getRemoteDirectory().equals(aRemoteDirectory)) {
395            //continue on
396          }
397          else {
398            objectsEqual = false;
399          }
400        }
401        else {
402          objectsEqual = false;
403        }
404      }
405      else {
406        if (aRemoteDirectory != null) {
407          if (aRemoteDirectory.equals("null"))  {
408            // continue on
409          }
410          else {
411            objectsEqual = false;
412          }
413        }    
414      }
415 
416      return objectsEqual;
417    }
418    /**
419    * Checks whether two name strings have equal values.
420    *
421    * @param java.lang.String  a userid
422    *
423    * @return boolean 
424    */
425     
426    private boolean isUserIDEqual(String aUserID) {
427      boolean objectsEqual = true;
428      
429      //check Name
430      if (getUserID() != null) {
431        if (aUserID != null) {
432          if (getUserID().equals(aUserID)) {
433            //continue on
434          }
435          else {
436            objectsEqual = false;
437          }
438        }
439        else {
440          objectsEqual = false;
441        }
442      }
443      else {
444        if (aUserID != null) {
445          if (aUserID.equals("null"))  {
446            // continue on
447          }
448          else {
449            objectsEqual = false;
450          }
451        }
452      }
453 
454      return objectsEqual;
455    }
456    /**
457    * Set the password of the authorized user of the ftp address
458    *
459    * @param java.lang.String  a password in plain text format
460    */
461     
462    public void setPassword(String aPassword) 
463    {
464        if ( aPassword == null || aPassword.length() < 1 )
465         password = null;
466        else
467       password = aPassword;
468    }
469    /**
470    * Set the name of the firewall server in dnsname.domain.tld format
471    *
472    * @param java.lang.String  a server name
473    */
474     
475    public void setProxyHost(String aHost) {
476        if ( aHost == null || aHost.length() < 1 )
477           proxyHost = null;
478        else
479         proxyHost = aHost;
480    }
481    /**
482    * Set the password of an proxy user authorized for ftp access through the firewall
483    *
484    * @param java.lang.String  a password in clear text format
485    */
486     
487    public void setProxyPassword(String aPassword) {
488        if ( aPassword == null || aPassword.length() < 1 )
489             proxyPassword = null;
490        else
491          proxyPassword = aPassword;
492    }
493    /**
494    * Set the port that the firewall allows ftp traffic through
495    *
496    * @param int  a port number
497    */
498     
499    public void setProxyPort(int aPortNumber) {
500      proxyPort = aPortNumber;
501    }
502    /**
503    * Set the name of a proxy user authorized for ftp access through the firewall
504    *
505    * @param java.lang.String  a userID
506    */
507     
508    public void setProxyUserID(String aUserID) {
509        if ( aUserID == null || aUserID.length() < 1 )
510             proxyUserID = null;
511        else
512          proxyUserID = aUserID;
513    }
514 
515    /**
516     * Sets the oracle key. Enforce type safety.
517     * @param the key to set
518     */
519    public void setKey(SettingKey key)
520    {
521       this.key = (FtpAddressKey)key;
522    }
523 
524    /**
525    * Set the initial directory or directory path assigned once a user successfully logs into an ftp server 
526    *
527    * @param java.lang.String  a directory
528    */
529     
530    public void setRemoteDirectory(String aDirectory) {
531        if ( aDirectory == null || aDirectory.length() < 1 )
532             remoteDirectory = null;
533        else
534          remoteDirectory = aDirectory;
535    }
536    /**
537    * Set the id of an authorized user of the ftp server
538    *
539    * @param java.lang.String   a userid
540    */
541     
542    public void setUserID(String aUserID) {
543        if ( aUserID == null || aUserID.length() < 1 )
544             userid = null;
545        else
546          userid = aUserID;
547    }
548    /**
549    * Return the contents of the instance as a String.  This method is strictly for use by testing classes <br>
550    * and should not be called by business objects
551    *
552    * @return java.lang.String  - String representation of FtpAddressData contents
553    */
554     
555    public String toString() {
556      String t_lineSeparator = System.getProperty("line.separator", "\n");
557      
558      StringBuffer t_roFtpDataContents = new StringBuffer(t_lineSeparator);
559        
560      t_roFtpDataContents.append("Class: FtpAddressData");
561      t_roFtpDataContents.append(t_lineSeparator);
562      
563      t_roFtpDataContents.append(super.toString());
564 
565 
566      t_roFtpDataContents.append("UserID: ");
567      t_roFtpDataContents.append(getUserID());
568      t_roFtpDataContents.append(t_lineSeparator);
569        
570      t_roFtpDataContents.append("Password: ");
571      t_roFtpDataContents.append(getPassword());
572      t_roFtpDataContents.append(t_lineSeparator);
573        
574      t_roFtpDataContents.append("Remote Directory: ");
575      t_roFtpDataContents.append(getRemoteDirectory());    
576      t_roFtpDataContents.append(t_lineSeparator);
577 
578      t_roFtpDataContents.append("ProxyUserID: ");
579      t_roFtpDataContents.append(getProxyUserID());
580      t_roFtpDataContents.append(t_lineSeparator);
581      
582      t_roFtpDataContents.append("ProxyHost: ");
583      t_roFtpDataContents.append(getProxyHost());
584      t_roFtpDataContents.append(t_lineSeparator);
585      
586      t_roFtpDataContents.append("ProxyPassword: ");
587      t_roFtpDataContents.append(getProxyPassword());
588      t_roFtpDataContents.append(t_lineSeparator);
589 
590      t_roFtpDataContents.append("ProxyPort: ");
591      t_roFtpDataContents.append(getProxyPort());  
592      t_roFtpDataContents.append(t_lineSeparator);
593      
594      return t_roFtpDataContents.toString();
595    }
596 }  // end of class