# Annotations in Java Spring Security

In 
Published 2024-01-14

This tutorial explains some annotations used in Java Spring Security.

Here are some well known annotations used in Java Spring Security:

# @EnableWebSecurity

@EnableWebSecurity - Enables web security

# @EnableGlobalMethodSecurity

@EnableGlobalMethodSecurity - Enables method security (further we can use @PreAuthorize, @PostAuthorize, @PreFilter, @PostFilter annotation).

# @PreAuthorize

@PreAuthorize - Defines access-control expression using SpEL, which is evaluated before invoking a protected method. Defines who can access a method.

# @PostAuthorize

@PostAuthorize - Defines access-control expression using SpEL, which is evaluated after invoking a protected method. Defines who can receive information from a method.

# @PreFilter

@PreFilter - Filter the call parameters (collection or arrays) of the method.

# @PostFilter

@PostFilter - Filter the result of the call (collection or arrays).

# @RolesAllowed

@RolesAllowed - Specifies a list of security roles allowed to invoke protected method

# @Secured

@Secured - Do the same thing as @RolesAllowed, but it is Spring specific.