nerdexam
(ISC)2

CSSLP · Question #32

Which of the following methods determines the principle name of the current user and returns the jav

The correct answer is A. security.Principal object in the HttpServletRequest interface?. The getUserPrincipal() method in the HttpServletRequest interface determines the principal name of the current user and returns a java.security.Principal object.

Secure Software Implementation

Question

Which of the following methods determines the principle name of the current user and returns the jav

Options

  • Asecurity.Principal object in the HttpServletRequest interface?
  • BgetUserPrincipal()
  • CisUserInRole()
  • DgetRemoteUser()
  • EgetCallerPrincipal()

How the community answered

(41 responses)
  • A
    88% (36)
  • B
    2% (1)
  • D
    7% (3)
  • E
    2% (1)

Why each option

The getUserPrincipal() method in the HttpServletRequest interface determines the principal name of the current user and returns a java.security.Principal object.

Asecurity.Principal object in the HttpServletRequest interface?Correct

The `getUserPrincipal()` method of the `HttpServletRequest` interface is specifically designed to retrieve the `java.security.Principal` object representing the current authenticated user, allowing access to the user's name and other principal information.

BgetUserPrincipal()
CisUserInRole()

`isUserInRole()` checks if the authenticated user belongs to a specific security role, returning a boolean, not the principal object itself.

DgetRemoteUser()

`getRemoteUser()` returns the login name of the authenticated user as a `String`, not a `java.security.Principal` object.

EgetCallerPrincipal()

`getCallerPrincipal()` is typically used in EJB containers to get the identity of the caller performing the method invocation, not directly from the `HttpServletRequest`.

Concept tested: Java Servlet security - User authentication

Source: https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletRequest.html

Topics

#Java EE Security#User Authentication#Web Application Security#API Usage

Community Discussion

No community discussion yet for this question.

Full CSSLP Practice