You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lin Chun <fr...@gmail.com> on 2009/08/13 11:37:35 UTC

How to set Realm digest for base64 password

hi,
I am using the JDBCRealm , but the password of user is not pure text, but
stored in base64 encoding

Followd the doc, seems I have to set the digest , but I don't know which
digest and digestEncoding should I use?


that's what I do now
------------------
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
          driverName="org.gjt.mm.mysql.Driver"

connectionURL="jdbc:mysql://localhost/hibernate?user=root&amp;password=root"
           userTable="users" userNameCol="USERNAME" userCredCol="PASSWORD"
       userRoleTable="granted_authorities" roleNameCol="AUTHORITY"/>
------------------
------------------
<security-constraint>

  <web-resource-collection>
    <web-resource-name>
      Entire Application
    </web-resource-name>
    <url-pattern>/*</url-pattern>
  </web-resource-collection>
  <auth-constraint>
      <role-name>Admin</role-name>
  </auth-constraint>

</security-constraint>
<login-config>

  <auth-method>BASIC</auth-method>
  <realm-name>Login Authority</realm-name>

</login-config>
<security-role>

<role-name>Admin</role-name>

</security-role>
-------------------

Regard,
-- 
-------------------------
Lin Chun
Marie von Ebner-Eschenbach<http://www.brainyquote.com/quotes/authors/m/marie_von_ebnereschenbac.html>
- "Even a stopped clock is right twice a day."

Re: How to set Realm digest for base64 password

Posted by Mark Thomas <ma...@apache.org>.
Lin Chun wrote:
> hi,
> I am using the JDBCRealm , but the password of user is not pure text, but
> stored in base64 encoding
> 
> Followd the doc, seems I have to set the digest , but I don't know which
> digest and digestEncoding should I use?

Sorry, that won't work. You'll need to write a custom realm (just extend
an existing one).

As an aside, the JDBCRealm is very synchronized. You'll get much better
performance with the DataSourceRealm.

Mark

> 
> 
> that's what I do now
> ------------------
> <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
>           driverName="org.gjt.mm.mysql.Driver"
> 
> connectionURL="jdbc:mysql://localhost/hibernate?user=root&amp;password=root"
>            userTable="users" userNameCol="USERNAME" userCredCol="PASSWORD"
>        userRoleTable="granted_authorities" roleNameCol="AUTHORITY"/>
> ------------------
> ------------------
> <security-constraint>
> 
>   <web-resource-collection>
>     <web-resource-name>
>       Entire Application
>     </web-resource-name>
>     <url-pattern>/*</url-pattern>
>   </web-resource-collection>
>   <auth-constraint>
>       <role-name>Admin</role-name>
>   </auth-constraint>
> 
> </security-constraint>
> <login-config>
> 
>   <auth-method>BASIC</auth-method>
>   <realm-name>Login Authority</realm-name>
> 
> </login-config>
> <security-role>
> 
> <role-name>Admin</role-name>
> 
> </security-role>
> -------------------
> 
> Regard,



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to set Realm digest for base64 password

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lin,

On 8/13/2009 5:37 AM, Lin Chun wrote:
> I am using the JDBCRealm , but the password of user is not pure text, but
> stored in base64 encoding

As Mark says, you'll have the best luck writing a custom Realm. I have a
couple of other suggestions that might also work:

1. Write your own crypto provider that provides a Base64 "digest"
(base64 is NOT NOT NOT NOT NOT NOT NOT a digest, it's a human-readable
byte encoding, so this is a HUGE HACK THAT COULD REALLY BITE YOU IN THE
ASS) and use that as your digest="Base64" in the Realm.

2. Re-write your entire database with /properly/-digested passwords by
performing the following operation on all passwords:

   a. Read the password from the database.
   b. Decode the password from Base64 into text (kinda silly to base64
      encode the passwords... why are you doing this?)
   c. Hash the password using something like SHA-256 (MD5 and SHA-1 are
      considered cryptographically weak these days).
   d. Write the hashed password back to the database.

Then you can use a stock Realm.

Mark also mentions that JDBCRealm is not recommended for production use.
I completely agree. DataSourceRealm allows multiple simultaneous
authentications and the use of a connection pool instead of a private
connection.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqSpw4ACgkQ9CaO5/Lv0PBYlgCgwA4e7nKIja+lhxtKXCvSYKoD
3vIAnjquCto1/oGEQb9gFbKnQ5zKG7yc
=W0EH
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to set Realm digest for base64 password

Posted by Lin Chun <fr...@gmail.com>.
sorry given little detail
Tomcat 5.5
JVM 1.5
OS linux

On Thu, Aug 13, 2009 at 12:21 PM, Pid <pi...@pidster.com> wrote:

> Tomcat version?
> JVM version?
> OS version?
>
> p
>
>
>
> On 13/08/2009 10:37, Lin Chun wrote:
>
>> hi,
>> I am using the JDBCRealm , but the password of user is not pure text, but
>> stored in base64 encoding
>>
>> Followd the doc, seems I have to set the digest , but I don't know which
>> digest and digestEncoding should I use?
>>
>>
>> that's what I do now
>> ------------------
>> <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
>>           driverName="org.gjt.mm.mysql.Driver"
>>
>>
>> connectionURL="jdbc:mysql://localhost/hibernate?user=root&amp;password=root"
>>            userTable="users" userNameCol="USERNAME" userCredCol="PASSWORD"
>>        userRoleTable="granted_authorities" roleNameCol="AUTHORITY"/>
>> ------------------
>> ------------------
>> <security-constraint>
>>
>>   <web-resource-collection>
>>     <web-resource-name>
>>       Entire Application
>>     </web-resource-name>
>>     <url-pattern>/*</url-pattern>
>>   </web-resource-collection>
>>   <auth-constraint>
>>       <role-name>Admin</role-name>
>>   </auth-constraint>
>>
>> </security-constraint>
>> <login-config>
>>
>>   <auth-method>BASIC</auth-method>
>>   <realm-name>Login Authority</realm-name>
>>
>> </login-config>
>> <security-role>
>>
>> <role-name>Admin</role-name>
>>
>> </security-role>
>> -------------------
>>
>> Regard,
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
-------------------------
Lin Chun
Mike Ditka <http://www.brainyquote.com/quotes/authors/m/mike_ditka.html>  -
"If God had wanted man to play soccer, he wouldn't have given us arms."

Re: How to set Realm digest for base64 password

Posted by Pid <pi...@pidster.com>.
Tomcat version?
JVM version?
OS version?

p


On 13/08/2009 10:37, Lin Chun wrote:
> hi,
> I am using the JDBCRealm , but the password of user is not pure text, but
> stored in base64 encoding
>
> Followd the doc, seems I have to set the digest , but I don't know which
> digest and digestEncoding should I use?
>
>
> that's what I do now
> ------------------
> <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
>            driverName="org.gjt.mm.mysql.Driver"
>
> connectionURL="jdbc:mysql://localhost/hibernate?user=root&amp;password=root"
>             userTable="users" userNameCol="USERNAME" userCredCol="PASSWORD"
>         userRoleTable="granted_authorities" roleNameCol="AUTHORITY"/>
> ------------------
> ------------------
> <security-constraint>
>
>    <web-resource-collection>
>      <web-resource-name>
>        Entire Application
>      </web-resource-name>
>      <url-pattern>/*</url-pattern>
>    </web-resource-collection>
>    <auth-constraint>
>        <role-name>Admin</role-name>
>    </auth-constraint>
>
> </security-constraint>
> <login-config>
>
>    <auth-method>BASIC</auth-method>
>    <realm-name>Login Authority</realm-name>
>
> </login-config>
> <security-role>
>
> <role-name>Admin</role-name>
>
> </security-role>
> -------------------
>
> Regard,


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org