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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:05:17+00:00 2026-06-08T02:05:17+00:00

My application calls a web service during the Authentication process (as shown in code

  • 0

My application calls a web service during the Authentication process (as shown in code below).

How can I save some information in HttpSession during this process?
This information like customer-account-number will be used in various other places in the application after the user is logged in.
Is it possible to pass HttpSession parameter to the MyServiceManager’s static login method?

 public class MyAuthenticationManager implements AuthenticationProvider {

    @Override
    public boolean supports(Class<? extends Object> authentication) {
        return authentication.equals(UsernamePasswordAuthenticationToken.class);
    }

    @Override
    public Authentication authenticate(Authentication authentication) {
                    //MyServiceManager.login - makes a call to web service
        if(MyServiceManager.login(authentication.getName(),     authentication.getCredentials().toString(), XXX_HTTP_SESSION_XXX))
        {
            List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>  ();  
            authorities.add(new GrantedAuthorityImpl("ROLE_USER"));
            authorities.add(new GrantedAuthorityImpl("ROLE_SUPERVISOR"));
            return new UsernamePasswordAuthenticationToken(authentication.getName(), authentication.getCredentials(),authorities);
        }
        else
        {
            return null;
        }

    }
 }
  • 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-08T02:05:19+00:00Added an answer on June 8, 2026 at 2:05 am

    After breaking a lot of head on this issue, I was able to achive the objective using following work around.
    Getting hold of session is really not feasible in following method
    public Authentication authenticate(Authentication authentication)

    I created a class

    import java.security.Principal;
    
    public class UserInfo implements Principal{
    
    private String customerId;
    private String accountNumber;
    private String name;
    }
    

    The information which I wanted to store in session (like customerId, accountNumber etc), I saved it in userInfo object.
    and this object was passed to UsernamePasswordAuthenticationToken

    List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();  
    authorities.add(new GrantedAuthorityImpl("ROLE_USER"));
    authorities.add(new GrantedAuthorityImpl("ROLE_SUPERVISOR"));
    return new UsernamePasswordAuthenticationToken(**userInfo**, authentication.getCredentials(),authorities);
    

    This information is readily available in the user’s session using

    (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    

    I home this is a good enough way to tackle the problem.

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

Sidebar

Related Questions

My application calls a web-service using WCF. The call can fail for various reasons:
I've the following issue I've a windows application It calls a remote web service
I am creating an application which involves so many web-service calls. I am using
A C# client application we developed calls an external SOAP web service of a
I have an application that calls a web service (axis based) to get a
I am developing an application that calls a java web service (using Jersey1.8). I
I have an ASP.Net application that calls an Amazon Web Service to start a
I am trying to develop a client application that calls a RESTful web service.
Application is a C# .Net 3.5 WCF Service. I'd like during the build process
I have developed a small C# form application which calls a web service. Everything

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.