protected final LifetimeType createLifetimeElement(long tokenLifetime){
  assert tokenLifetime > 0 : tokenLifetime;
  ObjectFactory wstFactory=new ObjectFactory();
  LifetimeType lifetime=wstFactory.createLifetimeType();
  org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_utility_1_0.ObjectFactory wssuObjFactory=new org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_utility_1_0.ObjectFactory();
  AttributedDateTime created=wssuObjFactory.createAttributedDateTime();
  DateFormat wssDateFormat=createDateFormatter();
  final long now=System.currentTimeMillis();
  String startDate=wssDateFormat.format(new Date(now));
  created.setValue(startDate);
  AttributedDateTime expires=wssuObjFactory.createAttributedDateTime();
  String endDate=wssDateFormat.format(new Date(now + TimeUnit.SECONDS.toMillis(tokenLifetime)));
  expires.setValue(endDate);
  lifetime.setCreated(created);
  lifetime.setExpires(expires);
  if (log.isDebugEnabled()) {
    log.debug("Lifitime created with following values -- Create date: " + startDate + " Expire date: "+ endDate);
  }
  return lifetime;
}

protected final LifetimeType createLifetimeElement ( long tokenLifetime ) { assert tokenLifetime > 0 : tokenLifetime ; ObjectFactory wstFactory = new ObjectFactory ( ) ; LifetimeType lifetime = wstFactory . createLifetimeType ( ) ; org . oasis_open . docs . wss . _2004 . _01 . oasis_200401_wss_wssecurity_utility_1_0 . ObjectFactory wssuObjFactory = new org . oasis_open . docs . wss . _2004 . _01 . oasis_200401_wss_wssecurity_utility_1_0 . ObjectFactory ( ) ; AttributedDateTime created = wssuObjFactory . createAttributedDateTime ( ) ; DateFormat wssDateFormat = createDateFormatter ( ) ; final long now = System . currentTimeMillis ( ) ; String startDate = wssDateFormat . format ( new Date ( now ) ) ; created . setValue ( startDate ) ; AttributedDateTime expires = wssuObjFactory . createAttributedDateTime ( ) ; String endDate = wssDateFormat . format ( new Date ( now + TimeUnit . SECONDS . toMillis ( tokenLifetime ) ) ) ; expires . setValue ( endDate ) ; lifetime . setCreated ( created ) ; lifetime . setExpires ( expires ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Lifitime created with following values -- Create date: " + startDate + " Expire date: " + endDate ) ; } return lifetime ; }
creates lifetime element . it is used to restrict token lifetime .
