We've already looked at the declarative approach, so now, let's take a look at the programmatic approach. As we mentioned earlier, the programmatic approach is when you define the security policy of your application using code.
Using programmatic security
Getting ready
Let's start by adding the dependency:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>