304 |
|
final ThreadGroup egroup = Thread.currentThread().getThreadGroup(); |
305 |
|
Runnable r = new Runnable() { |
306 |
|
public void run() { |
307 |
< |
try { |
308 |
< |
Thread current = Thread.currentThread(); |
309 |
< |
threadAssertTrue(!current.isDaemon()); |
310 |
< |
threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY); |
311 |
< |
ThreadGroup g = current.getThreadGroup(); |
312 |
< |
SecurityManager s = System.getSecurityManager(); |
313 |
< |
if (s != null) |
314 |
< |
threadAssertTrue(g == s.getThreadGroup()); |
315 |
< |
else |
316 |
< |
threadAssertTrue(g == egroup); |
317 |
< |
String name = current.getName(); |
318 |
< |
threadAssertTrue(name.endsWith("thread-1")); |
319 |
< |
} catch (SecurityException ok) { |
320 |
< |
// Also pass if not allowed to change setting |
321 |
< |
} |
307 |
> |
try { |
308 |
> |
Thread current = Thread.currentThread(); |
309 |
> |
threadAssertTrue(!current.isDaemon()); |
310 |
> |
threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY); |
311 |
> |
ThreadGroup g = current.getThreadGroup(); |
312 |
> |
SecurityManager s = System.getSecurityManager(); |
313 |
> |
if (s != null) |
314 |
> |
threadAssertTrue(g == s.getThreadGroup()); |
315 |
> |
else |
316 |
> |
threadAssertTrue(g == egroup); |
317 |
> |
String name = current.getName(); |
318 |
> |
threadAssertTrue(name.endsWith("thread-1")); |
319 |
> |
} catch (SecurityException ok) { |
320 |
> |
// Also pass if not allowed to change setting |
321 |
> |
} |
322 |
|
} |
323 |
|
}; |
324 |
|
ExecutorService e = Executors.newSingleThreadExecutor(Executors.defaultThreadFactory()); |
357 |
|
final AccessControlContext thisacc = AccessController.getContext(); |
358 |
|
Runnable r = new Runnable() { |
359 |
|
public void run() { |
360 |
< |
try { |
361 |
< |
Thread current = Thread.currentThread(); |
362 |
< |
threadAssertTrue(!current.isDaemon()); |
363 |
< |
threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY); |
364 |
< |
ThreadGroup g = current.getThreadGroup(); |
365 |
< |
SecurityManager s = System.getSecurityManager(); |
366 |
< |
if (s != null) |
367 |
< |
threadAssertTrue(g == s.getThreadGroup()); |
368 |
< |
else |
369 |
< |
threadAssertTrue(g == egroup); |
370 |
< |
String name = current.getName(); |
371 |
< |
threadAssertTrue(name.endsWith("thread-1")); |
372 |
< |
threadAssertTrue(thisccl == current.getContextClassLoader()); |
373 |
< |
threadAssertTrue(thisacc.equals(AccessController.getContext())); |
374 |
< |
} catch (SecurityException ok) { |
375 |
< |
// Also pass if not allowed to change settings |
376 |
< |
} |
360 |
> |
try { |
361 |
> |
Thread current = Thread.currentThread(); |
362 |
> |
threadAssertTrue(!current.isDaemon()); |
363 |
> |
threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY); |
364 |
> |
ThreadGroup g = current.getThreadGroup(); |
365 |
> |
SecurityManager s = System.getSecurityManager(); |
366 |
> |
if (s != null) |
367 |
> |
threadAssertTrue(g == s.getThreadGroup()); |
368 |
> |
else |
369 |
> |
threadAssertTrue(g == egroup); |
370 |
> |
String name = current.getName(); |
371 |
> |
threadAssertTrue(name.endsWith("thread-1")); |
372 |
> |
threadAssertTrue(thisccl == current.getContextClassLoader()); |
373 |
> |
threadAssertTrue(thisacc.equals(AccessController.getContext())); |
374 |
> |
} catch (SecurityException ok) { |
375 |
> |
// Also pass if not allowed to change settings |
376 |
> |
} |
377 |
|
} |
378 |
|
}; |
379 |
|
ExecutorService e = Executors.newSingleThreadExecutor(Executors.privilegedThreadFactory()); |
413 |
|
* privilegedCallableUsingCurrentClassLoader throws ACE |
414 |
|
*/ |
415 |
|
public void testCreatePrivilegedCallableUsingCCLWithNoPrivs() { |
416 |
< |
Policy savedPolicy = null; |
416 |
> |
Policy savedPolicy = null; |
417 |
|
try { |
418 |
|
savedPolicy = Policy.getPolicy(); |
419 |
|
AdjustablePolicy policy = new AdjustablePolicy(); |
445 |
|
* privilegedCallableUsingCurrentClassLoader does not throw ACE |
446 |
|
*/ |
447 |
|
public void testprivilegedCallableUsingCCLWithPrivs() throws Exception { |
448 |
< |
Policy savedPolicy = null; |
448 |
> |
Policy savedPolicy = null; |
449 |
|
try { |
450 |
|
savedPolicy = Policy.getPolicy(); |
451 |
|
AdjustablePolicy policy = new AdjustablePolicy(); |
506 |
|
* With permissions, calling privilegedCallable succeeds |
507 |
|
*/ |
508 |
|
public void testprivilegedCallableWithPrivs() throws Exception { |
509 |
< |
Policy savedPolicy = null; |
509 |
> |
Policy savedPolicy = null; |
510 |
|
try { |
511 |
|
savedPolicy = Policy.getPolicy(); |
512 |
|
AdjustablePolicy policy = new AdjustablePolicy(); |