December 2017
Intermediate to advanced
372 pages
8h 46m
English
Basic authentication mechanisms can be achieved by annotating the resource to secure (that is, a servlet or JAX-RS RESTful web service) with the @BasicAuthenticationMechanismDefinition annotation:
package net.ensode.javaee8book.security.basicauthexample; import java.io.IOException; import javax.annotation.security.DeclareRoles; import javax.security.enterprise.authentication.mechanism.http.BasicAuthenticationMechanismDefinition; import javax.servlet.ServletException; import javax.servlet.annotation.HttpConstraint; import javax.servlet.annotation.ServletSecurity; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; ...