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

  • Home
  • SEARCH
  • 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 4332236
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:13:39+00:00 2026-05-21T10:13:39+00:00

How to proceed if I want to check if credentials are valid ? For

  • 0

How to proceed if I want to check if credentials are valid ?

For example, I want to be sure that username is valid (valid email, limited size and so on) so I can display the error to the user before even attempting to authenticate using Spring Security.

1) Make sure credentials are valid before authentication
2) Authenticate
3) Rock-n-roll

Btw, I’m using Spring Security 3.1.0 RC.

Thank you in advance for your help,
Adnan

Update:
Actually I’m talking about validation: making sure that username is in valid email format, or make sure that the passwords is at least 8 characters and so on.
Only when I’m sure that it is in “valid” format I will submit it to the Security authentication & authorization else I just want to display the login form again with error message (for example: “password must be at least 8 characters”).

  • 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-05-21T10:13:40+00:00Added an answer on May 21, 2026 at 10:13 am

    You may want to skip validation on login and only do validation on registration/edit profile/change password. When they attempt to login with a bad username/password it just won’t be found.

    I can see two ways to do what you want. Normally the login page POSTs to /j_spring_security_check with j_username and j_password. The UsernamePasswordAuthenticationFilter intercepts this POST and delegates to the AuthenticationManager and its AuthenticationProviders (usually the DaoAuthenticationProvider).

    If you really want to do validation before it hits any Spring Security code you will need to add a Filter before the UsernamePasswordAuthenticationFilter and do your validation there.

    Alternatively, subclass DaoAuthenticationProvider and override retreiveUser(). In retrieveUser() do your extra validation, throwing an exception if the validation fails.

    Configure your subclass as the authentication provider like so:

    <authentication-manager>
      <authentication-provider ref='myAuthenticationProvider'/>
    </authentication-manager> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that I want to achieve the following with. Check
I have PHP background and want to start learning C++. How should I proceed?
I want to create a XML editor (form view type) for iphone. Can anyone
This is a little wierd, but I want to check if connection to my
I am currently implementing a custom c# cache provider that I can plug in
I made a form with ajax email validation. My problem is that I need
I need something that takes a directory's contents and then proceeds to generate an
Well it's not really a problem but I check if the user exist and
In rails I could do something like this to make sure a user is
I have a SQL query where I want to insert multiple rows in single

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.