Skip to content

Commit f253da1

Browse files
author
Suraiya Hameed
committed
datasource support
1 parent 971fd93 commit f253da1

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java

+45
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import javax.naming.StringRefAddr;
2323
import javax.sql.DataSource;
2424

25+
import org.ietf.jgss.GSSCredential;
26+
2527
/**
2628
* This datasource lists properties specific for the SQLServerConnection class.
2729
*/
@@ -175,6 +177,25 @@ public String getAuthentication() {
175177
SQLServerDriverStringProperty.AUTHENTICATION.getDefaultValue());
176178
}
177179

180+
/**
181+
* sets GSSCredential
182+
*
183+
* @param userCredential
184+
*/
185+
public void setGSSCredentials(GSSCredential userCredential){
186+
setObjectProperty(connectionProps,SQLServerDriverObjectProperty.GSS_CREDENTIAL.toString(), userCredential);
187+
}
188+
189+
/**
190+
* Retrieves the GSSCredential
191+
*
192+
* @return GSSCredential
193+
*/
194+
public GSSCredential getGSSCredentials(){
195+
return (GSSCredential) getObjectProperty(connectionProps, SQLServerDriverObjectProperty.GSS_CREDENTIAL.toString(),
196+
SQLServerDriverObjectProperty.GSS_CREDENTIAL.getDefaultValue());
197+
}
198+
178199
/**
179200
* Sets the access token.
180201
*
@@ -772,6 +793,30 @@ private boolean getBooleanProperty(Properties props,
772793
return value.booleanValue();
773794
}
774795

796+
private void setObjectProperty(Properties props,
797+
String propKey,
798+
Object propValue) {
799+
if (loggerExternal.isLoggable(java.util.logging.Level.FINER)) {
800+
loggerExternal.entering(getClassNameLogging(), "set" + propKey);
801+
}
802+
if (null != propValue) {
803+
props.put(propKey, propValue);
804+
}
805+
loggerExternal.exiting(getClassNameLogging(), "set" + propKey);
806+
}
807+
808+
private Object getObjectProperty(Properties props,
809+
String propKey,
810+
Object defaultValue) {
811+
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
812+
loggerExternal.entering(getClassNameLogging(), "get" + propKey);
813+
Object propValue = props.get(propKey);
814+
if (null == propValue)
815+
propValue = defaultValue;
816+
loggerExternal.exiting(getClassNameLogging(), "get" + propKey);
817+
return propValue;
818+
}
819+
775820
// Returns a SQLServerConnection given username, password, and pooledConnection.
776821
// Note that the DataSource properties set to connectionProps are used when creating
777822
// the connection.

0 commit comments

Comments
 (0)