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 8062549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:42:27+00:00 2026-06-05T10:42:27+00:00

I am using two different web application deployed in the same tomcat instance. One

  • 0

I am using two different web application deployed in the same tomcat instance. One of web application and another one is REST services. When user logged into the web application and calls the REST service, REST should authenticate with the user logged in using the web application. How can i implement SSO in tomcat> If anyone have implemented it, please help mw.

Update:
I have implemented the Spring Security and J2EEPreAuthentication mechanism in my first web application. THis application invokes the second application (REST services) using the DOJO (JavaScript Framework).

Update:
I have found the solution. Please read my answer below.

  • 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-05T10:42:29+00:00Added an answer on June 5, 2026 at 10:42 am

    We can implement the SSO between traditional web application and non web based application like the RESTful web services. This example shows the sample code for implementing the SSO between web application and RESTful web services. The following is the configuration in the spring-security.xml file

    <security:http create-session="never" use-expressions="true" 
                       auto-config="false" 
                       entry-point-ref="preAuthenticatedProcessingFilterEntryPoint" >
    
            <security:intercept-url pattern="/**" access="permitAll"/>
            <security:intercept-url pattern="/admin/**" access="hasRole('tomcat')"/>
            <security:intercept-url pattern="/**" access="hasRole('tomcat')"/>
            <security:custom-filter position="PRE_AUTH_FILTER" ref="preAuthFilter"/>
            <!-- Required for Tomcat, will prompt for username / password twice otherwise -->
            <security:session-management session-fixation-protection="none"/>
        </security:http>
    
        <bean id="preAuthenticatedProcessingFilterEntryPoint"
                    class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/>
    
        <bean id="preAuthFilter"
                    class="org.springframework.security.web.authentication.preauth.j2ee.J2eePreAuthenticatedProcessingFilter">
            <property name="authenticationManager" ref="appControlAuthenticationManager"/>
            <property name="authenticationDetailsSource"
                            ref="j2eeBasedPreAuthenticatedWebAuthenticationDetailsSource"/>
        </bean> 
    
        <security:authentication-manager alias="appControlAuthenticationManager">
            <security:authentication-provider ref="preAuthenticatedAuthenticationProvider"/>
        </security:authentication-manager>
    
        <bean id="preAuthenticatedAuthenticationProvider"
                    class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider">
            <property name="preAuthenticatedUserDetailsService" ref="inMemoryAuthenticationUserDetailsService"/>
        </bean>
    
        <bean id="j2eeBasedPreAuthenticatedWebAuthenticationDetailsSource"
                    class="org.springframework.security.web.authentication.preauth.j2ee.J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource">
            <property name="mappableRolesRetriever" ref="webXmlMappableAttributesRetriever"/>
            <property name="userRoles2GrantedAuthoritiesMapper" ref="simpleAttributes2GrantedAuthoritiesMapper"/>
        </bean>
    
        <bean id="webXmlMappableAttributesRetriever"
                    class="org.springframework.security.web.authentication.preauth.j2ee.WebXmlMappableAttributesRetriever"/>
    
        <bean id="simpleAttributes2GrantedAuthoritiesMapper"
                    class="org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper">
            <property name="attributePrefix" value=""/>
        </bean>
    
        <bean id="inMemoryAuthenticationUserDetailsService"
                    class="com.org.InMemoryAuthenticationUserDetailsService"/> 
    

    The above code is in the web application. Also the same code can be in the REST project’s spring security xml file. Add the following code into the web.xml file:

    <security-constraint>
            <web-resource-collection>
                <web-resource-name>Wildcard means whole app requires authentication</web-resource-name>
                <url-pattern>/*</url-pattern>
                <http-method>GET</http-method>
                <http-method>POST</http-method>
            </web-resource-collection>
            <auth-constraint>
                <role-name>tomcat</role-name>
            </auth-constraint>
    
            <user-data-constraint>
                <!-- transport-guarantee can be CONFIDENTIAL, INTEGRAL, or NONE -->
                <transport-guarantee>NONE</transport-guarantee>
            </user-data-constraint>
        </security-constraint>
        <login-config>
            <auth-method>FORM</auth-method>
            <form-login-config>
                <form-login-page>/login.jsp</form-login-page>
                <form-error-page>/error.jsp</form-error-page>
            </form-login-config>
        </login-config>
    

    The above code should be only in the normal web application. Then enable the SSO valve in the tomcat’s server.xml file. Tomcat uses the cookie based SSO login. The session ids are stored in the cookies. If your browser disabled the cookie, then SSO will not work.

    Hope this explanation helps.

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

Sidebar

Related Questions

If i had two different application running under the same solution but using different
I have two web application hosted on different server.For eg. one is main application
I'm using two different version of php on two different OS's. One is 5.2.9
I am conditionally using two different url patterns, mean on one URL I am
If one Servlet is mapped twice, using two different names (as shown bellow) how
I am trying to share two different using one shared memory block using the
I'm working on a web application for Apache Tomcat. I'm using a class called
For a limited time, we have to serve the same Tomcat 6 web application
In my silverlight application I have two wcf services, that used to be one,
We host several instances of our web application on four different servers. Two of

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.