Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Explain SecurityContext and SecurityContext Holder in Spring security.

Pragya Keshap answered on February 24, 2023 Popularity 6/10 Helpfulness 6/10

Contents


More Related Answers

  • context path spring boot
  • Spring Security Configuration
  • how to set context path in spring boot
  • get spring application context
  • SecurityConfig
  • set spring context
  • What is the difference between ApplicationContext and BeanFactory in the Spring framework?
  • Difference Between ApplicationContext and WebApplicationContext in Spring MVC
  • What is the security context?
  • Name the significant ApplicationContext implementations used in the spring framework?
  • Propagating the Security Context or Using Spring Scopes
  • @PersistenceContext
  • SecurityContextRepository
  • Spring Boot - @ContextConfiguration example

  • Explain SecurityContext and SecurityContext Holder in Spring security.

    1

    There are two fundamental classes of Spring Security: SecurityContext and SecurityContextHolder.

    SecurityContext: In this, information/data about the currently authenticated user (also known as the principal) is stored. So, in order to obtain a username or any other information about the user, you must first obtain the SecurityContext.

    SecurityContextHolder: Retrieving the currently authenticated principal is easiest via a static call to the SecurityContextHolder. As a helper class, it provides access to the security context. By default, it uses a ThreadLocal object to store SecurityContext, so SecurityContext is always accessible to methods in the same thread of execution, even if SecurityContext isn't passed around 

    Popularity 6/10 Helpfulness 6/10 Language java
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 24 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.