isValid method with simple implementation
This commit is contained in:
Scott Battaglia 2013-01-06 18:45:05 -05:00
parent 1a6c1aa002
commit cec2e8e463
2 changed files with 17 additions and 0 deletions

View File

@ -69,4 +69,12 @@ public interface Assertion extends Serializable {
* @return the principal.
*/
AttributePrincipal getPrincipal();
/**
* Determines whether an Assertion is considered usable or not. A naive implementation may just check the date validity.
*
* @return true if its valid, false otherwise.
* @since 3.3.0 (though in 3.3.0, no one actually calls this)
*/
boolean isValid();
}

View File

@ -121,4 +121,13 @@ public final class AssertionImpl implements Assertion {
public AttributePrincipal getPrincipal() {
return this.principal;
}
public boolean isValid() {
if (this.validFromDate == null) {
return true;
}
final Date now = new Date();
return this.validFromDate.before(now) && (this.validUntilDate == null || this.validUntilDate.after(now));
}
}