December 2017
Intermediate to advanced
372 pages
8h 46m
English
To authenticate a secured resource, such as a Servlet or JAX-RS RESTful web service, against credentials stored in a relational database, we need to annotate an application-scoped CDI bean with the @DatabaseIdentityStoreDefinition annotation, as illustrated in the following example.
package net.ensode.javaee8book.httpauthdatabaseidentitystore.security; import javax.enterprise.context.ApplicationScoped; import javax.security.enterprise.identitystore.DatabaseIdentityStoreDefinition; @DatabaseIdentityStoreDefinition( dataSourceLookup = "jdbc/userAuth", callerQuery = "select password from users where name = ?", groupsQuery = "select g.GROUP_NAME from " + "USER_GROUPS ug, users u, " ...