Package edu.ucsb.cs156.example.services
Class CurrentUserServiceImpl
java.lang.Object
edu.ucsb.cs156.example.services.CurrentUserService
edu.ucsb.cs156.example.services.CurrentUserServiceImpl
This is a service that provides information about the current user.
 
 This is the version of the service used in production.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.example.services.CurrentUserServicegetRolesSorted, isLoggedIn
- 
Constructor Details- 
CurrentUserServiceImplpublic CurrentUserServiceImpl()
 
- 
- 
Method Details- 
getCurrentUserThis method returns the current user as a User object.- Specified by:
- getCurrentUserin class- CurrentUserService
- Returns:
- the current user
 
- 
getOAuth2AuthenticatedUserpublic 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
 
- 
getUserThis method returns the current user as a User object.- Specified by:
- getUserin class- CurrentUserService
- Returns:
- the current user
 
- 
getRolesThis method returns the roles of the current user.- Specified by:
- getRolesin class- CurrentUserService
- Returns:
- a collection of roles
 
 
-