You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by salihrkc <sa...@live.com> on 2014/01/25 18:55:42 UTC

Plain password and encrypted password doesn't match

    public void doRegister() throws SQLException{
        PasswordService dps = new DefaultPasswordService();
        System.out.println("Test succesful");
         con = ds.getConnection();
         PreparedStatement ps = con.prepareStatement("insert into
user(username, password, email, fullname) values (?, ?, ?, ?)");
         String temp = dps.encryptPassword(password);
         ps.setString(1, userName);
         ps.setString(2, temp);
         ps.setString(3, emailAddress);
         ps.setString(4, "Salih ERİKCİ");
         ps.executeUpdate();
        //DatabaseOperations.initializeDB(this);
         System.out.println("AAAA  "+dps.passwordsMatch(password, temp));
         
    }

this outputs AAAA false

What is the problem?



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579551.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Plain password and encrypted password doesn't match

Posted by Les Hazlewood <lh...@apache.org>.
Thanks for creating the issue!

--
Les Hazlewood | @lhazlewood
CTO, Stormpath | http://stormpath.com | @goStormpath | 888.391.5282


On Sun, Jan 26, 2014 at 10:33 AM, salihrkc <sa...@live.com> wrote:

> I created an issue.
>
> https://issues.apache.org/jira/browse/SHIRO-483
>
>
>
> --
> View this message in context:
> http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579552p7579564.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>

Re: Plain password and encrypted password doesn't match

Posted by salihrkc <sa...@live.com>.
I created an issue.

https://issues.apache.org/jira/browse/SHIRO-483



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579552p7579564.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Plain password and encrypted password doesn't match

Posted by Jared Bunting <ja...@peachjean.com>.
This is definitely a bug.  Thanks for tracking down the root cause. Would
you mind filing an issue in Jira for it?
https://issues.apache.org/jira/browse/SHIRO


On Sun, Jan 26, 2014 at 5:09 AM, salihrkc <sa...@live.com> wrote:

> I solved the problem. My default locale is TR_tr. When i run the program
> without changing the default locale it outputs "false".
> but when i run the programming as below it outputs "true"
>
> public class App {
>
>     public static void main(String[] args) {
>         PasswordService psd = new DefaultPasswordService();
>         String password = "333";
>         String enc = psd.encryptPassword(password);
>         Locale.setDefault(Locale.ENGLISH);
>         System.out.println(Locale.getDefault());
>         System.out.print(psd.passwordsMatch(password, enc));
>
>     }
> }
>
>
>
> --
> View this message in context:
> http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579552p7579560.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>

Re: Plain password and encrypted password doesn't match

Posted by salihrkc <sa...@live.com>.
I solved the problem. My default locale is TR_tr. When i run the program
without changing the default locale it outputs "false".
but when i run the programming as below it outputs "true"

public class App {

    public static void main(String[] args) {
        PasswordService psd = new DefaultPasswordService();
        String password = "333";
        String enc = psd.encryptPassword(password);
        Locale.setDefault(Locale.ENGLISH);
        System.out.println(Locale.getDefault());
        System.out.print(psd.passwordsMatch(password, enc));
        
    }
}



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579552p7579560.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Plain password and encrypted password doesn't match

Posted by salihrkc <sa...@live.com>.
I tried on another pc but it gives false too. Can it be some character
encoding problem or something?  Both of the pc's i tried are using TR_tr
local



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579552p7579559.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Plain password and encrypted password doesn't match

Posted by salihrkc <sa...@live.com>.
I tried with the following simple program. It outputs false again.

https://github.com/slhrkc/mavenproject3



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579552p7579558.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Plain password and encrypted password doesn't match

Posted by Roger Caplan <ca...@nytimes.com>.
can you try a test that does not involve a webapp, i.e. just something with main()? that'd eliminate a lot of moving parts.


> I am using 1.2.2
> 
> I know it must return true, even  a guy on stackoverflow said it was
> returning true on his pc but i don't know what is wrong with my code.
> 
> here is small program i tested
> https://github.com/slhrkc/NewPlease
> 
> 
> you can run the file RegisterBean.java to see the output, it gives me false.
> 
> 
> 
> 
> 
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579552p7579554.html
> Sent from the Shiro User mailing list archive at Nabble.com.


Re: Plain password and encrypted password doesn't match

Posted by salihrkc <sa...@live.com>.
236 644 595
4456 

can you connect via teamviewer and check yourself please? I really wonder
why it works wrongly on my pc



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579552p7579556.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Plain password and encrypted password doesn't match

Posted by Jared Bunting <ja...@peachjean.com>.
Just tried it out. When I run RegisterBean.java, it gives me:

fdsfsdfTest succesful
AAAA  true

Maybe right the main method that you’re using or a unit test and put it in
here? That way we can make sure that we’re invoking the exact same thing?
(A unit test would be best - that way validation can be done with a simple
build.)


On Sat, Jan 25, 2014 at 5:00 PM, salihrkc <sa...@live.com> wrote:

> I am using 1.2.2
>
> I know it must return true, even  a guy on stackoverflow said it was
> returning true on his pc but i don't know what is wrong with my code.
>
> here is small program i tested
> https://github.com/slhrkc/NewPlease
>
>
> you can run the file RegisterBean.java to see the output, it gives me
> false.
>
>
>
>
>
> --
> View this message in context:
> http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579552p7579554.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>

Re: Plain password and encrypted password doesn't match

Posted by salihrkc <sa...@live.com>.
I am using 1.2.2

I know it must return true, even  a guy on stackoverflow said it was
returning true on his pc but i don't know what is wrong with my code.

here is small program i tested
https://github.com/slhrkc/NewPlease


you can run the file RegisterBean.java to see the output, it gives me false.





--
View this message in context: http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579552p7579554.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Plain password and encrypted password doesn't match

Posted by Les Hazlewood <lh...@apache.org>.
You can see from the test cases in DefaultPasswordServiceTest [1] that it
should work as expected.  Super simple example:

PasswordService service = new DefaultPasswordService();
String plaintext = "12345";
String encrypted = service.encryptPassword(plaintext);
assert service.passwordsMatch(plaintext, encrypted); //true

What version of Shiro are you using?

[1]
http://svn.apache.org/repos/asf/shiro/branches/1.x/core/src/test/groovy/org/apache/shiro/authc/credential/DefaultPasswordServiceTest.groovy

On Sat, Jan 25, 2014 at 9:55 AM, salihrkc <sa...@live.com> wrote:

>     public void doRegister() throws SQLException{
>         PasswordService dps = new DefaultPasswordService();
>         System.out.println("Test succesful");
>          con = ds.getConnection();
>          PreparedStatement ps = con.prepareStatement("insert into
> user(username, password, email, fullname) values (?, ?, ?, ?)");
>          String temp = dps.encryptPassword(password);
>          ps.setString(1, userName);
>          ps.setString(2, temp);
>          ps.setString(3, emailAddress);
>          ps.setString(4, "Salih ERİKCİ");
>          ps.executeUpdate();
>         //DatabaseOperations.initializeDB(this);
>          System.out.println("AAAA  "+dps.passwordsMatch(password, temp));
>
>     }
>
> this outputs AAAA false
>
> What is the problem?
>
>
>
> --
> View this message in context:
> http://shiro-user.582556.n2.nabble.com/Plain-password-and-encrypted-password-doesn-t-match-tp7579551.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>