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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:20:03+00:00 2026-05-27T16:20:03+00:00

Hi I am trying to retrive a simple object from a db via its

  • 0

Hi I am trying to retrive a simple object from a db via its password hash and username combination ….

username = request.getParameter("username");
password = request.getParameter("password");

// Converting request password to hash
String passwordHash = SecurityUtil.convertStringToSHA1(password);


Session hs = HibernateUtil.getSessionFactory().getCurrentSession();
hs.beginTransaction();

//query for a single result of matching username with password
//Query hquery = hs.createQuery("from User where id = :id");
//hquery.setParameter("id", 33l);  <- THIS QUERY WORKS

Query hquery = hs.createQuery("from User where password = :password and userName = :userName"); //<- password is a sha1 hash in the db
hquery.setString("userName", username);
hquery.setParameter("password", passwordHash);

User user = (User)hquery.uniqueResult(); //<- Always NULL WHY There should be a unique result.
log.info("UR: "+username);
log.info("PR: "+passwordHash);

if(user!=null) {
    //never reached
    log.info("UDB: "+user.getUserName());
    log.info("PDB: "+user.getPassword());

} else {
    always reaches here
}

Any Ideas? Or does that mean that there are no uniqueResults?

My sha1 hashes are not salted, however the password hashes are generated from a random string using apache commons which should be more or less collision free …

Further it is my first time doing hibernate stuff so I might be in the wrong somewhere …

  • 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-27T16:20:04+00:00Added an answer on May 27, 2026 at 4:20 pm

    Ok I know now where all went down the drain. I have jaspy string encryption enabled on these fields. Due to the random salt it is obvious that these fields in a WHERE clause just do not fly … :-/

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

Sidebar

Related Questions

I've been trying to retrive attachment from message in Exchange 2003 server using WebDAV.
I am trying to retrieve all cards from Mongoid that have request=preview I'm doing
I'm trying to do a simple Select Count(*) from PRODUCTS where date > xxx
I'm trying to retrieve data from a JSON object that looks like this: stdClass
I'm trying to write a simple curl program to retrieve the web page in
I'm trying to retrive a dataset to a Gridview, but I just don't get
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I'm trying to retrieve a file from a server using SFTP (as opposed to
I'm trying to retrieve an XML stream from a URL. For most URLs my
I'm trying to retrieve data from an SQL Server 2000 server, and place into

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.