com.identityx.auth.util.CertValidationResultCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of daon-http-digest-auth Show documentation
Show all versions of daon-http-digest-auth Show documentation
Client library used for adding authentication to http messages as required by IdentityX Rest Services
package com.identityx.auth.util;
import java.util.Date;
import java.util.HashMap;
public class CertValidationResultCache {
private static HashMap singleton = new HashMap();
private Date passedTime = null;
private int expiryTimeSec = 60 * 60 * 12;
public int getExpiryTimeSec() {
return expiryTimeSec;
}
public synchronized void setExpiryTimeSec(int expiryTimeSec) {
this.expiryTimeSec = expiryTimeSec;
}
protected CertValidationResultCache() {
}
public static CertValidationResultCache getInstance(String key) {
if(!singleton.containsKey(key)) {
synchronized(CertValidationResultCache.class) {
singleton.put(key, new CertValidationResultCache());
}
}
return singleton.get(key);
}
public synchronized void markPassedValidation() {
passedTime = new Date();
}
public synchronized void resetCache() {
passedTime = null;
}
public synchronized boolean isCached() {
if (passedTime == null) return false;
Date now = new Date();
if (now.getTime() - passedTime.getTime() < expiryTimeSec * 1000) {
return true;
}
else {
passedTime = null;
return false;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy