Authentication Framework Code Snippets

These code snippets are for the authentication framework. See the JXLoginPanel code snippets for examples of showing a login frame or login dialog.

Authenticating and Connecting to a JDBC Database

  String driver = "org.postgresql.Driver";
  String jdbcURL = "jdbc:postgresql://localhost/adventure";
  JDBCLoginService service = new JDBCLoginService(driver, jdbcURL);
  String userName = "postgres";
  char[] password = new char[] {'p','a','s','s'};
  //the Server param is not currently used by JDBCLoginService
  //so we pass in null
  if (service.authenticate(userName, password, null)) {
    java.sql.Connection conn = service.getConnection();
    //you are now authenticated and have a valid JDBC connection
  } else {
    //authentication failed
  }