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.

https://docs.spring.io/spring-security/site/docs/5.3.2.RELEASE/api/org/springframework/security/core/userdetails/UserDetails.html


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.

https://docs.spring.io/spring-security/site/docs/5.3.2.RELEASE/api/org/springframework/security/core/userdetails/UserDetailsService.html


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.

https://docs.spring.io/spring-security/site/docs/5.3.2.RELEASE/api/org/springframework/security/core/Authentication.html



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.

https://docs.spring.io/spring-security/site/docs/5.3.2.RELEASE/api/org/springframework/security/crypto/password/PasswordEncoder.html

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need