* Create a LifetimeType object given a created + expires Dates
*/
protected static LifetimeType createLifetime(
Date tokenCreated, Date tokenExpires
) {
AttributedDateTime created = QNameConstants.UTIL_FACTORY.createAttributedDateTime();
AttributedDateTime expires = QNameConstants.UTIL_FACTORY.createAttributedDateTime();
Date creationTime = tokenCreated;
if (creationTime == null) {
creationTime = new Date();
}
Date expirationTime = tokenExpires;
if (expirationTime == null) {
expirationTime = new Date();
long lifeTimeOfToken = 300L;
expirationTime.setTime(creationTime.getTime() + (lifeTimeOfToken * 1000L));
}
XmlSchemaDateFormat fmt = new XmlSchemaDateFormat();
created.setValue(fmt.format(creationTime));
LOG.fine("Token lifetime creation: " + created.getValue());
expires.setValue(fmt.format(expirationTime));
LOG.fine("Token lifetime expiration: " + expires.getValue());
LifetimeType lifetimeType = QNameConstants.WS_TRUST_FACTORY.createLifetimeType();
lifetimeType.setCreated(created);
lifetimeType.setExpires(expires);
return lifetimeType;