Apologies to the list, that one got away as I pressed paste!
Here's the code:
package za.co.oneTwoOne.runable;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
import javax.mail.internet.MimeUtility;
public class JamesEncryption {
public static void main(String[] args) throws AddressException,
IOException, NoSuchAlgorithmException {
System.out.println( digestString("password", "SHA") );
}
private static String digestString(String pass, String algorithm)
throws NoSuchAlgorithmException {
MessageDigest md;
ByteArrayOutputStream bos;
try {
md = MessageDigest.getInstance(algorithm);
byte[] digest =
md.digest(pass.getBytes("iso-8859-1"));
bos = new ByteArrayOutputStream();
OutputStream encodedStream = MimeUtility.encode(bos,
"base64");
encodedStream.write(digest);
return bos.toString("iso-8859-1");
} catch (IOException ioe) {
throw new RuntimeException("Fatal error: " + ioe);
} catch (MessagingException me) {
throw new RuntimeException("Fatal error: " + me);
}
}
}
-----Original Message-----
From: Renen Watermeyer [mailto:[EMAIL PROTECTED]
Sent: 15 November 2007 08:38 AM
To: 'James Users List'
Subject: RE: Question on initial configuration
Hi Mike,
At the risk of leading you astray, I pulled that code out of the James code
base about three months back. But, I didn't actually implement it into
production. Hopefully it helps you along your way:
-----Original Message-----
From: Stefano Bagnara [mailto:[EMAIL PROTECTED]
Sent: 14 November 2007 07:12 PM
To: James Users List
Subject: Re: Question on initial configuration
Mike McGonagle ha scritto:
> Hello all,
>
> I looked at James about a year or so ago, and really liked what I saw.
> Now that I am getting to the point where I am actually going to set it
> up for use, I was wondering if there is some way to configure it to
> work with a Database for User Authentication? I noticed a few things
> that MENTION it, but give no indication as to where to actually look
> for this or how to set it up.
>
> I would like to be able to set this up so that anyone can add a user
> by adding them to the database, and using the default method of adding
> users would just confuse almost everyone else I work with.
>
>
> Thanks,
>
> Michael McGonagle
You can use the db based user repository (there is a comment in the
default config.xml).
The query for a user is not cached, so if you add an user directly to
the db it will work for james (you can even see the query done to
retrieve users in the sqlResources.xml).
The problem is the password. You have to encode the password the way
JAMES expect it. If you search this mailing list archives you can
probably find a description on how to do that in JAVA and PHP.
Stefano
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]