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

public Class SecurityUtil

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Set, .HashSet, .Iterator, .Properties, java.io.IOException, java.security.Permission, javax.security.auth.Subject, org.apache.derby.authentication.SystemPrincipal, org.apache.derby.catalog.AliasInfo, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.context.Context, .ContextService, org.apache.derby.iapi.sql.conn.Authorizer, .LanguageConnectionContext, org.apache.derby.iapi.sql.dictionary.AliasDescriptor, .DataDictionary, .StatementPermission, .StatementRoutinePermission, org.apache.derby.iapi.util.IdUtil, org.apache.derby.shared.common.security.SystemPermission

This class provides helper functions for security-related features.

Field Summary

Modifier and TypeField and Description
private static final SystemPermission
USE_DERBY_INTERNALS

Permission to access Derby contexts (permissions are immutable).

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
authorize(Securable operation)

Raise an exception if the current user does not have permission to perform the indicated operation.

public static void
checkDerbyInternalsPrivilege()

Verify that we have been granted permission to use Derby internals.

public static void
checkSubjectHasPermission(final Subject
the subject representing the SystemPrincipal(s)
subject
,
final Permission
the permission to be checked
perm
)

Checks that a Subject has a Permission under the SecurityManager.

public static void
checkUserHasPermission(String
the user to be check for having the permission
user
,
Permission
the permission to be checked
perm
)

Checks that a User has a Permission under the SecurityManager.

public static Subject

Returns:

a Subject representing the user by its exact and normalized name
createSystemPrincipalSubject
(String
the user name
user
)

Creates a (read-only) Subject representing a given user as a System user within Derby.

private static String

Returns:

the authorization identifier for this principal
getAuthorizationId
(String
the name of the principal
name
)

Returns the Authorization Identifier for a principal name.

private static Context
getContextOrNull(final String contextID)

Must be private so that user code can't call this entry point.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

USE_DERBY_INTERNALSback to summary
private static final SystemPermission USE_DERBY_INTERNALS

Permission to access Derby contexts (permissions are immutable).

Constructor Detail

SecurityUtilback to summary
public SecurityUtil()

Method Detail

authorizeback to summary
public static void authorize(Securable operation) throws StandardException

Raise an exception if the current user does not have permission to perform the indicated operation.

checkDerbyInternalsPrivilegeback to summary
public static void checkDerbyInternalsPrivilege()

Verify that we have been granted permission to use Derby internals. This is a NOP now that Derby no longer uses a SecurityManager.

checkSubjectHasPermissionback to summary
public static void checkSubjectHasPermission(final Subject subject, final Permission perm)

Checks that a Subject has a Permission under the SecurityManager. To perform this check the following policy grant is required. This method is a NOP now that Derby does not use a SecurityManager.

  • to run the encapsulated test: permission javax.security.auth.AuthPermission "doAsPrivileged";
or an AccessControlException will be raised detailing the cause.

Parameters
subject:Subject

the subject representing the SystemPrincipal(s)

perm:Permission

the permission to be checked

checkUserHasPermissionback to summary
public static void checkUserHasPermission(String user, Permission perm)

Checks that a User has a Permission under the SecurityManager. To perform this check the following policy grant is required. This method is a NOP now that Derby no longer uses a SecurityManager.

  • to run the encapsulated test: permission javax.security.auth.AuthPermission "doAsPrivileged";
or an AccessControlException will be raised detailing the cause.

Parameters
user:String

the user to be check for having the permission

perm:Permission

the permission to be checked

createSystemPrincipalSubjectback to summary
public static Subject createSystemPrincipalSubject(String user)

Creates a (read-only) Subject representing a given user as a System user within Derby.

Parameters
user:String

the user name

Returns:Subject

a Subject representing the user by its exact and normalized name

See Also
User Names and Authorization Identifiers in Derby
getAuthorizationIdback to summary
private static String getAuthorizationId(String name)

Returns the Authorization Identifier for a principal name.

Parameters
name:String

the name of the principal

Returns:String

the authorization identifier for this principal

getContextOrNullback to summary
private static Context getContextOrNull(final String contextID)

Must be private so that user code can't call this entry point.