A configuration class is annotated `@EnableGlobalMethodSecurity(prePostEnabled = true)`. The team is deciding whether to express a rule with `@Secured` or with `@PreAuthorize`. Which TWO statements are correct?
A. As configured, `@Secured` annotations are ignored; enabling them requires `securedEnabled = true` on @EnableGlobalMethodSecurity.Correct answer
Correct. Each annotation family has its own switch — prePostEnabled, securedEnabled, jsr250Enabled — and all default to false. Turning on the pre/post family leaves @Secured inactive.
B. `@PreAuthorize` takes a SpEL expression and can therefore reference method arguments (for example `#accountId`) and the authenticated principal, while `@Secured` accepts only a plain list of security attribute (role) strings.Correct answer
Correct. Expression support is exactly what distinguishes the pre/post annotations from @Secured: @PreAuthorize is evaluated as SpEL against a context exposing the authentication and the invocation arguments, whereas @Secured values are compared as literal authorities.
C. `@Secured` also accepts SpEL, so `@Secured("hasRole('ADMIN') and #id == principal.id")` is an equivalent way to write an argument-aware rule.
The classic misconception that @Secured and @PreAuthorize differ only in name. @Secured predates expression-based access control and treats its values as literal security attributes, so such a string would be looked for as an authority, not evaluated.
D. Setting `prePostEnabled = true` implicitly activates `@Secured` and the JSR-250 annotations as well, since they share one method-security interceptor.
Assumes the three switches are cumulative. They are independent booleans; sharing an interceptor infrastructure does not mean enabling one family registers the metadata source for the others.
E. `@Secured` is evaluated after the target method returns, which lets it inspect the returned value before deciding whether access is allowed.
Confuses @Secured with @PostAuthorize. @Secured is a pre-invocation check; only the post-invocation annotations can consult the returned object.
Explanation
@EnableGlobalMethodSecurity exposes one independent switch per annotation family — prePostEnabled for @PreAuthorize/@PostAuthorize/@PreFilter/@PostFilter, securedEnabled for @Secured, and jsr250Enabled for @RolesAllowed and friends — and each defaults to false, so enabling the pre/post family alone leaves @Secured annotations silently inert rather than implicitly switching them on. The substantive difference between the two styles is expression support: @PreAuthorize is evaluated as SpEL with access to the authentication and the invocation arguments, whereas @Secured compares its values as literal security attributes and cannot express an argument-aware condition. Both @Secured and @PreAuthorize are pre-invocation checks; consulting a returned value is the job of the post-invocation annotations.