Skip to content

Commit

Permalink
TEIID-3165 updating property handling
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Oct 9, 2014
1 parent c7ed712 commit 247567f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
22 changes: 13 additions & 9 deletions client/src/main/java/org/teiid/jdbc/TeiidDataSource.java
Expand Up @@ -149,12 +149,23 @@ protected Properties buildProperties(final String userName, final String passwor

if (getLoginTimeout() > 0) {
props.setProperty(TeiidURL.CONNECTION.LOGIN_TIMEOUT, String.valueOf(getLoginTimeout()));
}
}

if (getJaasName() != null) {
props.setProperty(TeiidURL.CONNECTION.JAAS_NAME, getJaasName());
}
if (getKerberosServicePrincipleName() != null) {
props.setProperty(TeiidURL.CONNECTION.KERBEROS_SERVICE_PRINCIPLE_NAME, getKerberosServicePrincipleName());
}

return props;
}

protected String buildServerURL() throws TeiidSQLException {
protected String buildServerURL() throws TeiidSQLException {
if (serverName == null) {
return null;
}

if ( this.alternateServers == null || this.alternateServers.length() == 0) {
// Format: "mm://server:port"
return new TeiidURL(this.serverName, this.portNumber, this.secure).getAppServerURL();
Expand Down Expand Up @@ -276,13 +287,6 @@ public Connection getConnection(String userName, String password) throws java.sq
private Properties buildEmbeddedProperties(final String userName, final String password) {
Properties props = buildProperties(userName, password);
props.setProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION, Boolean.toString(this.passthroughAuthentication));

if (getJaasName() != null) {
props.setProperty(TeiidURL.CONNECTION.JAAS_NAME, getJaasName());
}
if (getKerberosServicePrincipleName() != null) {
props.setProperty(TeiidURL.CONNECTION.KERBEROS_SERVICE_PRINCIPLE_NAME, getKerberosServicePrincipleName());
}
return props;
}

Expand Down
11 changes: 11 additions & 0 deletions client/src/test/java/org/teiid/jdbc/TestTeiidDataSource.java
Expand Up @@ -763,4 +763,15 @@ public void testGetConnectionWithUser() throws SQLException {
assertEquals("user", p.getProperty(BaseDataSource.USER_NAME));
}

public void testKerberos() throws SQLException {
TeiidDataSource tds = new TeiidDataSource();
tds.setDatabaseName("y");
tds.setUser("%25user");
tds.setJaasName("x");
tds.setKerberosServicePrincipleName("z");
tds.setServerName("t");
assertEquals("jdbc:teiid:y@mm://t:0;fetchSize=2048;ApplicationName=JDBC;user=%2525user;jaasName=x;VirtualDatabaseName=y;kerberosServicePrincipleName=z", tds.buildURL().getJDBCURL());

}

}

0 comments on commit 247567f

Please sign in to comment.