equal
deleted
inserted
replaced
149 final MessageDigest md; |
149 final MessageDigest md; |
150 |
150 |
151 try { |
151 try { |
152 md = MessageDigest.getInstance("SHA"); |
152 md = MessageDigest.getInstance("SHA"); |
153 } catch (NoSuchAlgorithmException nsae) { |
153 } catch (NoSuchAlgorithmException nsae) { |
154 throw new InternalError("internal error: SHA-1 not available."); |
154 throw new InternalError("internal error: SHA-1 not available." |
|
155 , nsae); |
155 } |
156 } |
156 |
157 |
157 // The current time in millis |
158 // The current time in millis |
158 byte b =(byte)System.currentTimeMillis(); |
159 byte b =(byte)System.currentTimeMillis(); |
159 md.update(b); |
160 md.update(b); |
256 MessageDigest digest; |
257 MessageDigest digest; |
257 |
258 |
258 try { |
259 try { |
259 digest = MessageDigest.getInstance("SHA"); |
260 digest = MessageDigest.getInstance("SHA"); |
260 } catch (NoSuchAlgorithmException e) { |
261 } catch (NoSuchAlgorithmException e) { |
261 throw new InternalError("internal error: SHA-1 not available."); |
262 throw new InternalError("internal error: SHA-1 not available." |
|
263 , e); |
262 } |
264 } |
263 |
265 |
264 final ThreadGroup[] finalsg = new ThreadGroup[1]; |
266 final ThreadGroup[] finalsg = new ThreadGroup[1]; |
265 Thread t = java.security.AccessController.doPrivileged |
267 Thread t = java.security.AccessController.doPrivileged |
266 (new java.security.PrivilegedAction<Thread>() { |
268 (new java.security.PrivilegedAction<Thread>() { |
309 Thread t = new Thread |
311 Thread t = new Thread |
310 (seedGroup, bt, "SeedGenerator Thread"); |
312 (seedGroup, bt, "SeedGenerator Thread"); |
311 t.start(); |
313 t.start(); |
312 } catch (Exception e) { |
314 } catch (Exception e) { |
313 throw new InternalError("internal error: " + |
315 throw new InternalError("internal error: " + |
314 "SeedGenerator thread creation error."); |
316 "SeedGenerator thread creation error." |
|
317 , e); |
315 } |
318 } |
316 |
319 |
317 // We wait 250milli quanta, so the minimum wait time |
320 // We wait 250milli quanta, so the minimum wait time |
318 // cannot be under 250milli. |
321 // cannot be under 250milli. |
319 int latch = 0; |
322 int latch = 0; |
342 notifyAll(); |
345 notifyAll(); |
343 } |
346 } |
344 } |
347 } |
345 } catch (Exception e) { |
348 } catch (Exception e) { |
346 throw new InternalError("internal error: " + |
349 throw new InternalError("internal error: " + |
347 "SeedGenerator thread generated an exception."); |
350 "SeedGenerator thread generated an exception." |
|
351 , e); |
348 } |
352 } |
349 } |
353 } |
350 |
354 |
351 @Override |
355 @Override |
352 void getSeedBytes(byte[] result) { |
356 void getSeedBytes(byte[] result) { |
365 wait(); |
369 wait(); |
366 } |
370 } |
367 } catch (Exception e) { |
371 } catch (Exception e) { |
368 if (count <= 0) |
372 if (count <= 0) |
369 throw new InternalError("internal error: " + |
373 throw new InternalError("internal error: " + |
370 "SeedGenerator thread generated an exception."); |
374 "SeedGenerator thread generated an exception." |
|
375 ,e); |
371 } |
376 } |
372 |
377 |
373 synchronized(this) { |
378 synchronized(this) { |
374 // Get it from the queue |
379 // Get it from the queue |
375 b = pool[start]; |
380 b = pool[start]; |
531 read += count; |
536 read += count; |
532 } |
537 } |
533 } catch (IOException ioe) { |
538 } catch (IOException ioe) { |
534 throw new InternalError("URLSeedGenerator " + deviceName + |
539 throw new InternalError("URLSeedGenerator " + deviceName + |
535 " generated exception: " + |
540 " generated exception: " + |
536 ioe.getMessage()); |
541 ioe.getMessage(), ioe); |
537 } |
542 } |
538 } |
543 } |
539 |
544 |
540 } |
545 } |
541 } |
546 } |