You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Joose Vettenranta <jo...@iki.fi> on 2004/04/14 13:17:01 UTC
md5 in XSP
Hi,
I'm trying to create md5-chechsum in XSP.
I already have like this:
java.security.MessageDigest md =
java.security.MessageDigest.getInstance("MD5");
byte[] array = md.digest(password.getBytes());
And it seems to work OK. But problem is, howto get that byte-array to
hex-string?
I found that in catalina there is org.apache.catalina.util.MD5Encoder
which seems to do what I want, but I can't use that in XSP.
I've tried
<xsp:structure>
<xsp:include>org.apache.catalina.util.MD5Encoder</xsp:include>
</xsp:structure>
but it won't even compile.
So, how to get that working?
- Joose
--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: md5 in XSP
Posted by Antonio Gallardo <ag...@agssa.net>.
Jorg Heymans dijo:
> Not really answering your question sorry ;)
>
> If adding an extra lib to your webapp is an option, then commons-codec
> (http://jakarta.apache.org/commons/codec/) might be what you are looking
> for to do do MD5 checksums the "jakarta" way.
Yep! There is! :-D
Better use the commons-codec.jar . I think Cocoon will need to start to
use it too.
Best Regards,
Antonio Gallardo.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: About MySQL and PostgreSQL (Was: Re: OT: Re: md5 in XSP)
Posted by Yves Vindevogel <yv...@implements.be>.
mySQL probably has most of these features, but some of them only
recently (support of SAP who coded parts of MaxDB, IMHO)
I prefer Postgresql since these features have been implemented for ages.
What I would like is a database where I can write function in java.
That's the only thing that postgresql misses (besides named parameters
in functions)
On 15 Apr 2004, at 17:25, Leon Widdershoven wrote:
> I'm hardly an SQL wizard but I surfed the mysql docs long enough to
> feel one:)
>
> It can rollback, it can do that nested query, and it most certainly
> supports replication and master/slave setups.
>
> But my interest in software is not the brand, but can it do what I want
> with the least of trouble. If that's postgresql for you, fine.
>
> MySQL can keep my data in sync with no trouble at all, I know
> how it works - and that's it for me.
>
> Leon
>
> Joose Vettenranta wrote:
>> 15.4.2004 kello 12:39, Leon Widdershoven kirjoitti:
>> I actually agree with Joose; the lack of wizards in MySQL is very
>>> disturbing.
>> Heh =)
>>> OK. Bad joke. But I do agree; I think there are situations where
>>> MySQL
>>> is not the solution. As it happens nested queries have only just been
>>> introduced, which is kind of a nice feature to have. Not required -
>>> but
>> I created version 1 of a software to mysql and to postgresql.
>> versio 2 was only available as to postgresql, because mysql couldn't
>> do transactions and nested queries..
>> Now that I'm working on version 3, there is even more complex
>> SQL-queries and I don't want to even start to consider MySQL, 'caz it
>> might not work. I don't even know does MySQL have transactions
>> (begin, rollback, commit) and if it does handle well nested queries
>> like (select foo from bar where x = (select bar from quux)) stuff.
>> Speed is something I don't need to consider, because with money I can
>> buy hardware, but software without enough functionality isn't
>> possible to fix with money -> have replace. And postgresql seems to
>> be more friendly when porting to Oracle or DB2.
>> And how about replication in MySQL? There is replication for
>> postgresql and there is replication for Oracle =)
>> - Joose
>> --
>> "Always remember that you are unique, just like everyone else!"
>> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
Met vriendelijke groeten,
Bien à vous,
Kind regards,
Yves Vindevogel
Implements
Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91
Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
Markt 18c - 9700 Oudenaarde - Tel: +32 (55) 30 55 76
Web: http://www.implements.be
First they ignore you. Then they laugh at you. Then they fight you.
Then you win.
Mahatma Ghandi.
Re: About MySQL and PostgreSQL (Was: Re: OT: Re: md5 in XSP)
Posted by Leon Widdershoven <qa...@dds.nl>.
I'm hardly an SQL wizard but I surfed the mysql docs long enough to feel one:)
It can rollback, it can do that nested query, and it most certainly
supports replication and master/slave setups.
But my interest in software is not the brand, but can it do what I want
with the least of trouble. If that's postgresql for you, fine.
MySQL can keep my data in sync with no trouble at all, I know
how it works - and that's it for me.
Leon
Joose Vettenranta wrote:
>
> 15.4.2004 kello 12:39, Leon Widdershoven kirjoitti:
>
> I actually agree with Joose; the lack of wizards in MySQL is very
>
>> disturbing.
>
>
> Heh =)
>
>> OK. Bad joke. But I do agree; I think there are situations where MySQL
>> is not the solution. As it happens nested queries have only just been
>> introduced, which is kind of a nice feature to have. Not required - but
>
>
> I created version 1 of a software to mysql and to postgresql.
> versio 2 was only available as to postgresql, because mysql couldn't do
> transactions and nested queries..
> Now that I'm working on version 3, there is even more complex
> SQL-queries and I don't want to even start to consider MySQL, 'caz it
> might not work. I don't even know does MySQL have transactions (begin,
> rollback, commit) and if it does handle well nested queries like (select
> foo from bar where x = (select bar from quux)) stuff.
>
> Speed is something I don't need to consider, because with money I can
> buy hardware, but software without enough functionality isn't possible
> to fix with money -> have replace. And postgresql seems to be more
> friendly when porting to Oracle or DB2.
>
> And how about replication in MySQL? There is replication for postgresql
> and there is replication for Oracle =)
>
> - Joose
>
> --
> "Always remember that you are unique, just like everyone else!"
> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
About MySQL and PostgreSQL (Was: Re: OT: Re: md5 in XSP)
Posted by Joose Vettenranta <jo...@iki.fi>.
15.4.2004 kello 12:39, Leon Widdershoven kirjoitti:
I actually agree with Joose; the lack of wizards in MySQL is very
> disturbing.
Heh =)
> OK. Bad joke. But I do agree; I think there are situations where MySQL
> is not the solution. As it happens nested queries have only just been
> introduced, which is kind of a nice feature to have. Not required - but
I created version 1 of a software to mysql and to postgresql.
versio 2 was only available as to postgresql, because mysql couldn't do
transactions and nested queries..
Now that I'm working on version 3, there is even more complex
SQL-queries and I don't want to even start to consider MySQL, 'caz it
might not work. I don't even know does MySQL have transactions (begin,
rollback, commit) and if it does handle well nested queries like
(select foo from bar where x = (select bar from quux)) stuff.
Speed is something I don't need to consider, because with money I can
buy hardware, but software without enough functionality isn't possible
to fix with money -> have replace. And postgresql seems to be more
friendly when porting to Oracle or DB2.
And how about replication in MySQL? There is replication for postgresql
and there is replication for Oracle =)
- Joose
--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
OT: Re: md5 in XSP
Posted by Leon Widdershoven <qa...@dds.nl>.
I actually agree with Joose; the lack of wizards in MySQL is very
disturbing.
OK. Bad joke. But I do agree; I think there are situations where MySQL
is not the solution. As it happens nested queries have only just been
introduced, which is kind of a nice feature to have. Not required - but
nice.
And MySQL seems to be not completely relational. I don;t know why
one would want that, but maybe it's important for some applications.
And an XML database (Xindice?) is probably preferable when you
only have to do with XML data.
MySQL, though, is a nice database to just store data in:) It has all the
features I need, and it's fast enough. It has good docs, and a fairly
good jdbc driver. That's all I ask. But I wouldn't be surprised that
DB2 or Oracle scale better when dealing with huge (terabytes/petabytes)
databases and heavy access.
Leon
Bertrand Delacretaz wrote:
> Le 15 avr. 04, à 11:11, Joose Vettenranta a écrit :
>
>> ...1. MySQL is good only for some basic stuff, not for real use =)..
>
>
> not everybody agrees:
> http://www.mysql.com/news-and-events/newsletter/2003-11/a0000000265.html
> ;-)
>
> -Bertrand
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: md5 in XSP
Posted by Bertrand Delacretaz <bd...@codeconsult.ch>.
Le 15 avr. 04, à 11:11, Joose Vettenranta a écrit :
> ...1. MySQL is good only for some basic stuff, not for real use =)..
not everybody agrees:
http://www.mysql.com/news-and-events/newsletter/2003-11/a0000000265.html
;-)
-Bertrand
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: md5 in XSP
Posted by Joose Vettenranta <jo...@iki.fi>.
Nice idea, but not possible to use for few reasons.
1. MySQL is good only for some basic stuff, not for real use =)
2. I needed hash to make verification for online bank transactions.
Commons -packet helped.
Thanks,
- Joose
14.4.2004 kello 14:42, Leon Widdershoven kirjoitti:
Another non-answer (I had something similar a while ago), if the
passwords
> are stored in a MySQL database and you just wish to verify the password
> you could use MySQL's MD5() function (maybe also supported by other
> db's).
>
> This is of course of no use at all if you're comparing with encoded
> pw's
> in a file:)
>
> As a side pointer, the jboss getting started uses as an alternative to
> openssl dgst -md5 -binary | openssl base64 (for the command line)
> the java program:
> java -classpath jbosssx.jar org.jboss.security.Base64Encoder <pw> MD5
>
> I think using the Base64Encoder of jboss could also be an option. (I
> tested
> it in Java code some time ago and it does work).
>
> Leon
>
> Jorg Heymans wrote:
>> Not really answering your question sorry ;)
>> If adding an extra lib to your webapp is an option, then
>> commons-codec (http://jakarta.apache.org/commons/codec/) might be
>> what you are looking for to do do MD5 checksums the "jakarta" way.
>> hth
>> Jorg
>> Joose Vettenranta wrote:
>>> Hi,
>>>
>>> I'm trying to create md5-chechsum in XSP.
>>>
>>> I already have like this:
>>>
>>> java.security.MessageDigest md =
>>> java.security.MessageDigest.getInstance("MD5");
>>> byte[] array = md.digest(password.getBytes());
>>>
>>> And it seems to work OK. But problem is, howto get that byte-array
>>> to hex-string?
>>>
>>> I found that in catalina there is
>>> org.apache.catalina.util.MD5Encoder which seems to do what I want,
>>> but I can't use that in XSP.
>>>
>>> I've tried
>>> <xsp:structure>
>>> <xsp:include>org.apache.catalina.util.MD5Encoder</xsp:include>
>>> </xsp:structure>
>>>
>>> but it won't even compile.
>>>
>>> So, how to get that working?
>>>
>>> - Joose
>>>
>>> --
>>> "Always remember that you are unique, just like everyone else!"
>>> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: md5 in XSP
Posted by Leon Widdershoven <qa...@dds.nl>.
Another non-answer (I had something similar a while ago), if the passwords
are stored in a MySQL database and you just wish to verify the password
you could use MySQL's MD5() function (maybe also supported by other db's).
This is of course of no use at all if you're comparing with encoded pw's
in a file:)
As a side pointer, the jboss getting started uses as an alternative to
openssl dgst -md5 -binary | openssl base64 (for the command line)
the java program:
java -classpath jbosssx.jar org.jboss.security.Base64Encoder <pw> MD5
I think using the Base64Encoder of jboss could also be an option. (I tested
it in Java code some time ago and it does work).
Leon
Jorg Heymans wrote:
> Not really answering your question sorry ;)
>
> If adding an extra lib to your webapp is an option, then commons-codec
> (http://jakarta.apache.org/commons/codec/) might be what you are looking
> for to do do MD5 checksums the "jakarta" way.
>
> hth
> Jorg
>
> Joose Vettenranta wrote:
>
>> Hi,
>>
>> I'm trying to create md5-chechsum in XSP.
>>
>> I already have like this:
>>
>> java.security.MessageDigest md =
>> java.security.MessageDigest.getInstance("MD5");
>> byte[] array = md.digest(password.getBytes());
>>
>> And it seems to work OK. But problem is, howto get that byte-array to
>> hex-string?
>>
>> I found that in catalina there is org.apache.catalina.util.MD5Encoder
>> which seems to do what I want, but I can't use that in XSP.
>>
>> I've tried
>> <xsp:structure>
>> <xsp:include>org.apache.catalina.util.MD5Encoder</xsp:include>
>> </xsp:structure>
>>
>> but it won't even compile.
>>
>> So, how to get that working?
>>
>> - Joose
>>
>> --
>> "Always remember that you are unique, just like everyone else!"
>> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: md5 in XSP
Posted by Jorg Heymans <jh...@domek.be>.
Not really answering your question sorry ;)
If adding an extra lib to your webapp is an option, then commons-codec
(http://jakarta.apache.org/commons/codec/) might be what you are looking
for to do do MD5 checksums the "jakarta" way.
hth
Jorg
Joose Vettenranta wrote:
> Hi,
>
> I'm trying to create md5-chechsum in XSP.
>
> I already have like this:
>
> java.security.MessageDigest md =
> java.security.MessageDigest.getInstance("MD5");
> byte[] array = md.digest(password.getBytes());
>
> And it seems to work OK. But problem is, howto get that byte-array to
> hex-string?
>
> I found that in catalina there is org.apache.catalina.util.MD5Encoder
> which seems to do what I want, but I can't use that in XSP.
>
> I've tried
> <xsp:structure>
> <xsp:include>org.apache.catalina.util.MD5Encoder</xsp:include>
> </xsp:structure>
>
> but it won't even compile.
>
> So, how to get that working?
>
> - Joose
>
> --
> "Always remember that you are unique, just like everyone else!"
> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: md5 in XSP
Posted by Antonio Gallardo <ag...@agssa.net>.
Joose Vettenranta dijo:
> Hi,
>
> I'm trying to create md5-chechsum in XSP.
>
> I already have like this:
>
> java.security.MessageDigest md =
> java.security.MessageDigest.getInstance("MD5");
> byte[] array = md.digest(password.getBytes());
>
> And it seems to work OK. But problem is, howto get that byte-array to
> hex-string?
>
> I found that in catalina there is org.apache.catalina.util.MD5Encoder
> which seems to do what I want, but I can't use that in XSP.
>
> I've tried
> <xsp:structure>
> <xsp:include>org.apache.catalina.util.MD5Encoder</xsp:include>
> </xsp:structure>
>
> but it won't even compile.
>
> So, how to get that working?
Because you need to have the jar in the servlet classpath (WEB-INF/lib).
BTW, try to look into o.a.c.utils.* and in commons-lang-2.0.jar, I thought
I saw something like a hexconverter somewhere. Look also in http related
libs as commons-httpclient-2.0-final.jar.
Best Regards,
Antonio Gallardo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: md5 in XSP
Posted by Jorg Heymans <jh...@domek.be>.
I knew i came across something similar before, remember it now :)
A while ago, I implemented the md5response assertion for the jmeter
project. Upon committing , one of their developers swapped out my usage
of commons-codec with some JDK only code which does IIRC what you want.
//ba is your bytearray
MessageDigest md;
md = MessageDigest.getInstance("MD5");
md5Result = md.digest(ba);
StringBuffer sb = new StringBuffer(32);
for (int i = 0; i<ba.length; i++ )
{
int j = ba[i]&0xff;
if (j < 16) sb.append("0");
sb.append(Integer.toHexString(j));
}
}
//sb contains now your md5hex string
Regards
Jorg
Joose Vettenranta wrote:
> Hi,
>
> I'm trying to create md5-chechsum in XSP.
>
> I already have like this:
>
> java.security.MessageDigest md =
> java.security.MessageDigest.getInstance("MD5");
> byte[] array = md.digest(password.getBytes());
>
> And it seems to work OK. But problem is, howto get that byte-array to
> hex-string?
>
> I found that in catalina there is org.apache.catalina.util.MD5Encoder
> which seems to do what I want, but I can't use that in XSP.
>
> I've tried
> <xsp:structure>
> <xsp:include>org.apache.catalina.util.MD5Encoder</xsp:include>
> </xsp:structure>
>
> but it won't even compile.
>
> So, how to get that working?
>
> - Joose
>
> --
> "Always remember that you are unique, just like everyone else!"
> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org