View Javadoc
1   /*
2    * Copyright (c) 2002-2021, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.mylutece.authentication;
35  
36  import fr.paris.lutece.plugins.mylutece.web.MyLuteceApp;
37  import fr.paris.lutece.portal.service.security.LuteceAuthentication;
38  import fr.paris.lutece.portal.service.security.LuteceUser;
39  
40  import java.util.Collection;
41  
42  import javax.servlet.http.HttpServletRequest;
43  
44  /**
45   *
46   * PortalAuthentication : default authentication
47   */
48  public abstract class PortalAuthentication extends AbstractAuthentication
49  {
50      private static final String CONSTANT_PATH_ICON = "images/local/skin/plugins/mylutece/mylutece.png";
51  
52      /**
53       * Indicates that the user should be already authenticated by an external authentication service (ex : Web Server authentication).
54       * 
55       * @return true if the authentication is external, false if the authentication is provided by the Lutece portal.
56       */
57      public boolean isExternalAuthentication( )
58      {
59          return false;
60      }
61  
62      /**
63       *
64       * {@inheritDoc}
65       */
66      public boolean isDelegatedAuthentication( )
67      {
68          return false;
69      }
70  
71      /**
72       *
73       * {@inheritDoc}
74       */
75      public String getLoginPageUrl( )
76      {
77          return MyLuteceApp.getLoginPageUrl( );
78      }
79  
80      /**
81       *
82       * {@inheritDoc}
83       */
84      public String getDoLoginUrl( )
85      {
86          return MyLuteceApp.getDoLoginUrl( );
87      }
88  
89      /**
90       *
91       * {@inheritDoc}
92       */
93      public boolean findResetPassword( HttpServletRequest request, String strLogin )
94      {
95          return false;
96      }
97  
98      /**
99       * {@inheritDoc}
100      */
101     public String getResetPasswordPageUrl( HttpServletRequest request )
102     {
103         return MyLuteceApp.getResetPasswordUrl( request );
104     }
105 
106     /**
107      * Returns the new account page URL of the Authentication Service
108      * 
109      * @return The URL
110      */
111     public String getNewAccountPageUrl( )
112     {
113         return MyLuteceApp.getNewAccountUrl( );
114     }
115 
116     /**
117      * Returns the View account page URL of the Authentication Service
118      * 
119      * @return The URL
120      */
121     public String getViewAccountPageUrl( )
122     {
123         return MyLuteceApp.getViewAccountUrl( );
124     }
125 
126     /**
127      * {@inheritDoc}
128      */
129     @Override
130     public String getLostPasswordPageUrl( )
131     {
132         return MyLuteceApp.getLostPasswordUrl( );
133     }
134 
135     /**
136      * {@inheritDoc}
137      */
138     @Override
139     public String getLostLoginPageUrl( )
140     {
141         return MyLuteceApp.getLostLoginUrl( );
142     }
143 
144     /**
145      * Returns the disconnect URL of the Authentication Service
146      * 
147      * @return The URL
148      */
149     public String getDoLogoutUrl( )
150     {
151         return MyLuteceApp.getDoLogoutUrl( );
152     }
153 
154     /**
155      * Returns a Lutece user object if the user is already authenticated in the Http request. This method should return null if the user is not authenticated or
156      * if the authentication service is not based on Http authentication.
157      * 
158      * @param request
159      *            The HTTP request
160      * @return Returns A Lutece User
161      */
162     public LuteceUser getHttpAuthenticatedUser( HttpServletRequest request )
163     {
164         return null;
165     }
166 
167     /**
168      * Returns the access denied template
169      * 
170      * @return The template
171      */
172     public String getAccessDeniedTemplate( )
173     {
174         return MyLuteceApp.getAccessDeniedTemplate( );
175     }
176 
177     /**
178      * Returns the access controled template
179      * 
180      * @return The template
181      */
182     public String getAccessControledTemplate( )
183     {
184         return MyLuteceApp.getAccessControledTemplate( );
185     }
186 
187     /**
188      * Tells whether or not the authentication service can provide a list of all its users
189      * 
190      * @return true if the service can return a users list
191      */
192     public boolean isUsersListAvailable( )
193     {
194         return false;
195     }
196 
197     /**
198      * Returns all users managed by the authentication service if this feature is available.
199      * 
200      * @return A collection of Lutece users or null if the service doesn't provide a users list
201      */
202     public Collection<LuteceUser> getUsers( )
203     {
204         return null;
205     }
206 
207     /**
208      * Returns the user managed by the authentication service if this feature is available.
209      * 
210      * @param strUserLogin
211      *            user login
212      * @return A Lutece users or null if the service doesn't provide a user
213      */
214     public LuteceUser getUser( String strUserLogin )
215     {
216         // TODO add Methode getUser(ind userId) in classes LuteceAuthentication and Security service
217         return null;
218     }
219 
220     /**
221      * get all roles for this user : - user's roles - user's groups roles
222      *
223      * @param user
224      *            The user
225      * @return Array of roles
226      */
227     public String [ ] getRolesByUser( LuteceUser user )
228     {
229         return null;
230     }
231 
232     /**
233      * Return false
234      * 
235      * @see LuteceAuthentication#isMultiAuthenticationSupported()
236      * @return false
237      */
238     public boolean isMultiAuthenticationSupported( )
239     {
240         return false;
241     }
242 
243     /**
244      *
245      * {@inheritDoc}
246      */
247     public String getIconUrl( )
248     {
249         return CONSTANT_PATH_ICON;
250     }
251 
252     /**
253      *
254      * {@inheritDoc}
255      */
256     @Override
257     public String toString( )
258     {
259         return this.getName( );
260     }
261 
262     /**
263      *
264      * {@inheritDoc}
265      */
266     @Override
267     public void updateDateLastLogin( LuteceUser user, HttpServletRequest request )
268     {
269     }
270 }