Security
In this section, we will see some examples of how to make security to the servlets and configurations provided by the web.xml
descriptor file.
Any enterprise component needs an application realm to configure the type of security, the location of the credentials, and the protocols to use. The default realm works with the properties files inside the configuration folder of WildFly, but it's simply configurable in the standalone.xml
file descriptor of WildFly, as seen in Chapter 7, Implementing WebSockets, in the paragraph Security Realm.
File descriptor security
Now, let's see the configuration in the web.xml
:
... <security-constraint> <web-resource-collection> <web-resource-name>SecureServlet</web-resource-name> <url-pattern>/SecureServlet</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <web-resource-collection> ...