4a6b43bc6bc493bfb266458f6639d5347516e5c1
[portal/sdk.git] /
1 /*-
2  * ================================================================================
3  * ECOMP Portal SDK
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 package org.openecomp.portalsdk.core.onboarding.listener;
21
22 import java.io.Serializable;
23
24 import javax.servlet.http.HttpSession;
25 import javax.servlet.http.HttpSessionBindingEvent;
26 import javax.servlet.http.HttpSessionBindingListener;
27
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30 import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
31
32 public class PortalTimeoutBindingListener implements HttpSessionBindingListener, Serializable {
33
34         private final Log logger = LogFactory.getLog(getClass());
35
36         private static final long serialVersionUID = 1L;
37
38         @Override
39         public void valueBound(HttpSessionBindingEvent event) {
40                 final HttpSession session = event.getSession();
41                 PortalTimeoutHandler.sessionMap.put((String) session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID),
42                                 session);
43         }
44
45         @Override
46         public void valueUnbound(HttpSessionBindingEvent event) {
47                 final HttpSession session = event.getSession();
48                 String portalJSessionId = (String) session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID);
49                 logger.debug(portalJSessionId + " getting removed");
50                 PortalTimeoutHandler.sessionMap.remove(portalJSessionId);
51         }
52
53 }