Package edu.ucsb.cs156.rec.services
Class CurrentUserServiceImpl
java.lang.Object
edu.ucsb.cs156.rec.services.CurrentUserService
edu.ucsb.cs156.rec.services.CurrentUserServiceImpl
This is a service that provides information about the current user.
This is the version of the service used in production.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionThis method returns the current user as a User object.getOAuth2AuthenticatedUser
(org.springframework.security.core.context.SecurityContext securityContext, org.springframework.security.core.Authentication authentication) This method obtains the current user that is logged in with OAuth2, if any.Collection
<? extends org.springframework.security.core.GrantedAuthority> getRoles()
This method returns the roles of the current user.getUser()
This method returns the current user as a User object.Methods inherited from class edu.ucsb.cs156.rec.services.CurrentUserService
isLoggedIn
-
Constructor Details
-
CurrentUserServiceImpl
public CurrentUserServiceImpl()
-
-
Method Details
-
getCurrentUser
This method returns the current user as a User object.- Specified by:
getCurrentUser
in classCurrentUserService
- Returns:
- the current user
-
getOAuth2AuthenticatedUser
public User getOAuth2AuthenticatedUser(org.springframework.security.core.context.SecurityContext securityContext, org.springframework.security.core.Authentication authentication) This method obtains the current user that is logged in with OAuth2, if any. The parameters are automatically injected by Spring. This method also has a side effect of storing the user in the database if they are not already there.- Parameters:
securityContext
- the security context (provided by Spring)authentication
- the authentication token (provided by Spring)- Returns:
- the User object representing the current user
-
getUser
This method returns the current user as a User object.- Specified by:
getUser
in classCurrentUserService
- Returns:
- the current user
-
getRoles
This method returns the roles of the current user.- Specified by:
getRoles
in classCurrentUserService
- Returns:
- a collection of roles
-