public boolean expired() { Date expirationDate = DateUtil.fromISOString(m_expiration).getTime(); return new Date().after(expirationDate); }
public void visit(Element element) { if (element.getLocalName().equals("Session")) { sessionInfo.m_id = element.getAttribute("id"); try { sessionInfo.m_expiry = DateUtil.fromISOString(element.getAttribute("expirationDate")).getTime(); sessionInfo.m_lastUpdate = DateUtil.fromISOString(element.getAttribute("lastUpdate")).getTime(); sessionInfo.m_createdAt = DateUtil.fromISOString(element.getAttribute("createdAt")).getTime(); } catch (IllegalArgumentException e) { throw new SessionCreationException("Error while creating SessionInfo from XML: " + e, e); } } else if (element.getLocalName().equals("Name")) { sessionInfo.m_issuerName = element.getTextContent(); } else if (element.getLocalName().equals("URL")) { sessionInfo.m_issuerURL = element.getTextContent(); } else if (element.getLocalName().equals("Status")) { sessionInfo.m_status = element.getTextContent(); } }
/** * Validates the usage properties of this reference, with respect to time clock differences. * * @param timeDelta * allowed delta in msec. * @throws RuntimeException * if error occurs. */ @Override public void validate(final long timeDelta) throws RuntimeException { // check the time constrains if present Calendar actualDate = Calendar.getInstance(); String notbeforDate = (String) m_attributes.get(NOTBEFORE); if (notbeforDate != null) { Calendar notBefore = DateUtil.fromISOString(notbeforDate); notBefore.setTimeInMillis(notBefore.getTimeInMillis() - timeDelta); if (actualDate.before(notBefore)) { throw new IllegalStateException("License reference cannot be applied before <" + notbeforDate + ">"); } } String notOnOrAfterDate = (String) m_attributes.get(NOTONORAFTER); if (notOnOrAfterDate != null) { Calendar notOnOrAfter = DateUtil.fromISOString(notOnOrAfterDate); notOnOrAfter.setTimeInMillis(notOnOrAfter.getTimeInMillis() + timeDelta); if (actualDate.equals(notOnOrAfter) || actualDate.after(notOnOrAfter)) { throw new IllegalStateException("License reference cannot be applied on or after <" + notOnOrAfterDate + ">"); } } }