I know most people are using PHP but there are a few of us who use Java and JSP on our servers. We need a way for users to be automatically logged on to vBulletin via our Intranet (which is running under Tomcat).
Here is the code for hashing via MD5 and creating a vBulletin cookie:
import javax.servlet.http.Cookie;
import java.security.MessageDigest;
import java.math.BigInteger;
String dbpassword = "";
String license = "";
String password = dbpassword + license;
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(password.getBytes());
BigInteger hash = new BigInteger( 1, md.digest() );
String hpassword = hash.toString(16);
Cookie cookie_userid = new Cookie ("bbuserid", "3");
cookie_userid.setDomain("your domain");
cookie_userid.setMaxAge(365 * 24 * 60 * 60);
response.addCookie(cookie_userid);
Cookie cookie_password = new Cookie ("bbpassword", hpassword);
cookie_password.setDomain("your domain");
cookie_password.setMaxAge(365 * 24 * 60 * 60);
response.addCookie(cookie_password);
There you go!
G
Here is the code for hashing via MD5 and creating a vBulletin cookie:
import javax.servlet.http.Cookie;
import java.security.MessageDigest;
import java.math.BigInteger;
String dbpassword = "";
String license = "";
String password = dbpassword + license;
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(password.getBytes());
BigInteger hash = new BigInteger( 1, md.digest() );
String hpassword = hash.toString(16);
Cookie cookie_userid = new Cookie ("bbuserid", "3");
cookie_userid.setDomain("your domain");
cookie_userid.setMaxAge(365 * 24 * 60 * 60);
response.addCookie(cookie_userid);
Cookie cookie_password = new Cookie ("bbpassword", hpassword);
cookie_password.setDomain("your domain");
cookie_password.setMaxAge(365 * 24 * 60 * 60);
response.addCookie(cookie_password);
There you go!
G