md5 passwords in 7.2.3 ?

Поиск
Список
Период
Сортировка
От Rasputin
Тема md5 passwords in 7.2.3 ?
Дата
Msg-id 20021201150427.GA6838@nailbunny.tenten
обсуждение исходный текст
Ответы Re: md5 passwords in 7.2.3 ?  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-jdbc
Just a quick check - are these supposed to work?

I'm running PostgreSQL 7.2.3 and connecting remotely - psql
seems to handle MD5 password auth (as specified in g_hba.conf) transparently,
but a very simple java app craps out :

--------------------------------------
import java.sql.*;

public class simpletest {

    public static void main(String args[]) {

        if ( args.length != 4 ) { usage(); }
        try {
            simpletest me = new simpletest();
            me.connect(args);
        } catch (Exception e) { e.printStackTrace(); }
    }

    public simpletest(){}

    private void connect(String args[]) {

        try {
            Class.forName("org.postgresql.Driver");
        } catch (ClassNotFoundException c) {
            c.printStackTrace();
        }

        String user = args[0]; String pass = args[1];
        String host = args[2]; String db = args[3];

        String url = "jdbc:postgresql://" + host + "/" + db;

        try {
            Connection con = DriverManager.getConnection(url, user, pass);
        } catch (SQLException s) {
            s.printStackTrace();
        }

    }

    private static void usage() {
        System.err.println("usage\nsimpletest user pass host db");
        System.exit(0);
    }
}
--------------------------------------

Runing
java simpletest user pass host db
<names changed to protect the innocent>
gives me this error:

--------------------------------------
Something unusual has occured to cause the driver to fail. Please report this exception: Exception:
java.sql.SQLException:FATAL 1:  Password authentication failed for user "user" 

Stack Trace:

java.sql.SQLException: FATAL 1:  Password authentication failed for user "user"

    at org.postgresql.Connection.openConnection(Unknown Source)
    at org.postgresql.Driver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:517)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at simpletest.connect(simpletest.java:38)
    at simpletest.main(simpletest.java:14)
End of Stack Trace

    at org.postgresql.Driver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:517)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at simpletest.connect(simpletest.java:38)
    at simpletest.main(simpletest.java:14)
--------------------------------------

BUT it works (i.e. java exits without errors) if I setup another db
with a plaintext password in pg_shadow, so it seems related to MD5 .

Am I missing a step somewhere?
From a quick glance at the driver source, I think the driver
should be informed what password encoding to use by the server - in which case, I
wouldn't have thought the client *could* specify an encoding scheme.

I did check the archives and FAQ before posting, but couldn't tell if this was still
an issue...



--
Rasputin :: Jack of All Trades - Master of Nuns

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: pginfo
Дата:
Сообщение: Re: [GENERAL] pg 7.3 , JDBC and timestamp problem.
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: md5 passwords in 7.2.3 ?