Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

LogoutPage.java 1.8KB

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