...
| Code Block | ||||
|---|---|---|---|---|
| ||||
class MutableProtector extends Mutable {
@Override
public int[] getArray() {
return super.getArray().clone();
}
@Override
public void setArray(int[] i) {
throw new UnsupportedOperationException();
}
}
// ...
private Mutable mutable = new MutableProtector();
public Mutable getMutable() {return mutable;} // mayMay be safely invoked by untrusted caller having read ability
|
...
Failure to provide an unmodifiable safe - view of a sensitive mutable object to untrusted code can lead to malicious tampering and corruption of the object.
Bibliography
...