// Path: src/main/java/org/ardverk/security/SecurityUtils.java
// public class SecurityUtils {
// 
//   private static final int SEED_LENGTH = 32;
//   
//   private SecurityUtils() {}
//   
//   /**
//    * Creates and returns a {@link SecureRandom}. The difference between
//    * this factory method and {@link SecureRandom}'s default constructor
//    * is that this will try to initialize the {@link SecureRandom} with
//    * an initial seed from /dev/urandom while the default constructor will
//    * attempt to do the same from /dev/random which may block if there is
//    * not enough data available.
//    */
//   public static SecureRandom createSecureRandom() {
//     // All Unix like Systems should have this device.
//     File file = new File("/dev/urandom");
//     
//     if (file.exists() && file.canRead()) {
//       try (DataInputStream in = new DataInputStream(new FileInputStream(file))) {
//         byte[] seed = new byte[SEED_LENGTH];
//         in.readFully(seed);
//         return new SecureRandom(seed);
//       } catch (SecurityException | IOException ignore) {}
//     }
//     
//     // We're either on Windows or something else happened.
//     return new SecureRandom();
//   }
// }


import java.io.Closeable;
import java.security.MessageDigest;
import java.util.Random;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.ardverk.concurrent.ExecutorUtils;
import org.ardverk.concurrent.FutureUtils;
import org.ardverk.security.SecurityUtils;
      Runnable task = new Runnable() {
        @Override
        public void run() {
          synchronized (keyLock) {
            previous = current;
            
            // Create a new byte[] of the same length
            current = new byte[current.length];
            random.nextBytes(current);
          }
        }
      };
      
      future = executor.scheduleWithFixedDelay(
          task, frequency, frequency, unit);
    }
    
    this.future = future;
  }
  
  @Override
  public void close() {
    FutureUtils.cancel(future, true);
  }
  
  @Override
  public byte[] create(byte[] data, int offset, int length) {
    
    byte[] current = null;
    synchronized (keyLock) {
// Path: src/main/java/org/ardverk/security/SecurityUtils.java
// public class SecurityUtils {
// 
//   private static final int SEED_LENGTH = 32;
//   
//   private SecurityUtils() {}
//   
//   /**
//    * Creates and returns a {@link SecureRandom}. The difference between
//    * this factory method and {@link SecureRandom}'s default constructor
//    * is that this will try to initialize the {@link SecureRandom} with
//    * an initial seed from /dev/urandom while the default constructor will
//    * attempt to do the same from /dev/random which may block if there is
//    * not enough data available.
//    */
//   public static SecureRandom createSecureRandom() {
//     // All Unix like Systems should have this device.
//     File file = new File("/dev/urandom");
//     
//     if (file.exists() && file.canRead()) {
//       try (DataInputStream in = new DataInputStream(new FileInputStream(file))) {
//         byte[] seed = new byte[SEED_LENGTH];
//         in.readFully(seed);
//         return new SecureRandom(seed);
//       } catch (SecurityException | IOException ignore) {}
//     }
//     
//     // We're either on Windows or something else happened.
//     return new SecureRandom();
//   }
// }


// Path: src/main/java/org/ardverk/security/token/DefaultSecurityToken.java
import java.io.Closeable;
import java.security.MessageDigest;
import java.util.Random;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.ardverk.concurrent.ExecutorUtils;
import org.ardverk.concurrent.FutureUtils;
import org.ardverk.security.SecurityUtils;

      Runnable task = new Runnable() {
        @Override
        public void run() {
          synchronized (keyLock) {
            previous = current;
            
            // Create a new byte[] of the same length
            current = new byte[current.length];
            random.nextBytes(current);
          }
        }
      };
      
      future = executor.scheduleWithFixedDelay(
          task, frequency, frequency, unit);
    }
    
    this.future = future;
  }
  
  @Override
  public void close() {
    FutureUtils.cancel(future, true);
  }
  
  @Override
  public byte[] create(byte[] data, int offset, int length) {
    
    byte[] current = null;
    synchronized (keyLock) {
      current = this.current;