Take a look at ZimbraServer/docs/preauth.txt (also attached) in the latest source release. It describes how to do exactly that.
I'll also attach a simple JSP that shows how to use preauth. The following line in the sample:
Generates all the required preauth data to login as user1. You'd obviously want to change that to the user id you are preauth'ing. I modified this example slightly and didn't test it, so let me know if it doesn't work.
String redirect = generateRedirect(request, "user1");