View Javadoc
1   /*
2    * #%L
3    * Coser :: Web
4    * %%
5    * Copyright (C) 2011 Codelutin, Chemit Tony
6    * %%
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Affero General Public License as published by
9    * the Free Software Foundation, either version 3 of the License, or
10   * (at your option) any later version.
11   * 
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   * 
17   * You should have received a copy of the GNU Affero General Public License
18   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19   * #L%
20   */
21  
22  package fr.ifremer.coser.web.actions.auth;
23  
24  import fr.ifremer.coser.web.actions.common.AbstractCoserAction;
25  import org.apache.commons.logging.Log;
26  import org.apache.commons.logging.LogFactory;
27  import org.apache.struts2.convention.annotation.Result;
28  import org.apache.struts2.interceptor.SessionAware;
29  
30  import java.util.Map;
31  
32  /**
33   * Logout action.
34   * <p/>
35   * Last update : $Date$
36   * By : $Author$
37   *
38   * @author tchemit
39   * @version $Revision$
40   */
41  @Result(type = "redirect", location = "/index")
42  public class LogoutAction extends AbstractCoserAction implements SessionAware {
43  
44      private static final long serialVersionUID = 1L;
45  
46      /** Logger. */
47      private static final Log log = LogFactory.getLog(LogoutAction.class);
48  
49      protected transient Map<String, Object> session;
50  
51      @Override
52      public void setSession(Map<String, Object> session) {
53          this.session = session;
54      }
55  
56      @Override
57      public String execute() throws Exception {
58          Object login = session.remove(LoginInterceptor.SESSION_PARAMETER_LOGIN);
59          if (login != null) {
60              if (log.isInfoEnabled()) {
61                  log.info("Logout for user: " + login);
62              }
63          }
64          return SUCCESS;
65      }
66  }