Class DatabasePermission
- All Implemented Interfaces:
Serializable
,Guard
A DatabasePermission is defined by two string attributes, similar to a java.io.FilePermission:
- URL - a location description of or for a Derby database
- Actions - a list of granted administrative actions
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
The actions of this permission, as returned bygetActions()
.static final String
The create database permission.The legal database permission action names.private String
The parent directory of this permission's canonical directory path, or null if this permission's path does not have a parent directory.private String
This permission's canonical directory path.private char
Indicates whether the path denotes an inclusive, recursive, wildcard, or single location.static final char
The path type character matching any database anywhere.static final String
The location text matching any database anywhere.static final char
The wildcard character matching any database under a directory or its subdirectories.static final String
static final String
static final char
The relative path character.static final String
static final String
static final char
The URL file path separator character.static final String
static final char
The wildcard character matching any database in a directory.static final String
static final String
static final String
The URL protocol scheme specifying a directory location. -
Constructor Summary
ConstructorsConstructorDescriptionDatabasePermission
(String url, String actions) Creates a new DatabasePermission with the specified URL and actions. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks two DatabasePermission objects for equality.Returns the "canonical string representation" of the actions.int
hashCode()
Returns the hash code value for this object.boolean
Checks if this DatabasePermission implies a specified permission.protected void
initActions
(String actions) Parses the list of database actions.protected void
initLocation
(String url) Parses the database location URL.private void
Called upon Deserialization for restoring the state of this DatabasePermission from a stream.private void
Called upon Serialization for saving the state of this DatabasePermission to a stream.Methods inherited from class java.security.Permission
checkGuard, getName, newPermissionCollection, toString
-
Field Details
-
URL_PROTOCOL_DIRECTORY
The URL protocol scheme specifying a directory location.- See Also:
-
URL_PATH_INCLUSIVE_STRING
The location text matching any database anywhere.- See Also:
-
URL_PATH_INCLUSIVE_CHAR
public static final char URL_PATH_INCLUSIVE_CHARThe path type character matching any database anywhere.- See Also:
-
URL_PATH_SEPARATOR_CHAR
public static final char URL_PATH_SEPARATOR_CHARThe URL file path separator character.- See Also:
-
URL_PATH_RELATIVE_CHAR
public static final char URL_PATH_RELATIVE_CHARThe relative path character.- See Also:
-
URL_PATH_WILDCARD_CHAR
public static final char URL_PATH_WILDCARD_CHARThe wildcard character matching any database in a directory.- See Also:
-
URL_PATH_RECURSIVE_CHAR
public static final char URL_PATH_RECURSIVE_CHARThe wildcard character matching any database under a directory or its subdirectories.- See Also:
-
URL_PATH_SEPARATOR_STRING
-
URL_PATH_RELATIVE_STRING
-
URL_PATH_RELATIVE_PREFIX
-
URL_PATH_WILDCARD_STRING
-
URL_PATH_WILDCARD_SUFFIX
-
URL_PATH_RECURSIVE_STRING
-
URL_PATH_RECURSIVE_SUFFIX
-
CREATE
The create database permission.- See Also:
-
LEGAL_ACTIONS
The legal database permission action names. -
actions
The actions of this permission, as returned bygetActions()
. -
path
This permission's canonical directory path. The path consists of a canonicalized form of the user-specified URL, stripped off the protocol specification and any recursive/wildcard characters, or"<<ALL FILES>>"
for the "anywhere" permission. The canonical path is used when testing permissions with implies(), where real directory locations, not just notational differences, ought to be compared. Analog to java.io.FilePermission, the canonical path is also used by equals() and hashCode() to support hashing and mapping of permissions by their real directory locations. Because canonical file paths are platform dependent, this field must not be serialized (hence transient) but be recomputed from the original URL upon deserialization. -
parentPath
The parent directory of this permission's canonical directory path, or null if this permission's path does not have a parent directory. Because canonical file paths are platform dependent, this field must not be serialized (hence transient) but be recomputed from the original URL upon deserialization. -
pathType
private transient char pathTypeIndicates whether the path denotes an inclusive, recursive, wildcard, or single location. If the path denotes an inclusive, recursive or wildcard location, this field's value is URL_PATH_INCLUSIVE_CHAR, URL_PATH_RECURSIVE_CHAR, or URL_PATH_WILDCARD_CHAR, respectively; otherwise, it's URL_PATH_SEPARATOR_CHAR denoting a single location. This field gets recomputed upon deserialization.
-
-
Constructor Details
-
DatabasePermission
Creates a new DatabasePermission with the specified URL and actions.actions contains a comma-separated list of the desired actions granted on a database. Currently, the only supported action is
create
.URL denotes a database location URL, which, at this time, must start with
directory:
followed by a directory pathname. Note that in a URL, the separator character is always "/" rather than the file separator of the operating-system. The directory path may be absolute or relative, in which case it is prefixed with the current user directory. In addition, similar to java.io.FilePermission, the directory pathname may end with a wildcard character to allow for arbitrarily named databases under a path:- "directory:location" - refers to a database called location,
- "directory:location/*" - matches any database in the directory location,
- "directory:location/-" - matches any database under location or its subdirectories.
- "directory:*" - matches any database in the user's current working directory.
- "directory:-" - matches any database under the user's current working directory or its subdirectories.
-
"directory:<<ALL FILES>>"
matches any database anywhere.
- Parameters:
url
- the database URLactions
- the action string- Throws:
NullPointerException
- if an argument is nullIllegalArgumentException
- if an argument is not legalIOException
- if the location URL cannot be canonicalized- See Also:
-
-
Method Details
-
initActions
Parses the list of database actions.- Parameters:
actions
- the comma-separated action list- Throws:
NullPointerException
- if actions is nullIllegalArgumentException
- if not a list of legal actions
-
initLocation
Parses the database location URL.- Parameters:
url
- the database URL- Throws:
NullPointerException
- if the URL is nullIllegalArgumentException
- if the URL is not well-formedIOException
- if the location URL cannot be canonicalized
-
implies
Checks if this DatabasePermission implies a specified permission.This method returns true if:
- p is an instanceof DatabasePermission and
- p's directory pathname is implied by this object's pathname. For example, "/tmp/*" implies "/tmp/foo", since "/tmp/*" encompasses the "/tmp" directory and all files in that directory, including the one named "foo".
- Specified by:
implies
in classPermission
- Parameters:
p
- the permission to check against- Returns:
- true if the specified permission is implied by this object, false if not
- See Also:
- p is an instanceof DatabasePermission and
-
equals
Checks two DatabasePermission objects for equality.Checks that obj is a DatabasePermission and has the same canonizalized URL and actions as this object.
- Specified by:
equals
in classPermission
- Parameters:
obj
- the object we are testing for equality with this object- Returns:
- true if obj is a DatabasePermission, and has the same URL and actions as this DatabasePermission object, false if not
- See Also:
-
hashCode
public int hashCode()Returns the hash code value for this object.- Specified by:
hashCode
in classPermission
- Returns:
- a hash code value for this object
- See Also:
-
getActions
Returns the "canonical string representation" of the actions.- Specified by:
getActions
in classPermission
- Returns:
- the canonical string representation of the actions
- See Also:
-
writeObject
Called upon Serialization for saving the state of this DatabasePermission to a stream.- Throws:
IOException
-
readObject
Called upon Deserialization for restoring the state of this DatabasePermission from a stream.- Throws:
IOException
ClassNotFoundException
-