no.difi.certvalidator.parser.ExpirationRuleParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-certvalidator Show documentation
Show all versions of commons-certvalidator Show documentation
Rule engine for creation of certificate validator.
package no.difi.certvalidator.parser;
import no.difi.certvalidator.api.ValidatorRule;
import no.difi.certvalidator.api.ValidatorRuleParser;
import no.difi.certvalidator.jaxb.ExpirationType;
import no.difi.certvalidator.rule.ExpirationRule;
import no.difi.certvalidator.rule.ExpirationSoonRule;
import org.kohsuke.MetaInfServices;
import java.util.Map;
/**
* @author erlend
*/
@MetaInfServices
public class ExpirationRuleParser implements ValidatorRuleParser {
@Override
public boolean supports(Class cls) {
return ExpirationType.class.equals(cls);
}
@Override
public ValidatorRule parse(Object o, Map objectStorage) {
ExpirationType expirationType = (ExpirationType) o;
if (expirationType.getMillis() == null)
return new ExpirationRule();
else
return new ExpirationSoonRule(expirationType.getMillis());
}
}