Skip to content

Commit

Permalink
datasource support
Browse files Browse the repository at this point in the history
  • Loading branch information
Suraiya Hameed committed Mar 8, 2017
1 parent 971fd93 commit f253da1
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import javax.naming.StringRefAddr;
import javax.sql.DataSource;

import org.ietf.jgss.GSSCredential;

/**
* This datasource lists properties specific for the SQLServerConnection class.
*/
Expand Down Expand Up @@ -175,6 +177,25 @@ public String getAuthentication() {
SQLServerDriverStringProperty.AUTHENTICATION.getDefaultValue());
}

/**
* sets GSSCredential
*
* @param userCredential
*/
public void setGSSCredentials(GSSCredential userCredential){
setObjectProperty(connectionProps,SQLServerDriverObjectProperty.GSS_CREDENTIAL.toString(), userCredential);
}

/**
* Retrieves the GSSCredential
*
* @return GSSCredential
*/
public GSSCredential getGSSCredentials(){
return (GSSCredential) getObjectProperty(connectionProps, SQLServerDriverObjectProperty.GSS_CREDENTIAL.toString(),
SQLServerDriverObjectProperty.GSS_CREDENTIAL.getDefaultValue());
}

/**
* Sets the access token.
*
Expand Down Expand Up @@ -772,6 +793,30 @@ private boolean getBooleanProperty(Properties props,
return value.booleanValue();
}

private void setObjectProperty(Properties props,
String propKey,
Object propValue) {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER)) {
loggerExternal.entering(getClassNameLogging(), "set" + propKey);
}
if (null != propValue) {
props.put(propKey, propValue);
}
loggerExternal.exiting(getClassNameLogging(), "set" + propKey);
}

private Object getObjectProperty(Properties props,
String propKey,
Object defaultValue) {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "get" + propKey);
Object propValue = props.get(propKey);
if (null == propValue)
propValue = defaultValue;
loggerExternal.exiting(getClassNameLogging(), "get" + propKey);
return propValue;
}

// Returns a SQLServerConnection given username, password, and pooledConnection.
// Note that the DataSource properties set to connectionProps are used when creating
// the connection.
Expand Down

0 comments on commit f253da1

Please sign in to comment.