Working with user authentication

Derby provides support for user authentication and user authorization. User authentication determines whether a user is a valid user. It establishes the user's identity. User authorization determines what operations a user's established identity can perform. You are strongly urged to implement both authentication and authorization on any multi-user database used in production.

When user authentication is enabled (by default, it is not enabled), the user that requests a connection must provide a valid name and password, which Derby verifies against the repository of users defined for the system. After Derby authenticates the user as valid, user authorization determines what operations the user can perform on the database to which the user is requesting a connection.

For user authentication, Derby allows you to provide a repository of users in a number of different ways:

Important: Derby's BUILTIN authentication mechanism is suitable only for development and testing purposes, and it will no longer be documented in future releases. It is strongly recommended that production systems rely on NATIVE authentication, an external directory service such as LDAP, or a user-defined class for authentication. It is also strongly recommended that production systems protect network connections with SSL/TLS.

You can define a repository of users for a particular database or for an entire system, depending on whether you use system-wide or database-wide properties.

When Derby user authentication is enabled and Derby uses an external directory service, the architecture looks something like that shown in the following figure. The application can be a single-user application with an embedded Derby engine or a multi-user application server.

Figure 1. Derby user authentication using an external service
This figure shows how an application passes Derby user authentication through an external directory service before access to a Derby database is allowed.

Derby always runs embedded in another Java application, whether that application is a single-user application or a multiple-user application server or connectivity framework.

A database can be accessed by only one JVM at a time, so it is possible to deploy a system in which the application in which Derby is embedded, not Derby, handles the user authentication by connecting to an external directory service. The application can be a single-user application with an embedded Derby engine or a multi-user application server. The following figure shows this kind of deployment.

Figure 2. Application user authentication using an external service
This figure shows how an external directory service provides application user authentication before access to a Derby database is allowed.
Related concepts
Identity in Derby
Basic security configuration tasks
Users and authorization identifiers
User authorizations
Encrypting databases on disk
Signed jar files
Notes on the Derby security features
User authentication and authorization examples
Running Derby under a security manager
Related tasks
Providing a user name and password