Top Description Fields Constructors Methods
org.apache.derby.security

public final Class DatabasePermission

extends Permission
Class Inheritance
Imports
java.security.Permission, java.util.ArrayList, .List, .Set, java.io.File, .IOException, .ObjectInputStream, .ObjectOutputStream, org.apache.derby.shared.common.security.SystemPermission

This class represents access to database-scoped privileges. An example of database-scoped privileges is the permission to create a database under a specified directory path.

A DatabasePermission is defined by two string attributes, similar to a java.io.FilePermission:

The database location URL may contain certain wildcard characters. The currently only supported database action is create.
See Also
DatabasePermission#DatabasePermission(String, String), SystemPermission, java.io.FilePermission

Field Summary

Modifier and TypeField and Description
private String
actions

The actions of this permission, as returned by getActions().

public static final String
CREATE

The create database permission.

private transient String
parentPath

The parent directory of this permission's canonical directory path, or null if this permission's path does not have a parent directory.

private transient String
path

This permission's canonical directory path.

private transient char
pathType

Indicates whether the path denotes an inclusive, recursive, wildcard, or single location.

public static final char
URL_PATH_INCLUSIVE_CHAR

The path type character matching any database anywhere.

public static final String
URL_PATH_INCLUSIVE_STRING

The location text matching any database anywhere.

public static final char
URL_PATH_RECURSIVE_CHAR

The wildcard character matching any database under a directory or its subdirectories.

public static final String
public static final String
public static final char
URL_PATH_RELATIVE_CHAR

The relative path character.

public static final String
public static final String
public static final char
URL_PATH_SEPARATOR_CHAR

The URL file path separator character.

public static final String
public static final char
URL_PATH_WILDCARD_CHAR

The wildcard character matching any database in a directory.

public static final String
public static final String
public static final String
URL_PROTOCOL_DIRECTORY

The URL protocol scheme specifying a directory location.

Constructor Summary

AccessConstructor and Description
public
DatabasePermission(String
the database URL
url
,
String
the action string
actions
)

Creates a new DatabasePermission with the specified URL and actions.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if obj is a DatabasePermission, and has the same URL and actions as this DatabasePermission object, false if not
equals
(Object
the object we are testing for equality with this object
obj
)

Implements abstract java.security.Permission.equals.

Checks two DatabasePermission objects for equality.

public String

Returns:

the canonical string representation of the actions
getActions
()

Implements abstract java.security.Permission.getActions.

Returns the "canonical string representation" of the actions.

public int

Returns:

a hash code value for this object
hashCode
()

Implements abstract java.security.Permission.hashCode.

Returns the hash code value for this object.

public boolean

Returns:

true if the specified permission is implied by this object, false if not
implies
(Permission
the permission to check against
p
)

Implements abstract java.security.Permission.implies.

Checks if this DatabasePermission implies a specified permission.

protected void
initActions(String
the comma-separated action list
actions
)

Parses the list of database actions.

protected void
initLocation(String
the database URL
url
)

Parses the database location URL.

private void
readObject(ObjectInputStream s)

Called upon Deserialization for restoring the state of this DatabasePermission from a stream.

private void
writeObject(ObjectOutputStream s)

Called upon Serialization for saving the state of this DatabasePermission to a stream.

Inherited from java.security.Permission:
checkGuardgetNamenewPermissionCollectiontoString

Field Detail

actionsback to summary
private String actions

The actions of this permission, as returned by getActions().

CREATEback to summary
public static final String CREATE

The create database permission.

parentPathback to summary
private transient String 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.

pathback to summary
private transient String 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.

pathTypeback to summary
private transient char pathType

Indicates 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.

URL_PATH_INCLUSIVE_CHARback to summary
public static final char URL_PATH_INCLUSIVE_CHAR

The path type character matching any database anywhere.

URL_PATH_INCLUSIVE_STRINGback to summary
public static final String URL_PATH_INCLUSIVE_STRING

The location text matching any database anywhere.

URL_PATH_RECURSIVE_CHARback to summary
public static final char URL_PATH_RECURSIVE_CHAR

The wildcard character matching any database under a directory or its subdirectories.

URL_PATH_RECURSIVE_STRINGback to summary
public static final String URL_PATH_RECURSIVE_STRING
URL_PATH_RECURSIVE_SUFFIXback to summary
public static final String URL_PATH_RECURSIVE_SUFFIX
URL_PATH_RELATIVE_CHARback to summary
public static final char URL_PATH_RELATIVE_CHAR

The relative path character.

URL_PATH_RELATIVE_PREFIXback to summary
public static final String URL_PATH_RELATIVE_PREFIX
URL_PATH_RELATIVE_STRINGback to summary
public static final String URL_PATH_RELATIVE_STRING
URL_PATH_SEPARATOR_CHARback to summary
public static final char URL_PATH_SEPARATOR_CHAR

The URL file path separator character.

URL_PATH_SEPARATOR_STRINGback to summary
public static final String URL_PATH_SEPARATOR_STRING
URL_PATH_WILDCARD_CHARback to summary
public static final char URL_PATH_WILDCARD_CHAR

The wildcard character matching any database in a directory.

URL_PATH_WILDCARD_STRINGback to summary
public static final String URL_PATH_WILDCARD_STRING
URL_PATH_WILDCARD_SUFFIXback to summary
public static final String URL_PATH_WILDCARD_SUFFIX
URL_PROTOCOL_DIRECTORYback to summary
public static final String URL_PROTOCOL_DIRECTORY

The URL protocol scheme specifying a directory location.

Constructor Detail

DatabasePermissionback to summary
public DatabasePermission(String url, String actions) throws IOException

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:String

the database URL

actions:String

the action string

Exceptions
IOException:
if the location URL cannot be canonicalized
NullPointerException:
if an argument is null
IllegalArgumentException:
if an argument is not legal
See Also
Permission#Permission(String), java.io.FilePermission#FilePermission(String, String)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Implements abstract java.security.Permission.equals.

Checks two DatabasePermission objects for equality.

Checks that obj is a DatabasePermission and has the same canonizalized URL and actions as this object.

Parameters
obj:Object

the object we are testing for equality with this object

Returns:boolean

true if obj is a DatabasePermission, and has the same URL and actions as this DatabasePermission object, false if not

See Also
Permission#equals(Object)
getActionsback to summary
public String getActions()

Implements abstract java.security.Permission.getActions.

Returns the "canonical string representation" of the actions.

Returns:String

the canonical string representation of the actions

See Also
Permission#getActions()
hashCodeback to summary
public int hashCode()

Implements abstract java.security.Permission.hashCode.

Returns the hash code value for this object.

Returns:int

a hash code value for this object

See Also
Permission#hashCode()
impliesback to summary
public boolean implies(Permission p)

Implements abstract java.security.Permission.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".
Parameters
p:Permission

the permission to check against

Returns:boolean

true if the specified permission is implied by this object, false if not

See Also
Permission#implies(Permission)
initActionsback to summary
protected void initActions(String actions)

Parses the list of database actions.

Parameters
actions:String

the comma-separated action list

Exceptions
NullPointerException:
if actions is null
IllegalArgumentException:
if not a list of legal actions
initLocationback to summary
protected void initLocation(String url) throws IOException

Parses the database location URL.

Parameters
url:String

the database URL

Exceptions
IOException:
if the location URL cannot be canonicalized
NullPointerException:
if the URL is null
IllegalArgumentException:
if the URL is not well-formed
readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

Called upon Deserialization for restoring the state of this DatabasePermission from a stream.

writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

Called upon Serialization for saving the state of this DatabasePermission to a stream.