package at.gv.egiz.pdfas.api.timestamp; import java.util.Date; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Dummy/test implementation of the timestamper. Logs and stores test-timestamp for assertion {@link #getLastTimeStamp()} * * @author dferbas * */ public class DummyTimeStamper implements TimeStamper { private static Log log = LogFactory.getLog(DummyTimeStamper.class); private String lastTimeStamp; public String applyTimeStamp(String b64SignatureValue) { log.debug("Applying dummy timestamp on signature value: " + b64SignatureValue); String ts = DateFormatUtils.format(new Date(), "yyyy-MM-dd'T'hh:mm:ss.SSSZ"); log.debug("Timestamp: " + ts); ts = new String(Base64.encodeBase64(ts.getBytes())); log.debug("Timestamp value (base64): " + ts); this.lastTimeStamp = ts; return ts; } public String getLastTimeStamp() { return this.lastTimeStamp; } public void setLastTimeStamp(String lastTimeStamp) { this.lastTimeStamp = lastTimeStamp; } }