InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Is security a cross-cutting concern? |
|
Answer» SPRING Security is indeed a cross-cutting concern. Spring security is ALSO using Spring AOP (Aspect Oriented PROGRAMMING) internally. A cross-cutting concern is one that applies THROUGHOUT the whole application and affects it all. Below are some cross-cutting concerns related to the ENTERPRISE application.
|
|
| 2. |
Explain AbstractSecurityInterceptor in spring security? |
|
Answer» In SPRING Security, the AbstractSecurityInterceptor handles the initial authorization of incoming requests. AbstractSecurityInterceptor has two concrete IMPLEMENTATIONS: |
|
| 3. |
What is PasswordEncoder? |
|
Answer» Password ENCODING is provided by SPRING Security using the PASSWORDENCODER interface. This interface defines two methods: |
|
| 4. |
Explain salting and its usage. |
|
Answer» Spring Security automatically applies salting since version 3.1. Salting is the process of combining random data with a password before password hashing. SALT improves hashing by increasing its uniqueness and complexity without increasing the requirements for users, thereby reducing password attacks. HASHED passwords are then stored in a database, ALONG with salt. Your application will be protected from Dictionary-Attack by using salting. With Salt, you can ADD an extra string to the password to make it more difficult for HACKERS to crack it. |
|
| 5. |
What do you mean by HASHING in spring security? |
|
Answer» Databases often suffer from security problems when storing passwords. Plain text passwords cannot be stored in your database because then anyone who has access to the database WOULD know the passwords of every user. The solution to this problem is to STORE encrypted passwords in a database. This is called password hashing. As part of a general security concept, Hashing involves ENCODING a string according to the hashing algorithm used. MD4, MD5, SHA (Security Hashing Algorithm) like SHA256 SHA128, etc., are some of the hashing ALGORITHMS that can be APPLIED. The hashing method should take the password as input and return a hashed string, which should be stored in a database rather than plain text. |
|
| 6. |
What is method security and why do we need it? |
|
Answer» Simply put, SPRING method security lets us add or support authorization at the method level. Spring security checks the authorization of the logged-in user in addition to authentication. Upon login, the ROLE of the user is USED to determine which user is authorized to access the resource. When creating a new user in WebSecurityConfig, we can SPECIFY his ROLE as well. A security measure applied to a method prevents unauthorized users and only allows authentic users. The purpose of method level security is not to facilitate users who have access but to prevent unauthorized users from performing activities beyond their privileges and roles. Method level security is IMPLEMENTED using AOP (Aspect-Oriented Programming). |
|
| 7. |
What do you mean by OAuth2 Authorization code grant type? |
|
Answer» The TERM "grant type" in OAuth 2.0 refers to the way an application gets an access token. The authorization code flow is one of several types of grants defined by OAuth 2.0. This grant is used by both web APPLICATIONS and native applications to obtain an access token after a USER authorizes the application. As opposed to most other grant types, it requires the application to first LAUNCH a browser to begin the process/flow. The process involves the following steps:
|
|
| 8. |
Explain spring security OAuth2. |
|
Answer» A simple AUTHORIZATION framework, OAuth 2.0, permits client applications to access protected resources via an authorization server. Using it, a client application (third party) can gain limited access to an HTTP service on behalf of the resource owner or on its own behalf. In OAuth2, four roles are AVAILABLE as shown below:
|
|
| 9. |
Explain SecurityContext and SecurityContext Holder in Spring security. |
|
Answer» There are two fundamental classes of SPRING Security: SecurityContext and SecurityContextHolder.
|
|
| 10. |
What do you mean by session management in Spring Security? |
|
Answer» As far as SECURITY is concerned, session management relates to securing and managing multiple users' sessions against their request. It facilitates secure interactions between a user and a service/application and pertains to a sequence of requests and responses associated with a particular user. Session Management is one of the most critical aspects of Spring security as if sessions are not managed PROPERLY, the security of DATA will suffer. To CONTROL HTTP sessions, Spring security uses the following options:
With these two, spring-security can manage the following security session options:
|
|
| 11. |
What do you mean by digest authentication? |
|
Answer» RESTful web services can be authenticated in MANY ways, but advanced authentication methods include digest authentication. It applies a hash FUNCTION to username, password, HTTP method, and URI in order to send credentials in encrypted form. It generates more complex cryptographic results by using the hashing technique which is not EASY to decode. Syntax: Hash1=MD5(username:realm:password) Hash2=MD5(method:digestURI) response=MD5(Hash1:nonce:nonceCount:cnonce:QOP:Hash2) //Example, this got generated by running this example Authorization: Digest username="TestAdmin", realm="admin-digest-realm", nonce="MTYwMDEwMTUyMDM4OToxM2M1Y2I4MGFjMjk4OGI1ODQzZjc3NDUzOGFlMjZjYw==", uri="/admin/hello?name=User", response="2f080edbec53be2bdf3853d477e4a543", qop=auth, nc=00000002, cnonce="11ecd9bf947dbcf4" |
|
| 12. |
What do you mean by basic authentication? |
|
Answer» RESTful web services can be authenticated in many WAYS, but the most BASIC one is basic authentication. For basic authentication, we send a username and password using the HTTP [Authorization] header to enable us to access the resource. Usernames and passwords are encoded using base64 encoding (not encryption) in Basic Authentication. The encoding is not secure SINCE it can be easily decoded. Syntax: Value = username:password Encoded Value = base64(Value) Authorization Value = Basic <Encoded Value> //Example: Authorization: Basic VGVzdFVzZXI6dGVzdDEyMw== //Decode it'll GIVE back the original username:password UserName:user123 |
|
| 13. |
What is Spring security authentication and authorization? |
Answer»
|
|
| 14. |
What are some essential features of Spring Security? |
|
Answer» Some ESSENTIAL features of Spring Security include:
|
|