public final class EventPermission
extends java.security.Permission
EventPermission
allows access to system events. An
EventPermission
object contains a name (also referred to as a
"target name") and actions.
The target name is the name of the event ("BATTERY_LEVEL", "com.MyCompany.MyEvent", etc). The naming convention follows the hierarchical property naming convention. Also, an asterisk MAY appear at the end of the name, following a ".", or by itself, to signify a wildcard match. For example: "com.MyCompany.*" or "*" is valid, "*MyCompany" or "a*b" is not valid.
The actions to be granted are passed to the constructor in a non-empty string,
containing a list of comma-separated keywords. Trailing and leading white
spaces as well as those between the keywords and commas in the list are not
allowed and lead to an IllegalArgumentException
. The possible
keywords are "post", "postsystem", "read" and "register". Their meaning is
defined as follows:
post |
Permission to post an event. Allows the
EventManager.post method to post an event. |
postsystem |
Permission to post a system event. Allows the
EventManager.post method to post an event
that is returned by EventManager.getSystemEventNames() . |
read |
Permission to read an event. Allows the
EventManager.getCurrent
method return the current event and the EventManager.addEventListener methods to add an EventListener . |
register |
Permission to register and unregister applications to launch
in response to events. Allows the
EventManager.registerApplication()
methods register for the named event. |
Care should be taken before granting application permission to access certain events. For example, granting permission to post events could allow a badly behaving application to interfere with the operation of the device.
Constructor and Description |
---|
EventPermission(java.lang.String event,
java.lang.String actions)
Creates a new
EventPermission object with the specified
name and actions. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object object)
Checks if another object is "equal" to this one.
|
java.lang.String |
getActions()
Gets the canonical string representing the actions.
|
int |
hashCode()
Gets the hash code value for this object.
|
boolean |
implies(java.security.Permission p)
Checks if the specified permission is "implied" by this object.
|
public EventPermission(java.lang.String event, java.lang.String actions)
EventPermission
object with the specified
name and actions. If an action is listed multiple times, the second and
following occurences are ignored, means "post,post"
has the same effect as "post"
.event
- The name of the event for which to grant permission, not empty.actions
- Valid actions are "post", "postsystem", "read" and "register".java.lang.NullPointerException
- if event
or actions
is
null
.java.lang.IllegalArgumentException
- if actions
include any string other than those allowed, or if event
argument is an empty string, or a string that consists of white
space(s) only.EventManager
public boolean implies(java.security.Permission p)
true
if:
implies
in class java.security.Permission
p
- the permission to check against.true
if the passed permission is equal to or
implied by this permission, false
otherwise.public java.lang.String getActions()
EventPermission
object allows both, post and read actions, a call to getActions
will return the string "post,read".
getActions
in class java.security.Permission
public int hashCode()
hashCode
in class java.security.Permission
public boolean equals(java.lang.Object object)
equals
in class java.security.Permission
object
- an object to comparetrue
if the objects are of the same type
and the event and action are equal.Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. Use of this specification is subject to license terms.