Class SecurityServiceImpl
java.lang.Object
org.craftercms.studio.impl.v1.service.security.SecurityServiceImpl
- All Implemented Interfaces:
SecurityService
- Author:
- Dejan Brkic
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuditServiceInternalprotected com.google.common.cache.Cache<String, PermissionsConfigTO> protected ConfigurationServiceprotected ContentServiceprotected ContentTypeServiceprotected org.springframework.mail.javamail.JavaMailSenderprotected org.springframework.mail.javamail.JavaMailSenderprotected org.springframework.beans.factory.ObjectFactory<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> protected GeneralLockServiceprotected GroupServiceprotected SiteServiceprotected StudioConfigurationprotected UserServiceInternal -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddGlobalGroupRoles(Set<NormalizedRole> roles, List<String> groups, PermissionsConfigTO rolesConfig) protected voidaddGlobalUserRoles(String user, Set<NormalizedRole> roles, PermissionsConfigTO rolesConfig) protected voidaddUserRoles(Set<NormalizedRole> roles, String site, String user) add user rolesintGet all usersorg.springframework.security.core.AuthenticationReturns theAuthenticationfor the current user or null if not user is authenticated.Returns the username of the current user OR NULL if no user is authenticatedorg.springframework.mail.javamail.JavaMailSenderorg.springframework.mail.javamail.JavaMailSenderorg.springframework.beans.factory.ObjectFactory<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> protected StringgetPermissionsKey(String site, String filename) protected Map<NormalizedGroup, List<NormalizedRole>> getRoles(List<org.dom4j.Node> nodes, Map<NormalizedGroup, List<NormalizedRole>> rolesMap) int@Valid List<NormalizedRole> getUserGlobalRoles(long userId, String username) getUserPermissions(String site, String path, String user) getUserProfile(String user) getUserProfileByGitName(String gitName) Get user by git name.getUserRoles(String site) @Valid Set<NormalizedRole> getUserRoles(String site, String user) @Valid Set<NormalizedRole> getUserRoles(String site, String user, boolean includeGlobal) boolean@jakarta.validation.Valid booleanisSiteAdmin(String username, String site) Check if given user is site admin@jakarta.validation.Valid booleanisSystemAdmin(String username) Check if given user has system_admin roleprotected PermissionsConfigTOloadConfiguration(String site, String filename) protected PermissionsConfigTOprotected PermissionsConfigTOprotected voidloadPermissions(String siteId, org.dom4j.Element root, PermissionsConfigTO config) protected voidloadRoles(org.dom4j.Element root, PermissionsConfigTO config) populateUserGlobalPermissions(String path, Set<NormalizedRole> roles, PermissionsConfigTO permissionsConfig) populateUserPermissions(String site, String path, Set<NormalizedRole> roles, PermissionsConfigTO permissionsConfig) populate user permissionsvoidsetAuditServiceInternal(AuditServiceInternal auditServiceInternal) voidsetCache(com.google.common.cache.Cache<String, PermissionsConfigTO> cache) voidsetConfigurationService(ConfigurationService configurationService) voidsetContentService(ContentService contentService) voidsetContentTypeService(ContentTypeService contentTypeService) voidsetEmailService(org.springframework.mail.javamail.JavaMailSender emailService) voidsetEmailServiceNoAuth(org.springframework.mail.javamail.JavaMailSender emailServiceNoAuth) voidsetFreeMarkerConfig(org.springframework.beans.factory.ObjectFactory<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> freeMarkerConfig) voidsetGeneralLockService(GeneralLockService generalLockService) voidsetGroupService(GroupService groupService) voidsetSiteService(SiteService siteService) voidsetStudioConfiguration(StudioConfiguration studioConfiguration) voidsetUserServiceInternal(UserServiceInternal userServiceInternal) @jakarta.validation.Valid booleanuserExists(String username) Check if user exists
-
Field Details
-
contentTypeService
-
contentService
-
generalLockService
-
studioConfiguration
-
emailService
protected org.springframework.mail.javamail.JavaMailSender emailService -
emailServiceNoAuth
protected org.springframework.mail.javamail.JavaMailSender emailServiceNoAuth -
freeMarkerConfig
protected org.springframework.beans.factory.ObjectFactory<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> freeMarkerConfig -
groupService
-
userServiceInternal
-
configurationService
-
auditServiceInternal
-
siteService
-
cache
-
-
Constructor Details
-
SecurityServiceImpl
public SecurityServiceImpl()
-
-
Method Details
-
getCurrentUser
Description copied from interface:SecurityServiceReturns the username of the current user OR NULL if no user is authenticated- Specified by:
getCurrentUserin interfaceSecurityService- Returns:
- current user
-
getUserProfile
@Valid public @Valid Map<String,Object> getUserProfile(String user) throws ServiceLayerException, UserNotFoundException - Specified by:
getUserProfilein interfaceSecurityService- Throws:
ServiceLayerExceptionUserNotFoundException
-
getUserProfileByGitName
public Map<String,Object> getUserProfileByGitName(String gitName) throws ServiceLayerException, UserNotFoundException Description copied from interface:SecurityServiceGet user by git name. Special use case because git stores user as string of first and last name separated by ' '- Specified by:
getUserProfileByGitNamein interfaceSecurityService- Parameters:
gitName- first and last name separated with ' '- Returns:
- user
- Throws:
ServiceLayerException- general service errorUserNotFoundException- user not found
-
getUserPermissions
- Specified by:
getUserPermissionsin interfaceSecurityService
-
addGlobalUserRoles
protected void addGlobalUserRoles(String user, Set<NormalizedRole> roles, PermissionsConfigTO rolesConfig) -
addGlobalGroupRoles
protected void addGlobalGroupRoles(Set<NormalizedRole> roles, List<String> groups, PermissionsConfigTO rolesConfig) -
populateUserGlobalPermissions
protected Set<String> populateUserGlobalPermissions(String path, Set<NormalizedRole> roles, PermissionsConfigTO permissionsConfig) -
getPermissionsKey
-
addUserRoles
add user roles- Parameters:
roles-site-user-
-
getUserRoles
- Specified by:
getUserRolesin interfaceSecurityService
-
getUserRoles
- Specified by:
getUserRolesin interfaceSecurityService
-
getUserRoles
@Valid public @Valid Set<NormalizedRole> getUserRoles(String site, String user, boolean includeGlobal) - Specified by:
getUserRolesin interfaceSecurityService
-
populateUserPermissions
protected Set<String> populateUserPermissions(String site, String path, Set<NormalizedRole> roles, PermissionsConfigTO permissionsConfig) populate user permissions- Parameters:
site-path-roles-permissionsConfig-
-
loadConfiguration
-
loadRoles
-
getRoles
protected Map<NormalizedGroup,List<NormalizedRole>> getRoles(List<org.dom4j.Node> nodes, Map<NormalizedGroup, List<NormalizedRole>> rolesMap) -
loadPermissions
-
loadGlobalPermissionsConfiguration
-
loadGlobalRolesConfiguration
-
getAllUsersTotal
Description copied from interface:SecurityServiceGet all users- Specified by:
getAllUsersTotalin interfaceSecurityService- Returns:
- number of all users
- Throws:
ServiceLayerException- general service error
-
isSystemAdmin
Description copied from interface:SecurityServiceCheck if given user has system_admin role- Specified by:
isSystemAdminin interfaceSecurityService- Parameters:
username- user- Returns:
- true if user is system_admin, false otherwise
-
isSiteAdmin
Description copied from interface:SecurityServiceCheck if given user is site admin- Specified by:
isSiteAdminin interfaceSecurityService- Parameters:
username- usersite- site identifier- Returns:
- true if user belongs to admin group
-
userExists
@Valid public @jakarta.validation.Valid boolean userExists(String username) throws ServiceLayerException Description copied from interface:SecurityServiceCheck if user exists- Specified by:
userExistsin interfaceSecurityService- Parameters:
username- username- Returns:
- true if user exists
- Throws:
ServiceLayerException- general service error
-
getAuthentication
public org.springframework.security.core.Authentication getAuthentication()Description copied from interface:SecurityServiceReturns theAuthenticationfor the current user or null if not user is authenticated.- Specified by:
getAuthenticationin interfaceSecurityService- Returns:
- authentication
-
getUserGlobalRoles
@Valid public @Valid List<NormalizedRole> getUserGlobalRoles(long userId, String username) throws ServiceLayerException, UserNotFoundException - Specified by:
getUserGlobalRolesin interfaceSecurityService- Throws:
ServiceLayerExceptionUserNotFoundException
-
getRoleMappingsFileName
-
getPermissionsFileName
-
getGlobalConfigPath
-
getGlobalRoleMappingsFileName
-
getGlobalPermissionsFileName
-
getSessionTimeout
public int getSessionTimeout() -
isAuthenticatedSMTP
public boolean isAuthenticatedSMTP() -
getDefaultFromAddress
-
getSystemSite
-
getContentTypeService
-
setContentTypeService
-
getContentService
-
setContentService
-
getGeneralLockService
-
setGeneralLockService
-
getStudioConfiguration
-
setStudioConfiguration
-
getEmailService
public org.springframework.mail.javamail.JavaMailSender getEmailService() -
setEmailService
public void setEmailService(org.springframework.mail.javamail.JavaMailSender emailService) -
getEmailServiceNoAuth
public org.springframework.mail.javamail.JavaMailSender getEmailServiceNoAuth() -
setEmailServiceNoAuth
public void setEmailServiceNoAuth(org.springframework.mail.javamail.JavaMailSender emailServiceNoAuth) -
getFreeMarkerConfig
public org.springframework.beans.factory.ObjectFactory<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> getFreeMarkerConfig() -
setFreeMarkerConfig
public void setFreeMarkerConfig(org.springframework.beans.factory.ObjectFactory<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> freeMarkerConfig) -
getGroupService
-
setGroupService
-
getUserServiceInternal
-
setUserServiceInternal
-
getConfigurationService
-
setConfigurationService
-
getAuditServiceInternal
-
setAuditServiceInternal
-
getSiteService
-
setSiteService
-
setCache
-