1 /* 2 * Copyright (c) 2002-2022, 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.portal.business.user.authentication; 35 36 import fr.paris.lutece.portal.business.user.AdminUser; 37 38 import java.util.Collection; 39 40 import javax.security.auth.login.LoginException; 41 42 import javax.servlet.http.HttpServletRequest; 43 44 /** 45 * This Interface defines all methods required by an authentication service password is not valid 46 */ 47 public interface AdminAuthentication 48 { 49 /** 50 * Gets the Authentification service name 51 * 52 * @return The Service Name 53 */ 54 String getAuthServiceName( ); 55 56 /** 57 * Gets the Authentification type 58 * 59 * @param request 60 * The HTTP request 61 * @return The type of authentication 62 */ 63 String getAuthType( HttpServletRequest request ); 64 65 /** 66 * Checks the login 67 * 68 * @param strAccessCode 69 * The username 70 * @param strUserPassword 71 * The user's password 72 * @param request 73 * The HttpServletRequest 74 * @return The login 75 * @throws LoginException 76 * The Login Exception 77 */ 78 AdminUser login( final String strAccessCode, final String strUserPassword, HttpServletRequest request ) throws LoginException; 79 80 /** 81 * logout the user 82 * 83 * @param user 84 * The user 85 */ 86 void logout( AdminUser user ); 87 88 /** 89 * This method create an anonymous user 90 * 91 * @return A AdminUser object corresponding to an anonymous user 92 */ 93 AdminUser getAnonymousUser( ); 94 95 /** 96 * Indicates that the user should be already authenticated by an external authentication service (ex : Web Server authentication). 97 * 98 * @return true if the authentication is external, false if the authentication is provided by the Lutece portal. 99 */ 100 boolean isExternalAuthentication( ); 101 102 /** 103 * 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 104 * if the authentication service is not based on Http authentication. 105 * 106 * @param request 107 * The HTTP request 108 * @return Returns A Lutece User 109 */ 110 AdminUser getHttpAuthenticatedUser( HttpServletRequest request ); 111 112 /** 113 * Returns the Login page URL of the Authentication Service 114 * 115 * @return The URL 116 */ 117 String getLoginPageUrl( ); 118 119 /** 120 * Returns the password modification page URL of the Authentication Service 121 * 122 * @return The URL 123 */ 124 String getChangePasswordPageUrl( ); 125 126 /** 127 * Returns the DoLogin URL of the Authentication Service 128 * 129 * @return The URL 130 */ 131 String getDoLoginUrl( ); 132 133 /** 134 * Returns the DoLogout URL of the Authentication Service 135 * 136 * @return The URL 137 */ 138 String getDoLogoutUrl( ); 139 140 /** 141 * Returns the new account page URL of the Authentication Service 142 * 143 * @return The URL 144 */ 145 String getNewAccountPageUrl( ); 146 147 /** 148 * Returns the view account page URL of the Authentication Service 149 * 150 * @return The URL 151 */ 152 String getViewAccountPageUrl( ); 153 154 /** 155 * Returns the lost password URL of the Authentication Service 156 * 157 * @return The URL 158 */ 159 String getLostPasswordPageUrl( ); 160 161 /** 162 * Returns the lost login URL of the Authentication Service 163 * 164 * @return The URL 165 */ 166 String getLostLoginPageUrl( ); 167 168 /** 169 * get the list of user to display a list for selection in the main user management page 170 * 171 * @param strLastName 172 * The last name 173 * @param strFirstName 174 * The first name 175 * @param strEmail 176 * The email 177 * @return the collection of available users 178 */ 179 Collection<AdminUser> getUserList( String strLastName, String strFirstName, String strEmail ); 180 181 /** 182 * Get user data 183 * 184 * @param strAccessCode 185 * The access code (login) 186 * @return The admin User 187 */ 188 AdminUser getUserPublicData( String strAccessCode ); 189 }