Create a vBulletin cookie with Java; solved!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • inkiboo
    New Member
    • Sep 2005
    • 4

    Create a vBulletin cookie with Java; solved!

    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
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...