-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dave Cramer
authored and
Dave Cramer
committed
Dec 27, 2011
1 parent
c01fbcc
commit b125321
Showing
7 changed files
with
116 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/*------------------------------------------------------------------------- | ||
* | ||
* Copyright (c) 2004-2011, PostgreSQL Global Development Group | ||
* | ||
* IDENTIFICATION | ||
* $PostgreSQL: pgjdbc/org/postgresql/ssl/MakeSSL.java,v 1.8 2011/08/02 13:50:28 davecramer Exp $ | ||
* | ||
*------------------------------------------------------------------------- | ||
*/ | ||
package org.postgresql.ssl; | ||
|
||
|
||
|
||
public class MakeSSL extends @MAKE_SSL_CLASS@ | ||
{ | ||
|
||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/*------------------------------------------------------------------------- | ||
* | ||
* Copyright (c) 2004-2011, PostgreSQL Global Development Group | ||
* | ||
* IDENTIFICATION | ||
* $PostgreSQL: pgjdbc/org/postgresql/ssl/MakeSSL.java,v 1.8 2011/08/02 13:50:28 davecramer Exp $ | ||
* | ||
*------------------------------------------------------------------------- | ||
*/ | ||
package org.postgresql.ssl.jdbc3; | ||
|
||
import java.util.Properties; | ||
import java.io.IOException; | ||
import java.net.Socket; | ||
import java.lang.reflect.Constructor; | ||
import javax.net.ssl.SSLSocketFactory; | ||
|
||
import org.postgresql.core.PGStream; | ||
import org.postgresql.core.Logger; | ||
import org.postgresql.util.GT; | ||
import org.postgresql.util.PSQLState; | ||
import org.postgresql.util.PSQLException; | ||
|
||
public class AbstractJdbc3MakeSSL { | ||
public static void convert(PGStream stream, Properties info, Logger logger) throws IOException, PSQLException { | ||
logger.debug("converting regular socket connection to ssl"); | ||
|
||
SSLSocketFactory factory; | ||
|
||
// Use the default factory if no specific factory is requested | ||
// | ||
String classname = info.getProperty("sslfactory"); | ||
if (classname == null) | ||
{ | ||
factory = (SSLSocketFactory)SSLSocketFactory.getDefault(); | ||
} | ||
else | ||
{ | ||
Object[] args = {info.getProperty("sslfactoryarg")}; | ||
Constructor ctor; | ||
Class factoryClass; | ||
|
||
try | ||
{ | ||
factoryClass = Class.forName(classname); | ||
try | ||
{ | ||
ctor = factoryClass.getConstructor(new Class[]{String.class}); | ||
} | ||
catch (NoSuchMethodException nsme) | ||
{ | ||
ctor = factoryClass.getConstructor((Class[])null); | ||
args = null; | ||
} | ||
factory = (SSLSocketFactory)ctor.newInstance(args); | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new PSQLException(GT.tr("The SSLSocketFactory class provided {0} could not be instantiated.", classname), PSQLState.CONNECTION_FAILURE, e); | ||
} | ||
} | ||
|
||
Socket newConnection = factory.createSocket(stream.getSocket(), stream.getHost(), stream.getPort(), true); | ||
stream.changeSocket(newConnection); | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters