AAD password on non windows#146
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #146 +/- ##
============================================
- Coverage 27.32% 27.29% -0.03%
+ Complexity 1142 1140 -2
============================================
Files 95 97 +2
Lines 23279 23303 +24
Branches 3870 3871 +1
============================================
+ Hits 6360 6361 +1
- Misses 15641 15661 +20
- Partials 1278 1281 +3
Continue to review full report at Codecov.
|
v-nisidh
left a comment
There was a problem hiding this comment.
Approved with comments.
| if (authenticationString.trim().equalsIgnoreCase(SqlAuthentication.ActiveDirectoryPassword.toString())) { | ||
| dllInfo = AuthenticationJNI.getAccessToken(user, password, fedAuthInfo.stsurl, fedAuthInfo.spn, clientConnectionId.toString(), | ||
| ActiveDirectoryAuthentication.jdbcFedauthClientId, expirationFileTime); | ||
| if (authenticationString.trim().equalsIgnoreCase(SqlAuthentication.ActiveDirectoryPassword.toString())) { |
There was a problem hiding this comment.
Better to have constant on left side while comparing.
There was a problem hiding this comment.
I totally agree, but there are a lot of places to change in the driver, maybe we can have a separate PR for this?
| if ((!System.getProperty("os.name").toLowerCase().startsWith("windows")) | ||
| && (!authenticationString.equalsIgnoreCase(SqlAuthentication.NotSpecified.toString()))) { | ||
| throw new SQLServerException(SQLServerException.getErrString("R_FedAuthOnNonWindows"), null); | ||
| && (authenticationString.equalsIgnoreCase(SqlAuthentication.ActiveDirectoryIntegrated.toString()))) { |
There was a problem hiding this comment.
in getFedAuthToken(..) we have similar check of ActiveDirectoryPassword. There we used authenticationString.trim(). Is there any possibility that we are getting authenticationString as null?
There was a problem hiding this comment.
no, the default is NotSpecified, it cannot be null. you can search for this line in the file and you will see:
sPropValue = SQLServerDriverStringProperty.AUTHENTICATION.getDefaultValue();
| assert null != dllInfo.accessTokenBytes; | ||
| // the cause error message uses \\n\\r which does not give correct format | ||
| // change it to \r\n to provide correct format | ||
| String correctedErrorMessage = e.getCause().getMessage().replaceAll("\\\\r\\\\n", "\r\n"); |
There was a problem hiding this comment.
Do we have any Negative JUnit Test cases ? Which will expect some exception / message / cause.
There was a problem hiding this comment.
yes, we have tests for AAD error messages
| if (authenticationString.trim().equalsIgnoreCase(SqlAuthentication.ActiveDirectoryPassword.toString())) { | ||
| ExecutorService executorService = Executors.newFixedThreadPool(1); | ||
| try { | ||
| AuthenticationContext context = new AuthenticationContext(fedAuthInfo.stsurl, false, executorService); |
There was a problem hiding this comment.
SUGGESTION: May be we can have ADALAuth.getAccesstoken() in which we can create AuthenctioanContext and acquireToken.
There was a problem hiding this comment.
good suggestion. It's done now, I have used modular approach now
| import com.microsoft.sqlserver.jdbc.SQLServerConnection.ActiveDirectoryAuthentication; | ||
| import com.microsoft.sqlserver.jdbc.SQLServerConnection.SqlFedAuthInfo; | ||
|
|
||
| class SQLServerADAL4JUtils { |
There was a problem hiding this comment.
Are you sure you do not want public class? By default this will use package level visibility.
There was a problem hiding this comment.
why would we want it to be public?
| private static final int GetAccessTokenTansisentError = 2; | ||
| private static final int GetAccessTokenOtherError = 3; | ||
| class ActiveDirectoryAuthentication { | ||
| static final String jdbcFedauthClientId = "7f98cb04-cd1e-40df-9140-3bf7e2cea4db"; |
There was a problem hiding this comment.
final static instance variables should be in CAPS
v-nisidh
left a comment
There was a problem hiding this comment.
Approved. Having 2 review comments.
No description provided.