Re: do XA connections support SSL?

From: Stefan Verkoyen <stefan(dot)verkoyen(at)quesd(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: do XA connections support SSL?
Date: 2006-04-06 08:04:17
Message-ID: 4434CB81.8000909@quesd.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Kris,

thanks for your comments. I decided to try to patch the XA datasource
code. Luckily the datasource relies heavily on the pgjdbc driver which
already supports SSL. I'm no pgjdbc expert so I might have done
something wrong. In any case, the patch below works for me. I post it
here for anyone looking for XA with SSL support.

In the XA datasource descriptor you'll have to add:
<xa-datasource-property name="Ssl">true</xa-datasource-property>

Best regards,
Stefan

--- BaseDataSource.java Thu Apr 06 09:54:43 2006
+++ BaseDataSource.patched.java Thu Apr 06 09:51:39 2006
@@ -47,6 +47,7 @@
private String databaseName;
private String user;
private String password;
+ private boolean ssl = false;
private int portNumber;
private int prepareThreshold;
private int loginTimeout; // in seconds
@@ -262,13 +263,28 @@
}

/**
+ * Is SSL enabled?
+ */
+ public String isSsl() {
+ return ""+ssl;
+ }
+
+ /**
+ * Enable or disable SSL.
+ * @param ssl enable or disable SSL.
+ */
+ public void setSsl(String ssl) {
+ this.ssl = Boolean.valueOf(ssl).booleanValue();
+ }
+
+ /**
* Generates a DriverManager URL from the other properties supplied.
*/
private String getUrl()
{
return
"jdbc:postgresql://" + serverName + (portNumber == 0 ? "" :
":" + portNumber) + "/" + databaseName +
- "?loginTimeout=" + loginTimeout + "&prepareThreshold=" +
prepareThreshold;
+ "?loginTimeout=" + loginTimeout + "&prepareThreshold=" +
prepareThreshold + (ssl?"&ssl=true":"");
}

/**
@@ -301,6 +317,7 @@

ref.add(new StringRefAddr("prepareThreshold",
Integer.toString(prepareThreshold)));
ref.add(new StringRefAddr("loginTimeout",
Integer.toString(loginTimeout)));
+ ref.add(new StringRefAddr("ssl", Boolean.toString(ssl)));
return ref;
}

@@ -313,6 +330,7 @@
out.writeInt(portNumber);
out.writeInt(prepareThreshold);
out.writeInt(loginTimeout);
+ out.writeBoolean(ssl);
}

protected void readBaseObject(ObjectInputStream in) throws
IOException, ClassNotFoundException
@@ -324,6 +342,7 @@
portNumber = in.readInt();
prepareThreshold = in.readInt();
loginTimeout = in.readInt();
+ ssl = in.readBoolean();
}

}

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Pavan Kumar 2006-04-06 11:31:23 Re: thread hang on execute call
Previous Message Michael Barker 2006-04-06 06:38:49 [PATCH] Support for ping method.