I think this is the right answer:

digest() returns a sequence of bytes.  Depending on the values of the individual
bytes, if you were to try and convert it to String, you can end up with
non-printable characters, etc. 

I'm assuming that HexUtils.convert() turns each 4 bits of each byte into a hex
character, so that you end up with a proper String representation of the digest
that can be sent as part of a URL.

Jay

| Jay Burgess [Vertical Technology Group]
| http://www.vtgroup.com/


-----Original Message-----
From: Alessandro Colantoni [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 22, 2006 12:12 PM
To: Tomcat Users List
Subject: return (HexUtils.convert(md.digest())) in RealmBase

Hi All!
I saw that both method Digest(..) and digest(..) in RealmBase return (
HexUtils.convert(md.digest())) and not just
md.digest().toString.

My problem is that user table is maintained by another application developed
in an other technology.
My application uses this table just to authenticate.
The password of user table is encrypted with an algorithm I've been done.
I wrote a MessageDigestSpi for that algorithm, I wrote my provider, I
registered it and everything looks work fine.
Except that of course if I do:
 RealmBase.Digest(myCredentials,myAlgorithm);

I get a result different from doing
MessageDigest md = MessageDigest.getInstance(myAlgorithm);
md.update(myCredentials.getBytes());
md.digest().toString;

but the same result of
 MessageDigest md = MessageDigest.getInstance(myAlgorithm);
 md.update(myCredentials.getBytes());
HexUtils.convert(md.digest())

So the problem is that the other application stores without using the
HexUtils.convert method
but when tomcat authenticates it uses it.

One solution could be write a Realm class that extends the JDBCRealm (the
one I'm using) and overwrite these methods.
But I'm afraid that in different versions of Tomcat (i don't want link to
one) could be different signature of these methods.
There's another solution?
At least avoiding overwriting these very important methods?

And just for curiosity, why HexUtils.convert has been utilized?

Thanks in advance for help and have a nice springtime
Alessandro





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to