private Conditions createConditions(TimePeriod tokenValidity,DelegationInfo delegationInfo,int renewCount,Set<String> audience){
  assert tokenValidity != null;
  assert tokenValidity.getStartTime() != null;
  assert tokenValidity.getEndTime() != null;
  assert delegationInfo != null;
  assert renewCount >= 0;
  assert audience != null;
  Conditions conditions=new ConditionsBuilder().buildObject();
  conditions.setNotBefore(new DateTime(tokenValidity.getStartTime()));
  conditions.setNotOnOrAfter(new DateTime(tokenValidity.getEndTime()));
  log.debug("Created conditions - notBefore: {}, notOnOrAfter: {}",tokenValidity.getStartTime(),tokenValidity.getEndTime());
  conditions.getConditions().add(createProxyRestriction(delegationInfo.getDelegationCount()));
  List<TokenDelegate> delegationChain=delegationInfo.getDelegationChain();
  if (delegationChain != null && delegationChain.size() > 0) {
    conditions.getConditions().add(createDelegationChain(delegationChain));
  }
  addRenewRestriction(conditions,renewCount);
  final AudienceRestriction audienceCondition=createAudienceRestriction(audience);
  if (audienceCondition != null) {
    conditions.getAudienceRestrictions().add(audienceCondition);
  }
  return conditions;
}

private Conditions createConditions ( TimePeriod tokenValidity , DelegationInfo delegationInfo , int renewCount , Set < String > audience ) { assert tokenValidity != null ; assert tokenValidity . getStartTime ( ) != null ; assert tokenValidity . getEndTime ( ) != null ; assert delegationInfo != null ; assert renewCount >= 0 ; assert audience != null ; Conditions conditions = new ConditionsBuilder ( ) . buildObject ( ) ; conditions . setNotBefore ( new DateTime ( tokenValidity . getStartTime ( ) ) ) ; conditions . setNotOnOrAfter ( new DateTime ( tokenValidity . getEndTime ( ) ) ) ; log . debug ( "Created conditions - notBefore: {}, notOnOrAfter: {}" , tokenValidity . getStartTime ( ) , tokenValidity . getEndTime ( ) ) ; conditions . getConditions ( ) . add ( createProxyRestriction ( delegationInfo . getDelegationCount ( ) ) ) ; List < TokenDelegate > delegationChain = delegationInfo . getDelegationChain ( ) ; if ( delegationChain != null && delegationChain . size ( ) > 0 ) { conditions . getConditions ( ) . add ( createDelegationChain ( delegationChain ) ) ; } addRenewRestriction ( conditions , renewCount ) ; final AudienceRestriction audienceCondition = createAudienceRestriction ( audience ) ; if ( audienceCondition != null ) { conditions . getAudienceRestrictions ( ) . add ( audienceCondition ) ; } return conditions ; }
creates conditions section of the token . inserts in it only notbefore and notonorafter attributes .
