Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ public static void register() {
public static void initialize(String prefix) {
Assert.assertNotNull(prefix);

if (! (System.getSecurityManager() instanceof CountingSecurityManager)) {
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);
}
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);

if (!System.getSecurityManager().getClass().getName().equals(CountingSecurityManager.class.getName())) {
throw new IllegalStateException("Wrong security manager: " + System.getSecurityManager());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ public enum Mode {
public static void initialize(String prefix, Mode mode, Set<String> allowedFiles) {
System.setProperty("counting.security.disabled", "true");

if (System.getSecurityManager() instanceof CountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new CountingSecurityManager());
}
System.setSecurityManager(new CountingSecurityManager());
setCnt(0);
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand All @@ -113,7 +109,6 @@ public static void initialize(String prefix, Mode mode, Set<String> allowedFiles
static void assertReflection(int maxCount, String whitelist) {
System.setProperty("counting.reflection.whitelist", whitelist);
RuntimePermission checkMemberAccessPermission = new RuntimePermission("accessDeclaredMembers");
System.getSecurityManager().checkPermission(checkMemberAccessPermission);
System.getProperties().remove("counting.reflection.whitelist");
}

Expand All @@ -127,7 +122,7 @@ public Integer call() throws Exception {
}

public static boolean isEnabled() {
return System.getSecurityManager() instanceof Callable<?>;
return false;
}

public static void assertCounts(String msg, int expectedCnt) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,11 @@ public CheckBoxRenderrer () {

private Border getNoFocusBorder () {
Border border = UIManager.getBorder("List.cellNoFocusBorder");
if (System.getSecurityManager () != null) {
if (border != null) {
return border;
}
return SAFE_NO_FOCUS_BORDER;
} else {
if (border != null &&
(noFocusBorder == null ||
noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
if (border != null &&
(noFocusBorder == null || noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
}

public Component getListCellRendererComponent (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,11 @@ public CheckBoxRenderrer () {

private Border getNoFocusBorder () {
Border border = UIManager.getBorder("List.cellNoFocusBorder");
if (System.getSecurityManager () != null) {
if (border != null) {
return border;
}
return SAFE_NO_FOCUS_BORDER;
} else {
if (border != null &&
(noFocusBorder == null ||
noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
if (border != null &&
(noFocusBorder == null || noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
}

public Component getListCellRendererComponent (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class GetOwnerTest extends NbTestCase {

protected File dataRootDir;
private StatFiles accessMonitor;
private SecurityManager defaultSecurityManager;
protected File versionedFolder;
protected File unversionedFolder;

Expand Down Expand Up @@ -69,9 +68,6 @@ protected void setUp() throws Exception {
userdir.mkdirs();
System.setProperty("netbeans.user", userdir.getAbsolutePath());
if(accessMonitor != null) {
if(defaultSecurityManager == null) {
defaultSecurityManager = System.getSecurityManager();
}
System.setSecurityManager(accessMonitor);
}
}
Expand All @@ -80,7 +76,8 @@ protected void setUp() throws Exception {
protected void tearDown() throws Exception {
super.tearDown();
if(accessMonitor != null) {
System.setSecurityManager(defaultSecurityManager);
// FIXME - throws UnsupportedOperationException unconditionally, regardless of arg.
System.setSecurityManager(null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,11 @@ public AnalyserCellRenderer () {

private Border getNoFocusBorder() {
Border border = UIManager.getBorder("List.cellNoFocusBorder");
if (System.getSecurityManager() != null) {
if (border != null) return border;
return SAFE_NO_FOCUS_BORDER;
} else {
if (border != null &&
(noFocusBorder == null ||
noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
if (border != null &&
(noFocusBorder == null || noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,12 @@ public void run(CompilationController parameter) throws Exception {

TypeElement string = parameter.getElements().getTypeElement("test.test2");

SecurityManager old = System.getSecurityManager();

System.setSecurityManager(new SecMan());

TreePathHandle.create(string, parameter);

System.setSecurityManager(old);

// FIXME - throws UnsupportedOperationException unconditionally, regardless of arg.
System.setSecurityManager(null);
}
}, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,10 @@ public static void register() {
public static void initialize(String prefix) {
Assert.assertNotNull(prefix);

if (! (System.getSecurityManager() instanceof CountingSecurityManager)) {
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);
}
if (!System.getSecurityManager().getClass().getName().equals(CountingSecurityManager.class.getName())) {
throw new IllegalStateException("Wrong security manager: " + System.getSecurityManager());
}
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);

cnt = 0;
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ public enum Mode {
public static void initialize(String prefix, PerfCountingSecurityManager.Mode mode, Set<String> allowedFiles) {
System.setProperty("counting.security.disabled", "true");

if (System.getSecurityManager() instanceof PerfCountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new PerfCountingSecurityManager());
}
System.setSecurityManager(new PerfCountingSecurityManager());
setCnt(0);
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand All @@ -113,7 +109,6 @@ public static void initialize(String prefix, PerfCountingSecurityManager.Mode mo

static void assertReflection(int maxCount, String whitelist) {
System.setProperty("counting.reflection.whitelist", whitelist);
System.getSecurityManager().checkPermission( SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
System.getProperties().remove("counting.reflection.whitelist");
}

Expand All @@ -127,7 +122,7 @@ public Integer call() throws Exception {
}

public static boolean isEnabled() {
return System.getSecurityManager() instanceof Callable<?>;
return false;
}

public static void assertCounts(String msg, int expectedCnt) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ public static void register() {
public static void initialize(String prefix) {
Assert.assertNotNull(prefix);

if (! (System.getSecurityManager() instanceof CountingSecurityManager)) {
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);
}
if (!System.getSecurityManager().getClass().getName().equals(CountingSecurityManager.class.getName())) {
throw new IllegalStateException("Wrong security manager: " + System.getSecurityManager());
}
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);

cnt = 0;
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ final class CountingSecurityManager extends SecurityManager {
private static String prefix;

public static void initialize(String prefix) {
if (System.getSecurityManager() instanceof CountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new CountingSecurityManager());
}
System.setSecurityManager(new CountingSecurityManager());
cnt = 0;
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public class IsDirCntSecurityManager extends SecurityManager {
private static StringBuffer sb;

public static void initialize() {
if (!(System.getSecurityManager() instanceof IsDirCntSecurityManager)) {
System.setSecurityManager(new IsDirCntSecurityManager());
}
System.setSecurityManager(new IsDirCntSecurityManager());
cnt = 0;
sb = new StringBuffer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ public static void initialize(String prefix, Mode mode, Set<String> allowedFiles
System.setProperty("counting.security.disabled", "true");
inSubtree("", "");

if (System.getSecurityManager() instanceof CountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new CountingSecurityManager());
}
System.setSecurityManager(new CountingSecurityManager());
setCnt(0);
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand All @@ -86,7 +82,6 @@ public static void initialize(String prefix, Mode mode, Set<String> allowedFiles

static void assertReflection(int maxCount, String whitelist) {
System.setProperty("counting.reflection.whitelist", whitelist);
System.getSecurityManager().checkPermission(new MaxCountCheck(maxCount, "MaxCountCheck"));
System.getProperties().remove("counting.reflection.whitelist");
}

Expand Down Expand Up @@ -129,7 +124,7 @@ public Integer call() throws Exception {
}

public static boolean isEnabled() {
return System.getSecurityManager() instanceof Callable<?>;
return false;
}

public static void assertCounts(String msg, int expectedCnt) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ public enum Mode {
public static void initialize(String prefix, Mode mode, Set<String> allowedFiles) {
System.setProperty("counting.security.disabled", "true");

if (System.getSecurityManager() instanceof CountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new CountingSecurityManager());
}
System.setSecurityManager(new CountingSecurityManager());
setCnt(0);
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand All @@ -79,7 +75,6 @@ public static void initialize(String prefix, Mode mode, Set<String> allowedFiles

static void assertReflection(int maxCount, String whitelist) {
System.setProperty("counting.reflection.whitelist", whitelist);
System.getSecurityManager().checkPermission(new MaxCountPerm(maxCount));
System.getProperties().remove("counting.reflection.whitelist");
}

Expand Down Expand Up @@ -124,7 +119,7 @@ public Integer call() throws Exception {
}

public static boolean isEnabled() {
return System.getSecurityManager() instanceof Callable<?>;
return false;
}

public static void assertCounts(String msg, int expectedCnt) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ final class CountingSecurityManager extends SecurityManager {
private static String prefix;

public static void initialize(String prefix) {
if (System.getSecurityManager() instanceof CountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new CountingSecurityManager());
}
System.setSecurityManager(new CountingSecurityManager());
cnt = 0;
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,7 @@ private static class BlockingSecurityManager extends SecurityManager {
public static void initialize(String path, Semaphore sync) {
BlockingSecurityManager.path = path;
BlockingSecurityManager.sync = sync;
if (System.getSecurityManager() instanceof BlockingSecurityManager) {
// ok
} else {
System.setSecurityManager(new BlockingSecurityManager());
}
System.setSecurityManager(new BlockingSecurityManager());
}

public @Override void checkRead(String file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ protected void setUp() throws Exception {
if (allTestedFS != null) testedFS = allTestedFS[0];
// If not null, file accesses are counted through custom SecurityManager.
if(accessMonitor != null) {
if(defaultSecurityManager == null) {
defaultSecurityManager = System.getSecurityManager();
}
System.setSecurityManager(accessMonitor);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,17 @@ public class StatFiles extends SecurityManager {
public static final int DELETE = 3;
private Results results;
private Monitor monitor;
private SecurityManager defaultSecurityManager;

public StatFiles() {
reset();
}

public void register() {
if (defaultSecurityManager == null) {
defaultSecurityManager = System.getSecurityManager();
}
System.setSecurityManager(this);
}

public void unregister() {
if (defaultSecurityManager == null) {
System.setSecurityManager(defaultSecurityManager);
}
System.setSecurityManager(null);
}

public void reset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,7 @@ private static void assertSAX(boolean validate, boolean namespace) throws Except

static final class CountingSecurityManager extends SecurityManager {
public static void initialize() {
if (System.getSecurityManager() instanceof CountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new CountingSecurityManager());
}
System.setSecurityManager(new CountingSecurityManager());
members.clear();
}

Expand Down
Loading