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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:47:07+00:00 2026-05-29T15:47:07+00:00

Spring Security 3.1 has a nifty and convenient way to include the desired hash

  • 0

Spring Security 3.1 has a nifty and convenient way to include the desired hash in the XML configuration, which works like a charm:

<bean id="securityDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/myDataSource"/>
    <property name="resourceRef" value="true"/>
</bean>

<bean id="encoder" class="org.springframework.security.crypto.password.StandardPasswordEncoder" />

<security:authentication-manager>
    <security:authentication-provider>
        <security:password-encoder ref="encoder" />
        <security:jdbc-user-service 
            data-source-ref="securityDataSource"
            authorities-by-username-query="SELECT username, authority FROM user_roles WHERE username = ?"
            users-by-username-query="SELECT username, password, enabled FROM users WHERE username = ?"
        />        
    </security:authentication-provider>
</security:authentication-manager>

I took a look at this StandardPasswordEncoder class, which has two applicable public methods: encode() and matches(). The matches() method is presumably used by spring to compare the hashed version of the inputed password with the hashed password in the database. The encode() method seems to be used to generate the hashed string to store in the database. I assume you could use this to generate or change the password at will.

My question is this: given a completely legitimate reason to do so, how difficult (or is it at all possible) would it be to substitute this hash with a two-way encryption method? I don’t want to sacrifice all of the power and convenience that this spring security configuration offers, but it is necessary (per the business users) to have access to the plain text password at will.

  • 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-29T15:47:08+00:00Added an answer on May 29, 2026 at 3:47 pm

    As long as you provide an implementation of the PasswordEncoder interface Spring Security will be happy. It won’t care whether the passwords are hashed or reversibly encrypted.

    You would of course then need to give your implementation access to the key in order to verify passwords. That would be an additional configuration headache and security risk. An alternative would be to encrypt it using an asymmetric key but also use a hash as described here.

    So no, it’s not difficult. Whether it’s a good idea or not is another matter. I’d be curious to know what the business requirement is.

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

Sidebar

Related Questions

I'm using Spring Security which works great to make sure that a user has
I have to implement a spring security piece which has more than 1 parameter
I have implemented spring-security in my application, my spring-security.xml has following form-login tag. <form-login
I have integrated spring security plugin with my grails application, which has hibernate as
Spring security has a nice feature, it remembers the url of request resource and
I'm new to Spring Security. How do I add an event listener which will
I'm using Spring Security 3.0.2 and I can't find a way to load roles
When using spring security, specifically with @notation; what is the proper way to access
I have a website which uses Spring Security. I have realized that when I
We're developing an app (using Grails Spring Security (formerly Acegi)) in which we'll have

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.