Diwali Deal : Flat 20% off + 2 free self-paced courses + $200 Voucher - SCHEDULE CALL
Ans: The SessionManagement class consists of techniques for authenticating users, building personalized login experiences, personalizing security settings, and specifying trustworthy IP ranges for a particular session. It has the namespace of Auth. This class has several methods which can also be implemented with interfaces and controllers.
Ans: The SessionManagement methods are listed below. Every method is static. Use these techniques to build unique login flows, control time-based one-time password (TOTP) apps like Google Authenticator, and tailor user identity verification processes. Other techniques check an incoming user's IP address against trusted IP range parameters for a profile or organization.
Methods |
Description |
Signature |
Parameters |
Return Value |
finishLogin Discovery (method, userId) |
It finishes the My Domain Login Discovery login process. |
Public static System.Page Reference finishLogin Discovery(Auth. LoginDiscoveryMethod method, Id userId) |
method Type: Auth.Login DiscoveryMethod LoginDiscoveryMethod Enum userId Type: Id |
Type: System.PageReference |
finishLoginFlow () |
It finishes the Visualforce Page login flow process and redirects the user to the default home page. |
Public static System.Page Reference finishLoginFlow () |
Type: System.PageReference |
|
finishLoginFlow (startUrl) |
It finishes the Visualforce Page login flow process and redirects the user to the specified start URL. |
Public static System. PageReference finishLoginFlow(String startUrl) |
startUrl Type: String |
Type: System. PageReference |
generates VerificationUrl (policy, description, destinationUrl) |
It returns a URL to the identity verification page and starts a user identity verification flow using the user's registered verification method. For instance, you can ask the user to confirm their identification before allowing them to view a custom Visualforce page that contains critical account information. |
Public static String generates VerificationUrl (Auth. VerificationPolicy policy, String description, String destinationUrl) |
policy Type: Auth.VerificationPolicy description Type: String destinationUrl Type: String |
Type: String |
getCurrent Session() |
It returns a map of attributes for the current session. |
public static Map |
Type: Map |
|
getLightning LoginEligibility (userId) |
When you set up your org with My Domain and utilize the Login Discovery page type, it will return the eligibility status for a user who is logging in with Lightning Login. Use this technique to send the user to a special login process. For instance, if a user is ineligible for Lightning Login, use after a login attempt to direct the user to password flow. |
public static Auth. Lightning LoginEligibility getLightning LoginEligibility (Id userId) |
userId Type: Id |
Type: Auth. Lightning Login Eligibility |
getQrCode() |
It enables the configuration of authenticator apps or devices for multi-factor authentication by returning a map with a URL to a rapid response (QR) code and a time-based one-time password (TOTP) shared secret (MFA). |
public static Map |
Type: Map |
|
getRequired SessionLevelFor Profile(profileId) |
It indicates the required login security session level for the given profile. |
public static Auth.Session Level getRequired SessionLevelFor Profile(String profileId) |
profileId Type: String |
Type: Auth. Session Level |
ignoreFor Concurrent SessionLimit (sessions) |
This method is reserved for internal Salesforce use. |
public static Map |
sessions Type: Object |
Type: Map |
inOrgNetwork Range(ipAddress) |
It indicates whether the given IP address is within the organization's trusted IP range according to the organization's Network Access settings. |
public static Boolean inOrgNetwork Range(String ipAddress) |
ipAddress Type: String |
Type: Boolean |
isIpAllowedFor Profile(profileId, ipAddress) |
It indicates whether the given IP address is within the trusted IP range for the given profile. |
public static Boolean isIpAllowedFor Profile(String profileId, String ipAddress) |
profileId Type: String ipAddress Type: String |
Type: Boolean |
setSessionLevel (level) |
It sets the user's current session security level. |
public static Void setSessionLevel (Auth.Session Level level) |
level Type: Auth.Session Level |
Type: Void |
validateTotp TokenForKey (shared Key, totpCode) |
It is deprecated. We must use validateTotp TokenForKey (totpSharedKey, totpCode, description) instead. |
public static Boolean validateTotp TokenForKey (String sharedKey, String totpCode) |
sharedKey Type: String totpCode Type: String |
Type: Boolean |
validateTotp TokenForKey (totpSharedKey, totpCode, description) |
It indicates whether a time-based one-time password (TOTP) code (token) is valid for the given shared key. |
public static Boolean validateTotpTokenForKey(String totpSharedKey, String totpCode, String description) |
totpSharedKey Type: String totpCode Type: String description Type: String |
Type: Boolean |
validateTotp TokenForUser (totpCode) |
It is deprecated. We must use validateTotp TokenForUser (totpCode, description) instead. |
public static Boolean validateTotp TokenForUser (String totpCode) |
totpCode Type: String |
Type: Boolean |
validateTotp TokenForUser (totpCode, description) |
It indicates whether a time-based one-time password (TOTP) code (token) is valid for the current user. |
public static Boolean validateTotp TokenForUser (String totpCode, String description) |
totpCode Type: String description Type: String |
Type: Boolean |
verifyDeviceFlow(userCode, startUrl) |
It redirects users to the OAuth approval page after verifying the user code entered during the device authentication flow. Users must log in if they aren't already. Users are prompted to grant the device access to Salesforce data after successful login. |
Public static System.Page Reference verifyDeviceFlow(String userCode, String startUrl) |
userCode Type: String startURL Type: String |
Type: System.PageReference |
Ans: Implementing the MyDomainLoginDiscoveryHandler interface should include this method in point users to an authentication mechanism and log them in.
Ans: When developing login flows programmatically, include this method in the Apex controller of the Visualforce Page login flow. This technique completes the login process, and the user is forwarded to the Experience Cloud website's default home page. Until users finish, the login procedure will run in a limited session. Using finishLoginFlow method, users are granted full access to the Experience Cloud website, a sign that the login process has been successful and the Limitation has been lifted.
Ans: When developing login flows programmatically, include this method in the Apex controller of the Visualforce Page login flow. This method completes the login process, and the user is forwarded to the desired destination on the Experience Cloud website. Until users finish, the login procedure will run in a limited session. Calling this method signals that the login process is finished, and it removes the users with complete access to the Experience Cloud website without restriction.
Ans: It initiates a user identity verification process.
Enroll in JanBask Training's industry-renowned salesforce certification courses and gain the skills and insights needed to dominate the Salesforce landscape.
Ans: If a parent session exists (for instance, if the current session is for a canvas app), the map contains a ParentId value, the 18-character ID for the parent session.
Ans: The current user's username and the returning secret are encoded in the QR code. The keys are secret and qrCodeUrl. The user's state is not changed by calling this method, nor is the user's state read. This method does not save the secret anywhere or validate the TOTP token. Instead, it always returns with a new secret. The administrator must specifically save the information for the user after comparing a TOTP token with the secret.
A 20-byte shared key that has been base32-encoded forms the secret.
Ans: All sessions connected to the current session, such as Visualforce or UI access, will have their session levels impacted by this setting.
Ans: ValidateTotpTokenForKey method throws an invalid parameter value exception, or a no data found exception, depending on whether the key is invalid. This method throws a security exception if the current user tries to validate a token more than ten times.
Ans: This method raises exceptions for invalid parameter values and no data found, respectively, if the key is invalid or doesn't exist. If the current user tries to validate a token more than ten times, this method throws a security exception.
Ans: When developing a unique Visualforce User Code Verification page for the OAuth 2.0 device authentication flow, include this method in the Apex controller. This technique checks the user code, prompts the user to log in when necessary, and asks if they want to give the device permission to access their Salesforce data. After successful verification and authentication, the user is forwarded to the page specified by the start URL.
Ans: The SessionManagement.setSessionLevel method uses the enum value of an Auth.SessionLevel. It has the namespace of Auth.
Our in-depth exploration of session management, guided by illuminating interview questions, underscores its pivotal role in optimizing user experiences and safeguarding data integrity. By gaining insights into the intricacies of session control, you're well-equipped to harness its potential, creating a seamless, secure, and user-centric digital environment.
Your roadmap to Salesforce training begins now. Choose JanBask Training's expert-led certification programs and embark on a journey that will redefine your career trajectory.
Must-Know Salesforce Apex Interview Questions and Answers
Interview Questions Based On Login Issues & Passwords
Top JWS and JWT Interview Questions and Answers
Cyber Security
QA
Salesforce
Business Analyst
MS SQL Server
Data Science
DevOps
Hadoop
Python
Artificial Intelligence
Machine Learning
Tableau
Download Syllabus
Get Complete Course Syllabus
Enroll For Demo Class
It will take less than a minute
Tutorials
Interviews
You must be logged in to post a comment