From e36b352a42882a4dfe9d91d497aab8b5a792a6d6 Mon Sep 17 00:00:00 2001 From: Nidhi Date: Mon, 11 Apr 2022 16:57:24 +0530 Subject: [PATCH] fix: Conversion logic for expires in field (#12781) --- .../com/external/connections/OAuth2AuthorizationCode.java | 4 ++-- .../com/external/connections/OAuth2ClientCredentials.java | 4 ++-- .../server/solutions/ce/AuthenticationServiceCEImpl.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2AuthorizationCode.java b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2AuthorizationCode.java index 60b0f8a368..4c2de06b2e 100644 --- a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2AuthorizationCode.java +++ b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2AuthorizationCode.java @@ -142,9 +142,9 @@ public class OAuth2AuthorizationCode extends APIConnection implements UpdatableC Object expiresInResponse = mappedResponse.get(Authentication.EXPIRES_IN); Instant expiresAt = null; if (expiresAtResponse != null) { - expiresAt = Instant.ofEpochSecond(Long.valueOf((Integer) expiresAtResponse)); + expiresAt = Instant.ofEpochSecond(Long.parseLong(String.valueOf(expiresAtResponse))); } else if (expiresInResponse != null) { - expiresAt = issuedAt.plusSeconds(Long.valueOf((Integer) expiresInResponse)); + expiresAt = issuedAt.plusSeconds(Long.parseLong(String.valueOf(expiresInResponse))); } authenticationResponse.setExpiresAt(expiresAt); authenticationResponse.setIssuedAt(issuedAt); diff --git a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2ClientCredentials.java b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2ClientCredentials.java index 7ab38c825e..542936096e 100644 --- a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2ClientCredentials.java +++ b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/connections/OAuth2ClientCredentials.java @@ -111,9 +111,9 @@ public class OAuth2ClientCredentials extends APIConnection implements UpdatableC Object expiresInResponse = mappedResponse.get(Authentication.EXPIRES_IN); Instant expiresAt = null; if (expiresAtResponse != null) { - expiresAt = Instant.ofEpochSecond(Long.parseLong((String) expiresAtResponse)); + expiresAt = Instant.ofEpochSecond(Long.parseLong(String.valueOf(expiresAtResponse))); } else if (expiresInResponse != null) { - expiresAt = issuedAt.plusSeconds(Long.valueOf((Integer) expiresInResponse)); + expiresAt = issuedAt.plusSeconds(Long.parseLong(String.valueOf(expiresInResponse))); } authenticationResponse.setExpiresAt(expiresAt); authenticationResponse.setIssuedAt(issuedAt); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java index ca06edb7f7..c69441dbe6 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java @@ -230,9 +230,9 @@ public class AuthenticationServiceCEImpl implements AuthenticationServiceCE { Object expiresInResponse = response.get(Authentication.EXPIRES_IN); Instant expiresAt = null; if (expiresAtResponse != null) { - expiresAt = Instant.ofEpochSecond(Long.valueOf((Integer) expiresAtResponse)); + expiresAt = Instant.ofEpochSecond(Long.parseLong(String.valueOf(expiresAtResponse))); } else if (expiresInResponse != null) { - expiresAt = issuedAt.plusSeconds(Long.parseLong((String) expiresInResponse)); + expiresAt = issuedAt.plusSeconds(Long.parseLong(String.valueOf(expiresInResponse))); } authenticationResponse.setExpiresAt(expiresAt); // Replacing with returned scope instead