1.

State the difference between @Secured and @RolesAllowed.

Answer»

@RolesAllowed: It is a Java standard annotation (JSR250) (i.e., not only spring security). Because this annotation only supports role-based security, it is more limited than the @PreAuthorize annotation. To enable the @RolwesAllowed annotation in your code, add the following line to spring-security.xml and spring boot. 

XML: <global-method-security jsr250-annotations="enabled"/> Spring boot: @EnableGlobalMethodSecurity(jsr250Enabled = true)

@Secured: It is a Spring specific annotation. There is more to it than just role-based security. It secures methods implemented by beans (objects whose life-cycle is managed by the Spring IoC). HOWEVER, Spring Expression Language (SpEL) is not supported for defining security constraints. To enable the @Secured annotation in your code, add the following line to spring-security.xml and spring boot. 

XML: global-method-security secured-annotations="enabled"/> Spring boot: @EnableGlobalMethodSecurity(securedEnabled=true) Conclusion 

Spring Security is ONE of the most popular, powerful, and highly customizable access-control frameworks (security framework) that provide authentication, authorization, and other security features for enterprise applications. In this article, we have compiled a comprehensive LIST of Spring Security Interview questions, which are typically asked during interviews. In addition to checking your existing Spring Security skills, these questions serve as a good resource for reviewing some important concepts before you appear for an interview. It is suitable for both freshers as well as EXPERIENCED developers and tech LEADS

Additional Useful Resources

Interview questions on Java

Interview questions on Spring Boot

Spring MVC vs Spring Boot

Spring vs Spring Boot



Discussion

No Comment Found