Spring Certified Professional 2023 · Free Practice Question Easy
Question 16
_______ is an interface in Spring Security that represents a user's information, such as username, password, and authorities.
-
A
UserDetails -
B
UserDetailsService -
C
Authentication -
D
PasswordEncoder
Reveal correct answer
Correct answer: A
Explanation
UserDetails is an interface provided by Spring Security that represents a user's security-specific data. It contains methods to retrieve the user's username, password, authorities, and whether the user's account is expired, locked, or enabled. UserDetails is used as a contract for implementing user details by classes that represent user information, such as User, which is a commonly used implementation of UserDetails. The UserDetails interface is used in the authentication process by Spring Security to determine whether a user is authorized to access a particular resource.
UserDetailsService: This interface is used to load user-specific data during authentication. It has a single method, loadUserByUsername(), that takes a username as an argument and returns a UserDetails object for that user.
Authentication: This interface represents an authentication request made by a user. It contains the principal (i.e., the user being authenticated) and the credentials (e.g., password) for that user.
PasswordEncoder: This interface is used to encode passwords for storage in a database or other data store. It has a single method, encode(), that takes a raw password as an argument and returns the encoded password. Spring provides several implementations of PasswordEncoder, including BCryptPasswordEncoder, SCryptPasswordEncoder, and MessageDigestPasswordEncoder.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
