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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:26:06+00:00 2026-06-11T17:26:06+00:00

I’m new to Spring Security and I’ve been reading the API and the Javadocs

  • 0

I’m new to Spring Security and I’ve been reading the API and the Javadocs and I believe I need help regarding my issue.

So far, based from trial and error, what I’ve observed was throwing an exception prompts the authenticate method to automatically redirect to the Login Failure Handler. From there, it was easy redirecting and customizing the flow of the failed authentication. However, when it comes to logging in successfully, I can’t seem to pass anything to the Login Success Handler other than the HttpServletRequest, HttpServletResponse, Authentication objects.

My login success has two scenarios:

  1. Logging in successfully.

  2. New user logging in should be redirected to the change password page.

Here are some questions:

  1. Is it okay to call request.setParameter(“status”, “FOR_CHANGE_PASSWORD”) in this case? Is it safe?

  2. Should I add a “CHANGE_PASSWORD” authority? Is this good practice?

My problem is that I do not want to call the userService method in my LoginAuthenticator then call it again on my Login Success Handler just to retrieve the status of the user. Any work arounds?

public class LoginAuthenticator implements AuthenticationProvider{
private static final Logger log = LoggerFactory.getLogger(LoginAuthenticator.class);
private static final List<GrantedAuthority> AUTHORITIES = new ArrayList<GrantedAuthority>();
@Autowired
UserService userService;

@Override
public Authentication authenticate(Authentication authentication)
        throws AuthenticationException {
    log.info("Authenticating...");   

    log.debug("Username: {}" , authentication.getPrincipal());
    log.debug("Password: {}" , (String) authentication.getCredentials()); 


    WSResponse response = userService.authenticateLogin(username, password);


    //User log-in failure
    if(response.getResponseCode != 200){  

          if(response.getResponseStatus.equals("BAD CREDENTIALS")){
             throw new BadCredentialsException("Bad Credentials");  
          }
          else{
             throw new AccountStatusException("Account is locked")
          } 
    } 
    else{
        log.info("User credentials are valid... logging in");
        AUTHORITIES.add(new SimpleGrantedAuthority("USER"));
        return new UsernamePasswordAuthenticationToken(authentication.getPrincipal(),          (String) authentication.getCredentials(), AUTHORITIES);

    } 


}

Any more suggestions would be great.

  • 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-11T17:26:07+00:00Added an answer on June 11, 2026 at 5:26 pm

    A typical approach is to store all necessary information about the logged in user in its Authentication.

    For example, standard AuthenticationProviders such as DaoAuthenticationProvider store an implementation of UserDetails as a principal when constructing Authentication object after successful authentication, and application developer can provide its own subclass of UserDetails that includes necessary information. You can implement it in the same way.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I need a function that will clean a strings' special characters. I do NOT

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.