001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.servlet;
016    
017    import java.util.Enumeration;
018    
019    import javax.servlet.ServletContext;
020    import javax.servlet.http.HttpSession;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class HttpSessionWrapper implements HttpSession {
026    
027            public HttpSessionWrapper(HttpSession session) {
028                    _session = session;
029            }
030    
031            @Override
032            public boolean equals(Object obj) {
033                    if (obj instanceof HttpSessionWrapper) {
034                            HttpSessionWrapper sessionWrapper = (HttpSessionWrapper)obj;
035    
036                            obj = sessionWrapper.getWrappedSession();
037                    }
038    
039                    return _session.equals(obj);
040            }
041    
042            @Override
043            public Object getAttribute(String name) {
044                    return _session.getAttribute(name);
045            }
046    
047            @Override
048            public Enumeration<String> getAttributeNames() {
049                    return _session.getAttributeNames();
050            }
051    
052            @Override
053            public long getCreationTime() {
054                    return _session.getCreationTime();
055            }
056    
057            @Override
058            public String getId() {
059                    return _session.getId();
060            }
061    
062            @Override
063            public long getLastAccessedTime() {
064                    return _session.getLastAccessedTime();
065            }
066    
067            @Override
068            public int getMaxInactiveInterval() {
069                    return _session.getMaxInactiveInterval();
070            }
071    
072            @Override
073            public ServletContext getServletContext() {
074                    return _session.getServletContext();
075            }
076    
077            /**
078             * @deprecated As of 6.1.0
079             */
080            @Deprecated
081            @Override
082            public javax.servlet.http.HttpSessionContext getSessionContext() {
083                    return _session.getSessionContext();
084            }
085    
086            /**
087             * @deprecated As of 6.1.0
088             */
089            @Deprecated
090            @Override
091            public Object getValue(String name) {
092                    return _session.getValue(name);
093            }
094    
095            /**
096             * @deprecated As of 6.1.0
097             */
098            @Deprecated
099            @Override
100            public String[] getValueNames() {
101                    return _session.getValueNames();
102            }
103    
104            public HttpSession getWrappedSession() {
105                    return _session;
106            }
107    
108            @Override
109            public int hashCode() {
110                    return _session.hashCode();
111            }
112    
113            @Override
114            public void invalidate() {
115                    _session.invalidate();
116            }
117    
118            @Override
119            public boolean isNew() {
120                    return _session.isNew();
121            }
122    
123            /**
124             * @deprecated As of 6.1.0
125             */
126            @Deprecated
127            @Override
128            public void putValue(String name, Object value) {
129                    _session.putValue(name, value);
130            }
131    
132            @Override
133            public void removeAttribute(String name) {
134                    _session.removeAttribute(name);
135            }
136    
137            /**
138             * @deprecated As of 6.1.0
139             */
140            @Deprecated
141            @Override
142            public void removeValue(String name) {
143                    _session.removeValue(name);
144            }
145    
146            @Override
147            public void setAttribute(String name, Object value) {
148                    _session.setAttribute(name, value);
149            }
150    
151            @Override
152            public void setMaxInactiveInterval(int interval) {
153                    _session.setMaxInactiveInterval(interval);
154            }
155    
156            private final HttpSession _session;
157    
158    }