Class: Cache
- Inherits:
-
Object
- Object
- Cache
- Defined in:
- lib/AuthenticationSDK/util/Cache.rb
Overview
P12 file certificate Cache
Instance Method Summary collapse
- #fetchCachedCertificate(filePath, p12File, keyPass, keyAlias, cacheObj) ⇒ Object
-
#fetchPEMFileForNetworkTokenization(filePath, cacheObj) ⇒ Object
DEPRECATED: This method has been marked as Deprecated and will be removed in coming releases.
- #getCertificate(p12File, keyPass, keyAlias, cacheObj, currentFileLastModifiedTime) ⇒ Object
Instance Method Details
#fetchCachedCertificate(filePath, p12File, keyPass, keyAlias, cacheObj) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/AuthenticationSDK/util/Cache.rb', line 6 def fetchCachedCertificate(filePath, p12File, keyPass, keyAlias, cacheObj) certCache = cacheObj.read(keyAlias.to_s.upcase) cachedLastModifiedTimeStamp = cacheObj.read(keyAlias.to_s.upcase + '_LastModifiedTime') if File.exist?(filePath) currentFileLastModifiedTime = File.mtime(filePath) if certCache.to_s.empty? || cachedLastModifiedTimeStamp.to_s.empty? certificateFromP12File = getCertificate(p12File, keyPass, keyAlias, cacheObj, currentFileLastModifiedTime) return certificateFromP12File elsif currentFileLastModifiedTime > cachedLastModifiedTimeStamp # Function call to read the file and put values to new cache certificateFromP12File = getCertificate(p12File, keyPass, keyAlias, cacheObj, currentFileLastModifiedTime) return certificateFromP12File else return certCache end else raise Constants::ERROR_PREFIX + Constants::FILE_NOT_FOUND + filePath end end |
#fetchPEMFileForNetworkTokenization(filePath, cacheObj) ⇒ Object
DEPRECATED: This method has been marked as Deprecated and will be removed in coming releases.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/AuthenticationSDK/util/Cache.rb', line 34 def fetchPEMFileForNetworkTokenization(filePath, cacheObj) warn("[DEPRECATED] 'fetchPEMFileForNetworkTokenization' method is deprecated and will be removed in coming releases.") pem_file_cache = cacheObj.read('privateKeyFromPEMFile') cached_pem_file_last_updated_time = cacheObj.read('cachedLastModifiedTimeOfPEMFile') if File.exist?(filePath) current_last_modified_time_of_PEM_file = File.mtime(filePath) if pem_file_cache.nil? || pem_file_cache.to_s.empty? || current_last_modified_time_of_PEM_file > cached_pem_file_last_updated_time private_key = JOSE::JWK.from_pem_file filePath cacheObj.write('privateKeyFromPEMFile', private_key) cacheObj.write('cachedLastModifiedTimeOfPEMFile', current_last_modified_time_of_PEM_file) end end return cacheObj.read('privateKeyFromPEMFile') end |
#getCertificate(p12File, keyPass, keyAlias, cacheObj, currentFileLastModifiedTime) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/AuthenticationSDK/util/Cache.rb', line 26 def getCertificate(p12File, keyPass, keyAlias, cacheObj, currentFileLastModifiedTime) x5CertDer = Utility.new.fetchCert(keyPass, p12File, keyAlias) cacheObj.write(keyAlias.to_s.upcase, x5CertDer) cacheObj.write(keyAlias.to_s.upcase + '_LastModifiedTime', currentFileLastModifiedTime) x5CertDer end |