@Test public void testGetProviderWritesToRandomDeviceOnFirstCall() throws Exception { if (!(OsUtils.isLinux())) { System.err.println("WARNING: Skipping test, can't run on this OS"); return; } File urandom = new File(testDir, "urandom"); urandom.delete(); assertTrue(urandom.createNewFile()); assertEquals(0, urandom.length()); LinuxSecureRandomProvider p = new LinuxSecureRandomProvider(urandom); Provider provider = p.getProvider(); assertNotNull(provider); assertEquals("LinuxPRNG", provider.getName()); long length = urandom.length(); assertTrue(length >= 24); provider = p.getProvider(); assertNotNull(provider); assertEquals("LinuxPRNG", provider.getName()); assertEquals(length, urandom.length()); }
@Override public Provider getProvider() { if (!seeded.getAndSet(true)) writeSeed(); return new LinuxProvider(); }
LinuxSecureRandomProvider extends AbstractSecureRandomProvider { @Override public Provider getProvider() { if (!seeded.getAndSet(true)) writeSeed(); return new LinuxProvider(); } }
LinuxSecureRandomProvider extends AbstractSecureRandomProvider { @Override public Provider getProvider() { if (!seeded.getAndSet(true)) writeSeed(); return new LinuxProvider(); } LinuxSecureRandomProvider();   LinuxSecureRandomProvider(File outputDevice); }
LinuxSecureRandomProvider extends AbstractSecureRandomProvider { @Override public Provider getProvider() { if (!seeded.getAndSet(true)) writeSeed(); return new LinuxProvider(); } LinuxSecureRandomProvider();   LinuxSecureRandomProvider(File outputDevice); @Override Provider getProvider(); }
LinuxSecureRandomProvider extends AbstractSecureRandomProvider { @Override public Provider getProvider() { if (!seeded.getAndSet(true)) writeSeed(); return new LinuxProvider(); } LinuxSecureRandomProvider();   LinuxSecureRandomProvider(File outputDevice); @Override Provider getProvider();  }