Interface AuthenticationUtils
- All Known Implementing Classes:
DefaultAuthenticationUtils
public interface AuthenticationUtils
The common utility that contains some useful methods around
Authentication
.- Author:
- Sunny Yu
-
Method Summary
Modifier and TypeMethodDescriptionRetrieves the account id found on the authentication of the current security context.Retrieves the id of the CSR user, if any.Retrieves the username of the CSR user, if any.Retrieves the id of the authenticated customer, if any.Retrieves the customer segment ids found on the authentication of the current security context.Retrieves the full name of the authenticated user, if any.Retrieves a list of all parent account ids of thegetAuthenticatedAccountId()
.Retrieves the username of the authenticated user, if any.default org.springframework.security.core.Authentication
Retrieve the current SpringAuthentication
instance associated with the current flow, if any.Retrieves the attributes on the currentAuthentication
.boolean
Checks if the authenticated user is anonymous.boolean
Checks if the authenticated user is CSR.default boolean
Checks if the authenticated user is CSR acting as neither an impersonated customer nor an anonymous customer but as themselves.boolean
Checks if the authenticated user is CSR anonymous.default boolean
Whether or not the current user is in an admin context.
-
Method Details
-
getAuthentication
@Nullable default org.springframework.security.core.Authentication getAuthentication()Retrieve the current SpringAuthentication
instance associated with the current flow, if any.- Returns:
- The current Spring
Authentication
instance associated with the current flow
-
getAuthenticationAttributes
Retrieves the attributes on the currentAuthentication
. This method is expected to return the attributes in a map which is generally achieved by a registeredConverter
bean.- Returns:
- the attributes, if any, on the current
Authentication
-
userIsAnonymous
boolean userIsAnonymous()Checks if the authenticated user is anonymous.- Returns:
- true if the authenticated user is anonymous, otherwise false
-
getAuthenticatedFullName
Retrieves the full name of the authenticated user, if any.- Returns:
- the full name of the authenticated user, if any
-
getAuthenticatedUsername
Retrieves the username of the authenticated user, if any.- Returns:
- the username of the authenticated user, if any
-
getAuthenticatedCustomerId
Retrieves the id of the authenticated customer, if any.- Returns:
- the id of the authenticated customer, if any
-
getAuthenticatedAccountId
Retrieves the account id found on the authentication of the current security context.- Returns:
- the account id found on the authentication of the current security context
-
getAuthenticatedParentAccountIds
Retrieves a list of all parent account ids of thegetAuthenticatedAccountId()
.The returned list does not include the account id found on the authentication of the current security context.
- Returns:
- list of all parent account ids of the
getAuthenticatedAccountId()
-
getAuthenticatedCustomerSegmentIds
Retrieves the customer segment ids found on the authentication of the current security context.- Returns:
- list of customer segment ids found on the authentication of the current security context
-
userIsCSR
boolean userIsCSR()Checks if the authenticated user is CSR.- Returns:
- true if the authenticated user is CSR, otherwise false
-
userIsCSRActingAsSelf
default boolean userIsCSRActingAsSelf()Checks if the authenticated user is CSR acting as neither an impersonated customer nor an anonymous customer but as themselves. This is used in situations such as when a CSR is managing quote requests on the storefront.- Returns:
- true if the authenticated user is CSR, otherwise false
-
userIsCSRAnonymous
boolean userIsCSRAnonymous()Checks if the authenticated user is CSR anonymous.- Returns:
- true if the authenticated user is CSR anonymous, otherwise false
-
getAuthenticatedCsrUserId
Retrieves the id of the CSR user, if any.- Returns:
- the id of the CSR user, if any
-
getAuthenticatedCsrUsername
Retrieves the username of the CSR user, if any.- Returns:
- the username of the CSR user, if any
-
userIsInAdminContext
default boolean userIsInAdminContext()Whether or not the current user is in an admin context.- Returns:
- true if the user is in an admin context
-