Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,11 @@ static boolean isDllLoaded() {
}

static FedAuthDllInfo getAccessTokenForWindowsIntegrated(String stsURL, String servicePrincipalName,
String clientConnectionId, String clientId, long expirationFileTime) throws DLLException {
String clientConnectionId, String clientId) throws DLLException {
try {
lock.lock();

return ADALGetAccessTokenForWindowsIntegrated(stsURL, servicePrincipalName, clientConnectionId, clientId,
expirationFileTime, authLogger);
return MSQAGetAccessTokenForWindowsIntegrated(stsURL, servicePrincipalName, clientConnectionId, clientId, authLogger);
} finally {
lock.unlock();
}
Expand Down Expand Up @@ -164,9 +163,8 @@ private static native int SNISecGenClientContext(byte[] psec, int[] secptrsize,

private static native int GetDNSName(String address, String[] DNSName, java.util.logging.Logger log);

private static native FedAuthDllInfo ADALGetAccessTokenForWindowsIntegrated(String stsURL,
String servicePrincipalName, String clientConnectionId, String clientId, long expirationFileTime,
java.util.logging.Logger log);
private static native FedAuthDllInfo MSQAGetAccessTokenForWindowsIntegrated(String stsURL,
String servicePrincipalName, String clientConnectionId, String clientId, java.util.logging.Logger log);

static native byte[] DecryptColumnEncryptionKey(String masterKeyPath, String encryptionAlgorithm,
byte[] encryptedColumnEncryptionKey) throws DLLException;
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -6798,7 +6798,7 @@ private SqlAuthenticationToken getFedAuthToken(SqlFedAuthInfo fedAuthInfo) throw
try {
FedAuthDllInfo dllInfo = AuthenticationJNI.getAccessTokenForWindowsIntegrated(
fedAuthInfo.stsurl, fedAuthInfo.spn, clientConnectionId.toString(),
ActiveDirectoryAuthentication.JDBC_FEDAUTH_CLIENT_ID, 0);
ActiveDirectoryAuthentication.JDBC_FEDAUTH_CLIENT_ID);

// AccessToken should not be null.
assert null != dllInfo.accessTokenBytes;
Expand All @@ -6811,15 +6811,15 @@ private SqlAuthenticationToken getFedAuthToken(SqlFedAuthInfo fedAuthInfo) throw

// Break out of the retry loop in successful case.
break;
} catch (DLLException adalException) {
} catch (DLLException dllException) {

// the mssql-jdbc_auth DLL return -1 for errorCategory, if unable to load the
// adalsql DLL
int errorCategory = adalException.getCategory();
// The mssql-jdbc_auth DLL returns -1 for errorCategory if unable to load the
// mssql-auth.dll
int errorCategory = dllException.getCategory();
if (-1 == errorCategory) {
MessageFormat form = new MessageFormat(
SQLServerException.getErrString("R_UnableLoadADALSqlDll"));
Object[] msgArgs = { Integer.toHexString(adalException.getState()) };
SQLServerException.getErrString("R_UnableLoadMSSQLAuthDll"));
Object[] msgArgs = { Integer.toHexString(dllException.getState()) };
throw new SQLServerException(form.format(msgArgs), null);
}

Expand All @@ -6828,21 +6828,21 @@ private SqlAuthenticationToken getFedAuthToken(SqlFedAuthInfo fedAuthInfo) throw
|| timerHasExpired(timerExpire)
|| (fedauthSleepInterval >= millisecondsRemaining)) {

String errorStatus = Integer.toHexString(adalException.getStatus());
String errorStatus = Integer.toHexString(dllException.getStatus());

if (connectionlogger.isLoggable(Level.FINER)) {
connectionlogger.fine(
toString()
+ " SQLServerConnection.getFedAuthToken.AdalException category:"
+ " SQLServerConnection.getFedAuthToken.DLLException category:"
+ errorCategory + " error: " + errorStatus);
}

MessageFormat form = new MessageFormat(
SQLServerException.getErrString("R_ADALAuthenticationMiddleErrorMessage"));
String errorCode = Integer.toHexString(adalException.getStatus()).toUpperCase();
Object[] msgArgs1 = { errorCode, adalException.getState() };
String errorCode = Integer.toHexString(dllException.getStatus()).toUpperCase();
Object[] msgArgs1 = { errorCode, dllException.getState() };
SQLServerException middleException = new SQLServerException(form.format(msgArgs1),
adalException);
dllException);

form = new MessageFormat(SQLServerException.getErrString("R_MSALExecution"));
Object[] msgArgs = { user, authenticationString };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ protected Object[][] getContents() {
{"R_GenerateSignature", "Unable to generate signature using a specified Azure Key Vault Key URL."},
{"R_SignedHashLengthError", "Signed hash length does not match the RSA key size."},
{"R_InvalidSignatureComputed", "Invalid signature of the encrypted column encryption key computed."},
{"R_UnableLoadADALSqlDll", "Unable to load adalsql.dll. Error code: 0x{0}. For details, see: http://go.microsoft.com/fwlink/?LinkID=513072"},
{"R_UnableLoadMSSQLAuthDll", "Unable to load mssql-auth.dll. Error code: 0x{0}."},
{"R_ADALAuthenticationMiddleErrorMessage", "Error code 0x{0}; state {1}."},
{"R_unsupportedDataTypeTVP", "Data type {0} not supported in Table-Valued Parameter."},
{"R_moreDataInRowThanColumnInTVP", "Input array is longer than the number of columns in this table."},
Expand Down
Loading