...
Code Block |
---|
|
public void readSensitiveFile() {
try {
SecurityManager sm = System.getSecurityManager();
if(sm != null) { // Check if file can be read
sm.checkRead(""/temp/tempFile"");
}
// Access the file
} catch (SecurityException se) {
// Log exception
}
}
|
...
Code Block |
---|
|
public final void readSensitiveFile() {
try {
SecurityManager sm = System.getSecurityManager();
if(sm != null) { // check if file can be read
sm.checkRead(""/temp/tempFile"");
}
// Access the file
} catch (SecurityException se) {
// Log exception
}
}
|
...
Code Block |
---|
|
private void readSensitiveFile() {
try {
SecurityManager sm = System.getSecurityManager();
if(sm != null) { // check if file can be read
sm.checkRead(""/temp/tempFile"");
}
// Access the file
} catch (SecurityException se) {
// Log exception
}
}
|
...
MET05-J. Validate method parameters 12. Methods (MET) MET30-J. Follow the general contract while overriding the equals method