Question

I am using the HDIV Web Application Security Framework for a java web application. Every new web-page-request generates hdiv-internal security information that is cached and used for security checks.

I have the following szenario:

I have one order page that pops up a confirmation-page for 2 seconds when something was added to or removed from the cart.

after 50 popups the the underlaying order page is removed from the cache and therefor an error occurs in the app.

does anybody know how to influence the hdiv cache-removal strategy to keep the basepage alive?

One way around is to increase org.hdiv.session.StateCache.maxSize from 50 to 500.

but this would only cure the symptoms not the underlying cause.

Update:

using @rbelasko solution I succeded to use the original org.hdiv.session.StateCache to change the maxSize to 20 and verified in the debug-log that the cachentries are dismissed after 20 entries.

When I changed it to use my own implementation it didn-t work

Bean definition

<bean id="cache" class="com.mycompany.session.StateCacheTest" singleton="false" 
  init-method="init">
    <property name="maxSize">
        <value>20</value>
    </property>
</bean>

My own class

public class StateCacheTest extends StateCache
{
    private static final Log log = LogFactory.getLog(StateCacheTest.class);

    public StateCacheTest()
    {
        log.debug("StateCache()");
    }

    @Override
    public void setMaxSize(final int maxSize)
    {
        super.setMaxSize(maxSize);

        if (log.isDebugEnabled())
        {
            log.debug("setMaxSize to " + maxSize);
        }
    }
}

In the debug-log were no entries from StateCacheTest

Any ideas?

Update 2:

While i was not able to load a different IStateCache implementation via spring i was able to make this error less likely using

<hdiv:config ... maxPagesPerSession="200" ... />

the bean-settings definition

<property name="maxSize">
    <value>20</value>
</property>

had no effect on the cachesize in my system.

Was it helpful?

Solution

You could create a custom IStateCache interface implementation.

Using the HDIV explicit configuration (not using HDIV's new custom schema) this is the default configuration for "cache" bean:

<bean id="cache" class="org.hdiv.session.StateCache" singleton="false" 
  init-method="init">
    <property name="maxSize">
        <value>200</value>
    </property>
</bean>

You could create your own implementation and implement the strategy that fits your requirements.

Regards,

Roberto

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top