Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8722011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:19:03+00:00 2026-06-13T07:19:03+00:00

I try to secure my struts 2 application with Spring Security 3.0.5. I declare

  • 0

I try to secure my struts 2 application with Spring Security 3.0.5.

I declare this in the web.xml :

      <!-- Tiles --> 
  <context-param> 
    <param-name> org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG </param-name> 
    <param-value>/WEB-INF/conf/tiles.xml</param-value> 
  </context-param> 
  <listener> 
    <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class> 
  </listener> 

<!-- Files defining SPRING ApplicationContext -->   
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/conf/spring-security.xml,/WEB-INF/conf/application.xml</param-value>
    </context-param>

    <context-param>
        <param-name>locatorFactorySelector</param-name>
        <param-value>classpath:/model/config/beans.xml</param-value>
    </context-param>
    <context-param>
        <param-name>parentContextKey</param-name>
        <param-value>context</param-value>
    </context-param>

    <!-- Filter for security -->
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- Struts 2 --> 
  <filter> 
    <filter-name>struts2</filter-name> 
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 
  </filter> 
  <filter-mapping> 
    <filter-name>struts2</filter-name> 
    <url-pattern>/*</url-pattern> 
  </filter-mapping> 
     <!-- Spring --> 


    <!-- Open session filter - binds a Hibernate Session to the thread for the entire processing of the request  -->
    <filter>
        <filter-name>HibernateFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
        <init-param>
              <param-name>sessionFactoryBeanName</param-name> 
              <param-value>hibernateSessionFactory</param-value>
        </init-param>
    </filter>

        <!-- Filter for Character Encoding -->
    <filter>
        <filter-name>CharacterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </filter>


    <!-- Mapping for pages to filter -->
    <filter-mapping>
        <filter-name>HibernateFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>CharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


<listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>


  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

Then in my struts.xml:

<struts> 
  <!-- internationalisation --> 
  <constant name="struts.custom.i18n.resources" value="messages" /> 
  <!-- intégration Spring --> 
  <constant name="struts.objectFactory.spring.autoWire" value="name" />

  <package name="searchMandate" namespace="/search" extends="struts-default, tiles-default"> 
   <action name="MandateSearchActionInit"  class="web.action.mandate.SearchAction" method="initSearch"> 
      <result name="input" type="tiles">search</result> 
      <result name="success" type="tiles">search</result> 
    </action> 
    </package>
     <package name="userProfile" namespace="/profile" extends="struts-default, tiles-default"> 
        <action name="ChangeProfileInit"  class="web.action.user.ProfileAction" method="loadProfile"> 
           <result name="input" type="tiles">updateProfile</result> 
         </action> 
    </package>
</struts> 

My spring-security.xml :

     <beans:bean id="springSecurityFilterChain" class="org.springframework.security.util.FilterChainProxy">
        <filter-chain-map path-type="ant">
            <filter-chain pattern="/**" filters="sif"/>
        </filter-chain-map>
    </beans:bean>

    <http use-expressions="true">
        <intercept-url pattern="/profile*" access="isAuthenticated()" />
        <intercept-url pattern="/search*" access="hasRole('SEARCH')"/>
        <form-login login-page="/login" default-target-url="/welcome"
            authentication-failure-url="/loginfailed" />
        <logout logout-success-url="/logout" />
    </http>



    <authentication-manager>
        <authentication-provider>
            <password-encoder ref="passwordEncoder" />
            <jdbc-user-service data-source-ref="dataSource"

                users-by-username-query="
                    select login,password, isactive 
                    from tuser where LOGIN=?" 

                authorities-by-username-query="
                    select u.login, ur.name from tuser u,tgroup g, trolegroup rg, trole ur 
                    where u.groupid = g.groupid and g.groupid=rg.groupid and rg.roleid=ur.roleid and u.login =?  " 

            />
        </authentication-provider>
    </authentication-manager>

I thought the security were in place reading “INFO 20-10 23:26:55,620 – Creating access control expression attribute ‘hasRole(‘SEARCH’)’ for /search*” as server startup. But when I access search/MandateSearchActionInit url, I go to the action without having been routed to the login page.
Has somebody the key?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:19:05+00:00Added an answer on June 13, 2026 at 7:19 am

    In fact the intercept-url patterns were wrong.
    For example for the search path the syntax should be :

    <intercept-url pattern="/search/**" access="hasRole('SEARCH')"/>
    

    No link with struts2 (spring security secures url and has no matter of what is behind).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Spring Security 3 along with Struts 2 and Tiles 2, I have a
I use spring-security to secure my web, when I'm learning it by spring-roo generated
I am a web developer that is very conscious of security and try and
Can I use Spring Security annotations in my ZKGrails composers to secure the ajax-callbacks,
I can create a secure, multi-tenant web app with Grails by : setup spring
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
Try this piece of code - public class WhitespaceTest { public static void main(String[]
try: html = urlopen('http://glbse.com/api/asset/' + asset.name) except: print 'error while updating the price of
try: recursive_function() except RuntimeError e: # is this a max. recursion depth exceeded exception?
At last i try Encryption and Compression Functions in mysql for secure password and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.