diff --git a/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/internal/ClientAttestationMgtServiceComponent.java b/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/internal/ClientAttestationMgtServiceComponent.java index b227e997b047..faa0d5737d9a 100644 --- a/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/internal/ClientAttestationMgtServiceComponent.java +++ b/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/internal/ClientAttestationMgtServiceComponent.java @@ -44,6 +44,7 @@ import static org.wso2.carbon.identity.client.attestation.mgt.utils.Constants.APPLE_ATTESTATION_REVOCATION_CHECK_ENABLED; import static org.wso2.carbon.identity.client.attestation.mgt.utils.Constants.APPLE_ATTESTATION_ROOT_CERTIFICATE_PATH; import static org.wso2.carbon.identity.client.attestation.mgt.utils.Constants.CERTIFICATE_EXPIRY_THRESHOLD; +import static org.wso2.carbon.identity.client.attestation.mgt.utils.Constants.MILLI_SECOND_IN_DAY; /** * OSGi declarative services component which handled registration and un-registration of @@ -141,7 +142,7 @@ private boolean isCertificateExpiringSoon(X509Certificate certificate) { Date expirationDate = certificate.getNotAfter(); // Calculate the difference in days - long differenceInDays = (expirationDate.getTime() - currentDate.getTime()) / (24 * 60 * 60 * 1000); + long differenceInDays = (expirationDate.getTime() - currentDate.getTime()) / MILLI_SECOND_IN_DAY; // Check if the certificate is expiring within 3 months. return differenceInDays <= CERTIFICATE_EXPIRY_THRESHOLD; diff --git a/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/utils/Constants.java b/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/utils/Constants.java index 38f255b006c3..96bf3168165b 100644 --- a/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/utils/Constants.java +++ b/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/utils/Constants.java @@ -61,5 +61,7 @@ public enum ClientTypes { public static final String X_509_CERTIFICATE_TYPE = "X.509"; public static final String PKIX = "PKIX"; public static final int CERTIFICATE_EXPIRY_THRESHOLD = 90; + // Milli seconds in days 24 * 60 * 60 * 1000 + public static final int MILLI_SECOND_IN_DAY = 86400000; } diff --git a/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/validators/AppleAttestationValidator.java b/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/validators/AppleAttestationValidator.java index 85f3a4e668da..70cf0f2809c2 100644 --- a/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/validators/AppleAttestationValidator.java +++ b/components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/src/main/java/org/wso2/carbon/identity/client/attestation/mgt/validators/AppleAttestationValidator.java @@ -55,6 +55,7 @@ import static org.wso2.carbon.identity.client.attestation.mgt.utils.Constants.ATT_STMT; import static org.wso2.carbon.identity.client.attestation.mgt.utils.Constants.AUTH_DATA; import static org.wso2.carbon.identity.client.attestation.mgt.utils.Constants.CERTIFICATE_EXPIRY_THRESHOLD; +import static org.wso2.carbon.identity.client.attestation.mgt.utils.Constants.MILLI_SECOND_IN_DAY; import static org.wso2.carbon.identity.client.attestation.mgt.utils.Constants.PKIX; import static org.wso2.carbon.identity.client.attestation.mgt.utils.Constants.SHA_256; import static org.wso2.carbon.identity.client.attestation.mgt.utils.Constants.X5C; @@ -284,7 +285,7 @@ private boolean isCertificateExpiringSoon(X509Certificate certificate) { Date expirationDate = certificate.getNotAfter(); // Calculate the difference in days - long differenceInDays = (expirationDate.getTime() - currentDate.getTime()) / (24 * 60 * 60 * 1000); + long differenceInDays = (expirationDate.getTime() - currentDate.getTime()) / MILLI_SECOND_IN_DAY; // Check if the certificate is expiring within 3 months. return differenceInDays <= CERTIFICATE_EXPIRY_THRESHOLD;