James Moger
2015-11-22 ed552ba47c02779c270ffd62841d6d1048dade70
commit | author | age
db4f6b 1 /*
JM 2  * Copyright 2013 gitblit.com.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.gitblit.manager;
17
18 import javax.servlet.http.HttpServletRequest;
19 import javax.servlet.http.HttpServletResponse;
20
6e3481 21 import com.gitblit.Constants.Role;
04a985 22 import com.gitblit.models.TeamModel;
db4f6b 23 import com.gitblit.models.UserModel;
bcc8a0 24 import com.gitblit.transport.ssh.SshKey;
db4f6b 25
04a985 26 public interface IAuthenticationManager extends IManager {
db4f6b 27
JM 28     /**
29      * Authenticate a user based on HTTP request parameters.
30      *
31      * Authentication by X509Certificate is tried first and then by cookie.
32      *
33      * @param httpRequest
34      * @return a user object or null
3a6499 35      * @since 1.4.0
db4f6b 36      */
JM 37     UserModel authenticate(HttpServletRequest httpRequest);
38
44e2ee 39     /**
bcc8a0 40      * Authenticate a user based on a ssh public key.
44e2ee 41      *
JM 42      * @param username
43      * @param key
44      * @return a user object or null
3a6499 45 *      * @since 1.5.0
44e2ee 46      */
bcc8a0 47     UserModel authenticate(String username, SshKey key);
e3b636 48
db4f6b 49     /**
JM 50      * Authenticate a user based on HTTP request parameters.
51      *
52      * Authentication by X509Certificate, servlet container principal, cookie,
53      * and BASIC header.
54      *
55      * @param httpRequest
56      * @param requiresCertificate
57      * @return a user object or null
3a6499 58      * @since 1.4.0
db4f6b 59      */
JM 60     UserModel authenticate(HttpServletRequest httpRequest, boolean requiresCertificate);
61
aa6d43 62     /**
JM 63      * Authenticate a user based on a username and password.
64      *
65      * @see IUserService.authenticate(String, char[])
66      * @param username
67      * @param password
0d7c65 68      * @param remoteIP 
aa6d43 69      * @return a user object or null
3a6499 70      * @since 1.4.0
aa6d43 71      */
0d7c65 72     UserModel authenticate(String username, char[] password, String remoteIP);
db4f6b 73
JM 74     /**
e97c01 75      * Return the UserModel for already authenticated user.
FB 76      *
77      * @see IUserService.authenticate(String, char[])
78      * @param username
79      * @return a user object or null
80      * @since 1.7.0
81      */
82     UserModel authenticate(String username);
83
84     /**
7ab32b 85      * Returns the Gitlbit cookie in the request.
JM 86      *
87      * @param request
88      * @return the Gitblit cookie for the request or null if not found
3a6499 89      * @since 1.4.0
7ab32b 90      */
JM 91     String getCookie(HttpServletRequest request);
92
93     /**
db4f6b 94      * Sets a cookie for the specified user.
JM 95      *
96      * @param response
97      * @param user
3a6499 98      * @since 1.4.0
db4f6b 99      */
ec7ed8 100     @Deprecated
db4f6b 101     void setCookie(HttpServletResponse response, UserModel user);
ec7ed8 102
JM 103     /**
104      * Sets a cookie for the specified user.
105      *
106      * @param request
107      * @param response
108      * @param user
109      * @since 1.6.1
110      */
111     void setCookie(HttpServletRequest request, HttpServletResponse response, UserModel user);
db4f6b 112
JM 113     /**
114      * Logout a user.
115      *
116      * @param user
3a6499 117      * @since 1.4.0
db4f6b 118      */
ec7ed8 119     @Deprecated
db4f6b 120     void logout(HttpServletResponse response, UserModel user);
JM 121
04a985 122     /**
ec7ed8 123      * Logout a user.
JM 124      *
125      * @param request
126      * @param response
127      * @param user
128      * @since 1.6.1
129      */
130     void logout(HttpServletRequest request, HttpServletResponse response, UserModel user);
131
132     /**
04a985 133      * Does the user service support changes to credentials?
JM 134      *
135      * @return true or false
3a6499 136      * @since 1.4.0
04a985 137      */
JM 138     boolean supportsCredentialChanges(UserModel user);
139
140     /**
141      * Returns true if the user's display name can be changed.
142      *
143      * @param user
144      * @return true if the user service supports display name changes
3a6499 145      * @since 1.4.0
04a985 146      */
JM 147     boolean supportsDisplayNameChanges(UserModel user);
148
149     /**
150      * Returns true if the user's email address can be changed.
151      *
152      * @param user
153      * @return true if the user service supports email address changes
3a6499 154      * @since 1.4.0
04a985 155      */
JM 156     boolean supportsEmailAddressChanges(UserModel user);
157
158     /**
159      * Returns true if the user's team memberships can be changed.
160      *
161      * @param user
162      * @return true if the user service supports team membership changes
3a6499 163      * @since 1.4.0
04a985 164      */
JM 165     boolean supportsTeamMembershipChanges(UserModel user);
166
167     /**
168      * Returns true if the team memberships can be changed.
169      *
170      * @param user
171      * @return true if the team memberships can be changed
3a6499 172      * @since 1.4.0
04a985 173      */
JM 174     boolean supportsTeamMembershipChanges(TeamModel team);
175
6e3481 176     /**
JM 177      * Returns true if the specified role can be changed.
178      *
179      * @param user
180      * @return true if the specified role can be changed
181      * @since 1.6.1
182      */
183     boolean supportsRoleChanges(UserModel user, Role role);
184
185     /**
186      * Returns true if the specified role can be changed.
187      *
188      * @param team
189      * @return true if the specified role can be changed
190      * @since 1.6.1
191      */
192     boolean supportsRoleChanges(TeamModel team, Role role);
193
db4f6b 194 }