commit | author | age
|
f13c4c
|
1 |
/*
|
JM |
2 |
* Copyright 2011 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 |
*/
|
1f9dae
|
16 |
package com.gitblit.wicket.pages;
|
87cc1e
|
17 |
|
a2ce62
|
18 |
import org.apache.wicket.protocol.http.WebRequest;
|
85c2e6
|
19 |
import org.apache.wicket.protocol.http.WebResponse;
|
JM |
20 |
|
ea094a
|
21 |
import com.gitblit.models.UserModel;
|
85c2e6
|
22 |
import com.gitblit.wicket.GitBlitWebSession;
|
87cc1e
|
23 |
|
a2ce62
|
24 |
public class LogoutPage extends BasePage {
|
87cc1e
|
25 |
|
JM |
26 |
public LogoutPage() {
|
a2ce62
|
27 |
super();
|
ea094a
|
28 |
GitBlitWebSession session = GitBlitWebSession.get();
|
JM |
29 |
UserModel user = session.getUser();
|
ec7ed8
|
30 |
app().authentication().logout(((WebRequest) getRequest()).getHttpServletRequest(),
|
JM |
31 |
((WebResponse) getResponse()).getHttpServletResponse(), user);
|
699e71
|
32 |
session.invalidate();
|
JM |
33 |
|
a2ce62
|
34 |
/*
|
LV |
35 |
* Now check whether the authentication was realized via the Authorization in the header.
|
|
36 |
* If so, it is likely to be cached by the browser, and cannot be undone. Effectively, this means
|
|
37 |
* that you cannot log out...
|
|
38 |
*/
|
|
39 |
if ( ((WebRequest)getRequest()).getHttpServletRequest().getHeader("Authorization") != null ) {
|
|
40 |
// authentication will be done via this route anyway, show a page to close the browser:
|
|
41 |
// this will be done by Wicket.
|
|
42 |
setupPage(null, getString("gb.logout"));
|
699e71
|
43 |
|
a2ce62
|
44 |
} else {
|
LV |
45 |
setRedirect(true);
|
|
46 |
setResponsePage(getApplication().getHomePage());
|
|
47 |
} // not via WWW-Auth
|
|
48 |
} // LogoutPage
|
87cc1e
|
49 |
} |