diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java index 734bcf487..b49abe9bc 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java @@ -387,7 +387,7 @@ static SqlAuthenticationToken getManagedIdentityCredAuthToken(String resource, } else { AccessToken accessToken = accessTokenOptional.get(); sqlFedAuthToken = new SqlAuthenticationToken(accessToken.getToken(), - accessToken.getExpiresAt().toEpochSecond()); + accessToken.getExpiresAt().toInstant().toEpochMilli()); } if (logger.isLoggable(java.util.logging.Level.FINEST)) { @@ -471,7 +471,7 @@ static SqlAuthenticationToken getDefaultAzureCredAuthToken(String resource, } else { AccessToken accessToken = accessTokenOptional.get(); sqlFedAuthToken = new SqlAuthenticationToken(accessToken.getToken(), - accessToken.getExpiresAt().toEpochSecond()); + accessToken.getExpiresAt().toInstant().toEpochMilli()); } return sqlFedAuthToken; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SqlAuthenticationToken.java b/src/main/java/com/microsoft/sqlserver/jdbc/SqlAuthenticationToken.java index c57cd2268..5cba25cca 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SqlAuthenticationToken.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SqlAuthenticationToken.java @@ -24,12 +24,12 @@ public class SqlAuthenticationToken implements Serializable { private final String accessToken; /** - * Contructs a SqlAuthentication token. + * Constructs a SqlAuthentication token. * * @param accessToken * The access token string. * @param expiresOn - * The expiration date in seconds since the unix epoch. + * The expiration date in milliseconds since the unix epoch. */ public SqlAuthenticationToken(String accessToken, long expiresOn) { this.accessToken = accessToken; @@ -37,7 +37,7 @@ public SqlAuthenticationToken(String accessToken, long expiresOn) { } /** - * Contructs a SqlAuthentication token. + * Constructs a SqlAuthentication token. * * @param accessToken * The access token string. diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/TestUtils.java b/src/test/java/com/microsoft/sqlserver/jdbc/TestUtils.java index b17e86c0d..928a59490 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/TestUtils.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/TestUtils.java @@ -138,8 +138,8 @@ public SqlAuthenticationToken getAccessToken(String spn, String stsurl) { if (expireTokenToggle) { Date now = new Date(); - long minutesToExpireWithin = TEST_TOKEN_EXPIRY_SECONDS * 1000; // Expire within 2 minutes - return new SqlAuthenticationToken(accessToken, now.getTime() + minutesToExpireWithin); + long millisecondsToExpireWithin = TEST_TOKEN_EXPIRY_SECONDS * 1000; // Expire within 2 minutes + return new SqlAuthenticationToken(accessToken, now.getTime() + millisecondsToExpireWithin); } else { return new SqlAuthenticationToken(accessToken, expiresOn); }