How to log operations logs to meet security audit requirements when Tomcat session is over

Source: Internet
Author: User

Known. In a real Web application, session management typically uses the Web container session management feature.

Using Tomcat to do webserver is also the case, and from a security standpoint, try to avoid changing and interfering with the session management capabilities of the Web container.

The Tomcat session management feature is definitely more comprehensive and reliable than what we do ourselves, and Tomcat is maintained by the mainstream open source community. Have a dedicated team to develop and maintain. Once a security breach is available, it can be repaired very quickly.


In the actual development, in order to meet the requirements of security audit. Once the Web application has a session logoff. The operation log should be logged. Logoff is generally divided into the operator active logoff, application detection to the exception attack active logoff session, timeout logoff session.

For active logoff and detection to an attack logoff session, the operation log can be very easy to record. Meet the requirements.

However, it is logged off for a timeout session. A lot of people feel no way to achieve, a more common method is to develop a heartbeat program, through the client page constantly send the heartbeat to the server, the server through the thread to receive heartbeat and rotation to time out, to log the operation log.

This allows you to record the effect of the Operation log. However, client to the server more than a lot of requests, once the system concurrency is very high, service-side business pressure will be added. is not a good way to handle it.


WebEasy can configure the session time-out. Should you be able to listen for session creation and logoff? The answer is yes, Tomcat can really be done by Httpsessionlistener. the session creation event occurs every time a new session is created. Similarly, a session failure event occurs at each time a session fails.



This interface also includes only two methods. corresponding to the creation and invalidation of the session, respectively:
public void sessioncreated (httpsessionevent se);

public void sessiondestroyed (httpsessionevent se);

So we just have to implement Httpsessionlistener. The ability to log operations logs is implemented in the Sessiondestroyed method.


In detail, we need to configure the Listener class, code examples and Web. XML configuration for the following:

1) Code example

public class SessionManager implements httpsessionlistener{public    void sessioncreated (httpsessionevent se)    {        // ....    }    public void sessiondestroyed (httpsessionevent se)    {        //...    }}

2) Web. XML configuration
<session-config>  <session-timeout>30</session-timeout>  </session-config> < listener>  <listener-class>com.test.SessionManager</listener-class>  </listener>  

How to log operations logs to meet security audit requirements when Tomcat session is over

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.