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.gateway.kernel.session;
21  
22  import org.waarp.common.command.NextCommandReply;
23  import org.waarp.common.file.SessionInterface;
24  
25  /**
26   * Allow all default implementation
27   * <p>
28   * If an authentication is needed, then it will have to use an implementation
29   * compatible with the Security of
30   * the IT that needs it.
31   */
32  public class DefaultHttpAuth implements HttpAuthInterface {
33    /**
34     * User name
35     */
36    protected String user = "user";
37  
38    /**
39     * Password
40     */
41    protected String password = "password"; // NOSONAR
42  
43    /**
44     * Account name
45     */
46    protected String account = "account";
47  
48    /**
49     * Is Identified
50     */
51    protected final boolean isIdentified;
52  
53    /**
54     * SessionInterface
55     */
56    protected final SessionInterface session;
57  
58    /**
59     * @param session
60     */
61    public DefaultHttpAuth(final SessionInterface session) {
62      this.session = session;
63      isIdentified = true;
64    }
65  
66    @Override
67    public final SessionInterface getSession() {
68      return session;
69    }
70  
71    @Override
72    public final NextCommandReply setUser(final String user) {
73      this.user = user;
74      return null;
75    }
76  
77    @Override
78    public final String getUser() {
79      return user;
80    }
81  
82    @Override
83    public final NextCommandReply setPassword(final String password) {
84      this.password = password;
85      return null;
86    }
87  
88    @Override
89    public final boolean isIdentified() {
90      return isIdentified;
91    }
92  
93    @Override
94    public final boolean isAdmin() {
95      return false;
96    }
97  
98    @Override
99    public final boolean isBusinessPathValid(final String newPath) {
100     return true;
101   }
102 
103   @Override
104   public final String getBusinessPath() {
105     return "";
106   }
107 
108   @Override
109   public final String getBaseDirectory() {
110     return "/";
111   }
112 
113   @Override
114   public final String getRelativePath(final String file) {
115     return file;
116   }
117 
118   @Override
119   public final void clear() {
120     // nothing
121   }
122 
123   @Override
124   public final String getAccount() {
125     return account;
126   }
127 
128   @Override
129   public final NextCommandReply setAccount(final String account) {
130     this.account = account;
131     return null;
132   }
133 
134   @Override
135   public final CommandExecutorInterface getCommandExecutor() {
136     // TO DO Auto-generated method stub
137     return null;
138   }
139 
140 }