public void put(AuthTimeWithHash t,KerberosTime currentTime) throws KrbApErrException {
  if (entries.isEmpty()) {
    entries.addFirst(t);
  }
 else {
    AuthTimeWithHash temp=entries.getFirst();
    int cmp=temp.compareTo(t);
    if (cmp < 0) {
      entries.addFirst(t);
    }
 else     if (cmp == 0) {
      throw new KrbApErrException(Krb5.KRB_AP_ERR_REPEAT);
    }
 else {
      ListIterator<AuthTimeWithHash> it=entries.listIterator(1);
      boolean found=false;
      while (it.hasNext()) {
        temp=it.next();
        cmp=temp.compareTo(t);
        if (cmp < 0) {
          entries.add(entries.indexOf(temp),t);
          found=true;
          break;
        }
 else         if (cmp == 0) {
          throw new KrbApErrException(Krb5.KRB_AP_ERR_REPEAT);
        }
      }
      if (!found) {
        entries.addLast(t);
      }
    }
  }
  long timeLimit=currentTime.getSeconds() - lifespan;
  ListIterator<AuthTimeWithHash> it=entries.listIterator(0);
  AuthTimeWithHash temp=null;
  int index=-1;
  while (it.hasNext()) {
    temp=it.next();
    if (temp.ctime < timeLimit) {
      index=entries.indexOf(temp);
      break;
    }
  }
  if (index > -1) {
    do {
      entries.removeLast();
    }
 while (entries.size() > index);
  }
}

public void put ( AuthTimeWithHash t , KerberosTime currentTime ) throws KrbApErrException { if ( entries . isEmpty ( ) ) { entries . addFirst ( t ) ; } else { AuthTimeWithHash temp = entries . getFirst ( ) ; int cmp = temp . compareTo ( t ) ; if ( cmp < 0 ) { entries . addFirst ( t ) ; } else if ( cmp == 0 ) { throw new KrbApErrException ( Krb5 . KRB_AP_ERR_REPEAT ) ; } else { ListIterator < AuthTimeWithHash > it = entries . listIterator ( 1 ) ; boolean found = false ; while ( it . hasNext ( ) ) { temp = it . next ( ) ; cmp = temp . compareTo ( t ) ; if ( cmp < 0 ) { entries . add ( entries . indexOf ( temp ) , t ) ; found = true ; break ; } else if ( cmp == 0 ) { throw new KrbApErrException ( Krb5 . KRB_AP_ERR_REPEAT ) ; } } if ( ! found ) { entries . addLast ( t ) ; } } } long timeLimit = currentTime . getSeconds ( ) - lifespan ; ListIterator < AuthTimeWithHash > it = entries . listIterator ( 0 ) ; AuthTimeWithHash temp = null ; int index = - 1 ; while ( it . hasNext ( ) ) { temp = it . next ( ) ; if ( temp . ctime < timeLimit ) { index = entries . indexOf ( temp ) ; break ; } } if ( index > - 1 ) { do { entries . removeLast ( ) ; } while ( entries . size ( ) > index ) ; } }
puts the authenticator timestamp into the cache in descending order , and throw an exception if it ' s already there .
