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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:31:30+00:00 2026-06-07T18:31:30+00:00

Summary How do you get the session of a web service client using spring

  • 0

Summary

How do you get the session of a web service client using spring web services and spring security?

Details

After submitting

<form method="POST" action="<c:url value="/j_spring_security_check" />">...</form>

I’ve noticed that you can:

public class MyUserDetailsService implements UserDetailsService {}

Which will allow you to override methods like loadUserByUsername(String username) therefore being able to retrieve the submitted username and do a database lookup to return a user object.

The issue I have, however, is that I’m unsure where SecurityContextHolder gets set. I’m able to get the user object by using this line of code:

User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

But I’m not sure how it gets set in the first place. I would like to know the flow after submitting the above-mentioned form so that I can identify how SecurityContextHolder gets set.

The reason why I want to know this is because I want to use it as a “session” for web service client authentication instead of having the client resubmit credentials with every request.


Spring Version: 3.0.2.RELEASE

  • 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-07T18:31:33+00:00Added an answer on June 7, 2026 at 6:31 pm

    /j_spring_security_check is handled by the UsernamePasswordAuthenticationFilter which extends AbstractAuthenticationFilter. The security context is set in the latter’s successfulAuthentication method.

    However, web-service clients are usually stateless and would be more likely to use something like Basic authentication with a shared secret. I’m not sure there would be much benefit in rolling your own session system based on the security context contents. If you are worried about performance then you could use a cache of authentication information on the server.

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

Sidebar

Related Questions

Summary To get my site running smoothly on a 64bit server platform, using IIS
Where can I get a summary of differences between ActionScript 3.0 strict and standard
Summary: does anyone know how to get @PreDestroy to get triggered on recycling\ timeout
Summary I am after some advice on the easiest way to analyze simple data
Summary A parent can have many children. How do you write a service such
I have a service layer returning a collection of entities : /// <summary> ///
My question is about this summary on session fixation: Alice has an account at
Quick summary Pinging back to a webservice in ajax from the client keeps the
Summary I'm a seasoned programmer with years of experience in Windows Forms development using
I'm struggling to get a $.ajax call to correctly send some form data to

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.