View Javadoc
1   /*
2    * This file is part of Waarp Project (named also Waarp or GG).
3    *
4    *  Copyright (c) 2019, Waarp SAS, and individual contributors by the @author
5    *  tags. See the COPYRIGHT.txt in the distribution for a full listing of
6    * individual contributors.
7    *
8    *  All Waarp Project is free software: you can redistribute it and/or
9    * modify it under the terms of the GNU General Public License as published by
10   * the Free Software Foundation, either version 3 of the License, or (at your
11   * option) any later version.
12   *
13   * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
14   * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15   * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16   *
17   *  You should have received a copy of the GNU General Public License along with
18   * Waarp . If not, see <http://www.gnu.org/licenses/>.
19   */
20  package org.waarp.common.file;
21  
22  import org.waarp.common.command.NextCommandReply;
23  import org.waarp.common.command.exception.Reply421Exception;
24  import org.waarp.common.command.exception.Reply530Exception;
25  
26  /**
27   * Interface for Authentication
28   */
29  public interface AuthInterface {
30    /**
31     * @return the Ftp SessionInterface
32     */
33    SessionInterface getSession();
34  
35    /**
36     * @param user the user to set
37     *
38     * @return (NOOP, 230) if the user is OK, else return the following command
39     *     that must follow (usually PASS) and
40     *     the associated reply
41     *
42     * @throws Reply421Exception if there is a problem during the
43     *     authentication
44     * @throws Reply530Exception if there is a problem during the
45     *     authentication
46     */
47    NextCommandReply setUser(String user)
48        throws Reply421Exception, Reply530Exception;
49  
50    /**
51     * @return the user
52     */
53    String getUser();
54  
55    /**
56     * @param password the password to set
57     *
58     * @return (NOOP, 230) if the Password is OK, else return the following
59     *     command that must follow (usually ACCT)
60     *     and the associated reply
61     *
62     * @throws Reply421Exception if there is a problem during the
63     *     authentication
64     * @throws Reply530Exception if there is a problem during the
65     *     authentication
66     */
67    NextCommandReply setPassword(String password)
68        throws Reply421Exception, Reply530Exception;
69  
70    /**
71     * Is the current Authentication OK for full identification. It must be true
72     * after a correct sequence of
73     * identification: At most, it is true when setAccount is OK. It could be
74     * positive before (user name only,
75     * user+password only).<br>
76     * In the current implementation, as USER+PASS+ACCT are needed, it will be
77     * true only after a correct ACCT.
78     *
79     * @return True if the user has a positive login, else False
80     */
81    boolean isIdentified();
82  
83    /**
84     * @return True if the current authentication has an admin right (shutdown,
85     *     bandwidth limitation)
86     */
87    boolean isAdmin();
88  
89    /**
90     * Is the given complete relative Path valid from Authentication/Business
91     * point of view.
92     *
93     * @param newPath
94     *
95     * @return True if it is Valid
96     */
97    boolean isBusinessPathValid(String newPath);
98  
99    /**
100    * Return the relative path for this account according to the Business
101    * (without true root of mount).<br>
102    *
103    * @return Return the relative path for this account
104    */
105   String getBusinessPath();
106 
107   /**
108    * Return the mount point
109    *
110    * @return the mount point
111    */
112   String getBaseDirectory();
113 
114   /**
115    * Return the relative path from a file (without mount point)
116    *
117    * @param file (full path with mount point)
118    *
119    * @return the relative path from a file
120    */
121   String getRelativePath(String file);
122 
123   /**
124    * Clean object
125    */
126   void clear();
127 }