How do I encrypt a password insert it into the db and after the comparison when he will want to connect? - spring

How do I encrypt a password insert it into the db and after the comparison when he will want to connect?
I would use Spring security 3.1.
Link Doc Spring : http://docs.spring.io/spring-security/site/docs/3.1.4.RELEASE/reference/crypto.html Link API SPring security 3.1.4 : http://docs.spring.io/spring-security/site/docs/3.1.4.RELEASE/apidocs/

Hash the password and store it in database.. when login hash the password which enters and compare it with the password which is stored in database..
check this link.. may help you...
http://www.mkyong.com/spring-security/spring-security-password-hashing-example/

Related

Laravel encrypt password before storing on DB and decrypt it to use on email settings

I followed this tutorial to create dynamic email settings stored on db.
https://kayike.medium.com/enable-unique-and-dynamic-smtp-mail-settings-for-each-user-laravel-48e320d381ec
The only problem is that the password is not encrypted. I would like to encrypt it before storing on db and decrypt it before using on MailServiceProvider.
I tried to use bcrypt but it can't be de-crypted. Any suggestions?
Thanks
see the docs for encryption: https://laravel.com/docs/8.x/encryption
encrypting password:
$encrypted = crypt::encryptString($password);
//store this to database
decrypting password:
$decrypted_password = crypt::decryptString($encrypted);
//use this for mailer settings
Note: don't forget to use namespace Illuminate\Support\Facades\Crypt;
in the controller
Additional Note for bcrypt:
encryption-decryption is different than hashing, bcrypt is a hashing formula which can't be decrypted (one way process).

Get the password after encoded by PasswordEncoder and generated with jwt in spring boot security

I'm working with Spring Boot Security.
I have to Sign up a user (name, login, password, ... .),
the password inserted to oracle DB is encoded using PasswordEncoder.
Then the Sign in is implemented with JWT.
I'd like to recuperate the password registered in DB, but it's not possible with PasswordEncoder.
That's why I used StandardPBEStringEncryptor which allowed decrypt the encrypted registered password.
But, now, I faced another problem which is :
encoded password does not look like bcrypt jwt
Could you please tell me if I missed something ? Have you any idea to recuperate the registered password ?
Any suggestion will be appreciated.

How to get Salesforce Data in java

I have username and password for salesforce. I tried using REST API way, it requires clientid, client secret and redirecturl. Client is not willing to share them. Is there any alternate to get the data by just using Username and password?
You can use the username & password OAuth flow. Here is an example Java app that does that: https://github.com/jamesward/salesforce-rest-starter
Ask the client to create a public Rest Service as described here.
https://developer.salesforce.com/forums/?id=906F00000008s2KIAQ
This way it does not require any authentication and anyone can access the service.

Unable to decrypt password in Jhipster

I have working on jhipster.but i am unable to decrypt password in jhipster and Spring.PasswordEncoderClass only provide encode and Match password function.can you help to decrypt password in jhipster.
Thanks in advance
We are using Spring Security's StandardPasswordEncoder, I do hope you can't decrypt it :-)
We are indeed storing hashed passwords: as you say, you can encode a password, and validate (match) if a specific String is the correct password, but you can't decrypt it. This means that if your database is stolen by a hacker, he would have a very hard time to figure out your users' passwords.
So this is a very good idea if you want to keep your users' password secure.
If, however, you want to have your passwords in plain text, you can change the encoder in your SecurityConfiguration class: you need to change the "passwordEncoder" bean, and probably use Spring Security's "NoOpPasswordEncoder" class. Of course, I have never done it, as I care about my users' data :-)

Spring Security - Alter username on the way in

I have a database where passwords are encrypted in plain old md5. There is no salt. All the usernames are numeric.
This is what the db looks like..
Username, Password, Hashed Password
0101,abcd123,79cfeb94595de33b3326c06ab1c7dbda
I am writing a web application using spring security. I have managed to get authentication working when the user the user types in 0101 as the username and then abcd123 as the password.
But what I really want working is the user to type in 101 (without the leading zero) as the username and abcd123 as the password.
I got my code working with the leading zero by overriding org.springframework.security.core.userdetails.UserDetailsService > loadUserByUsername(String userId).
I started looking at salt and then realized that I was totally going down the wrong track because this has nothing to do with my use password.
How can I alter my code so that my requirement is meant? I tried to hack my own implementation of loadUserByUsername(String userId) to prepend a 0 on the way into the method but this did not work.
thanks
Thanks for the advice guys. I was lucky and I found another column in the database named sign on id. It contains the actual string that the user enters to sign into the application.

Resources