|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.SecurityManager
com.android.ide.common.rendering.RenderSecurityManager
public class RenderSecurityManager
A SecurityManager which is used for layout lib rendering, to
prevent custom views from accidentally exiting the whole IDE if they call
System.exit, as well as unintentionally writing files etc.
The security manager only checks calls on the current thread for which it
was made active with a call to setActive(boolean, Object), as well as any
threads constructed from the render thread.
| Field Summary | |
|---|---|
static java.lang.String |
ENABLED_PROPERTY
Property used to disable sandbox |
static boolean |
RESTRICT_READS
Whether we should restrict reading to certain paths |
static boolean |
sEnabled
Whether the security manager is enabled for this session (it might still be inactive, either because it's active for a different thread, or because it has been disabled via setActive(boolean, Object) (which sets the
per-instance mEnabled flag) |
| Fields inherited from class java.lang.SecurityManager |
|---|
inCheck |
| Constructor Summary | |
|---|---|
RenderSecurityManager(java.lang.String sdkPath,
java.lang.String projectPath)
Creates a security manager suitable for controlling access to custom views being rendered by layoutlib, ensuring that they don't accidentally try to write files etc (which could corrupt data if they for example assume device paths that are not the same for the running IDE; for example, they could try to clear out their own local app storage, which in the IDE could be the user's home directory.) |
|
| Method Summary | |
|---|---|
void |
checkAccept(java.lang.String host,
int port)
|
void |
checkAccess(java.lang.Thread thread)
|
void |
checkAccess(java.lang.ThreadGroup threadGroup)
|
void |
checkAwtEventQueueAccess()
|
void |
checkConnect(java.lang.String host,
int port)
|
void |
checkConnect(java.lang.String host,
int port,
java.lang.Object context)
|
void |
checkCreateClassLoader()
|
void |
checkDelete(java.lang.String file)
|
void |
checkExec(java.lang.String cmd)
|
void |
checkExit(int status)
|
void |
checkLink(java.lang.String lib)
|
void |
checkListen(int port)
|
void |
checkMemberAccess(java.lang.Class<?> clazz,
int which)
|
void |
checkMulticast(java.net.InetAddress inetAddress)
|
void |
checkMulticast(java.net.InetAddress inetAddress,
byte ttl)
|
void |
checkPackageAccess(java.lang.String pkg)
|
void |
checkPackageDefinition(java.lang.String pkg)
|
void |
checkPermission(java.security.Permission permission)
|
void |
checkPrintJobAccess()
|
void |
checkPropertiesAccess()
|
void |
checkPropertyAccess(java.lang.String property)
|
void |
checkRead(java.lang.String file)
|
void |
checkRead(java.lang.String file,
java.lang.Object context)
|
void |
checkSetFactory()
|
void |
checkSystemClipboardAccess()
|
boolean |
checkTopLevelWindow(java.lang.Object context)
|
void |
checkWrite(java.io.FileDescriptor fileDescriptor)
|
void |
checkWrite(java.lang.String file)
|
void |
dispose(java.lang.Object credential)
Disposes the security manager. |
static boolean |
enterSafeRegion(java.lang.Object credential)
Enters a code region where the sandbox is not needed |
static void |
exitSafeRegion(boolean token)
Exits a code region where the sandbox was not needed |
static RenderSecurityManager |
getCurrent()
Returns the current render security manager, if any. |
static java.lang.String |
getLastFailedPath()
Returns the most recently denied path. |
void |
setActive(boolean active,
java.lang.Object credential)
Sets whether the RenderSecurityManager is active or not. |
RenderSecurityManager |
setAppTempDir(java.lang.String appTempDir)
Sets an optional application temp directory. |
RenderSecurityManager |
setLogger(com.android.utils.ILogger logger)
Sets an optional logger. |
| Methods inherited from class java.lang.SecurityManager |
|---|
checkPermission, checkRead, checkSecurityAccess, classDepth, classLoaderDepth, currentClassLoader, currentLoadedClass, getClassContext, getInCheck, getSecurityContext, getThreadGroup, inClass, inClassLoader |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String ENABLED_PROPERTY
public static final boolean RESTRICT_READS
public static boolean sEnabled
setActive(boolean, Object) (which sets the
per-instance mEnabled flag)
| Constructor Detail |
|---|
public RenderSecurityManager(@Nullable
java.lang.String sdkPath,
@Nullable
java.lang.String projectPath)
Note: By default a security manager is not active. You need to call
setActive(boolean, Object) with true to activate it, instead of just calling
System.setSecurityManager(SecurityManager).
sdkPath - an optional path to the SDK install being used by layoutlib;
this is used to white-list path prefixes for layoutlib resource
lookupprojectPath - a path to the project directory, used for similar purposes| Method Detail |
|---|
@Nullable public static RenderSecurityManager getCurrent()
public RenderSecurityManager setLogger(@Nullable
com.android.utils.ILogger logger)
public RenderSecurityManager setAppTempDir(@Nullable
java.lang.String appTempDir)
public void setActive(boolean active,
@Nullable
java.lang.Object credential)
active - whether to turn on or off the security managercredential - when turning off the security manager, the exact same
credential passed in to the earlier activation call
public void dispose(@Nullable
java.lang.Object credential)
setActive(boolean, java.lang.Object) with
false.
credential - the sandbox credential initially passed to
setActive(boolean, Object)
public static boolean enterSafeRegion(@Nullable
java.lang.Object credential)
credential - a credential which proves that the caller has the right to do this
exitSafeRegion(boolean)public static void exitSafeRegion(boolean token)
token - the token which was returned back from the paired
enterSafeRegion(Object) call@Nullable public static java.lang.String getLastFailedPath()
public void checkPackageAccess(java.lang.String pkg)
checkPackageAccess in class java.lang.SecurityManager
public void checkMemberAccess(java.lang.Class<?> clazz,
int which)
checkMemberAccess in class java.lang.SecurityManagerpublic void checkPropertyAccess(java.lang.String property)
checkPropertyAccess in class java.lang.SecurityManagerpublic void checkLink(java.lang.String lib)
checkLink in class java.lang.SecurityManagerpublic void checkCreateClassLoader()
checkCreateClassLoader in class java.lang.SecurityManagerpublic void checkRead(java.lang.String file)
checkRead in class java.lang.SecurityManager
public void checkRead(java.lang.String file,
java.lang.Object context)
checkRead in class java.lang.SecurityManagerpublic void checkExit(int status)
checkExit in class java.lang.SecurityManagerpublic void checkPropertiesAccess()
checkPropertiesAccess in class java.lang.SecurityManagerpublic void checkPackageDefinition(java.lang.String pkg)
checkPackageDefinition in class java.lang.SecurityManagerpublic void checkExec(java.lang.String cmd)
checkExec in class java.lang.SecurityManager
public void checkConnect(java.lang.String host,
int port)
checkConnect in class java.lang.SecurityManager
public void checkConnect(java.lang.String host,
int port,
java.lang.Object context)
checkConnect in class java.lang.SecurityManagerpublic void checkListen(int port)
checkListen in class java.lang.SecurityManager
public void checkAccept(java.lang.String host,
int port)
checkAccept in class java.lang.SecurityManagerpublic void checkSetFactory()
checkSetFactory in class java.lang.SecurityManagerpublic void checkMulticast(java.net.InetAddress inetAddress)
checkMulticast in class java.lang.SecurityManager
public void checkMulticast(java.net.InetAddress inetAddress,
byte ttl)
checkMulticast in class java.lang.SecurityManagerpublic void checkDelete(java.lang.String file)
checkDelete in class java.lang.SecurityManagerpublic void checkAwtEventQueueAccess()
checkAwtEventQueueAccess in class java.lang.SecurityManagerpublic void checkWrite(java.io.FileDescriptor fileDescriptor)
checkWrite in class java.lang.SecurityManagerpublic void checkWrite(java.lang.String file)
checkWrite in class java.lang.SecurityManagerpublic void checkPrintJobAccess()
checkPrintJobAccess in class java.lang.SecurityManagerpublic void checkSystemClipboardAccess()
checkSystemClipboardAccess in class java.lang.SecurityManagerpublic boolean checkTopLevelWindow(java.lang.Object context)
checkTopLevelWindow in class java.lang.SecurityManagerpublic void checkAccess(java.lang.Thread thread)
checkAccess in class java.lang.SecurityManagerpublic void checkAccess(java.lang.ThreadGroup threadGroup)
checkAccess in class java.lang.SecurityManagerpublic void checkPermission(java.security.Permission permission)
checkPermission in class java.lang.SecurityManager
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||