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 AuditServiceInternal
protected com.google.common.cache.Cache
<String, PermissionsConfigTO> protected ConfigurationService
protected ContentService
protected ContentTypeService
protected org.springframework.mail.javamail.JavaMailSender
protected org.springframework.mail.javamail.JavaMailSender
protected org.springframework.beans.factory.ObjectFactory
<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> protected GeneralLockService
protected GroupService
protected SiteService
protected StudioConfiguration
protected UserServiceInternal
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addGlobalGroupRoles
(Set<NormalizedRole> roles, List<String> groups, PermissionsConfigTO rolesConfig) protected void
addGlobalUserRoles
(String user, Set<NormalizedRole> roles, PermissionsConfigTO rolesConfig) protected void
addUserRoles
(Set<NormalizedRole> roles, String site, String user) add user rolesint
Get all usersorg.springframework.security.core.Authentication
Returns theAuthentication
for 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.JavaMailSender
org.springframework.mail.javamail.JavaMailSender
org.springframework.beans.factory.ObjectFactory
<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> protected String
getPermissionsKey
(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 boolean
isSiteAdmin
(String username, String site) Check if given user is site admin@jakarta.validation.Valid boolean
isSystemAdmin
(String username) Check if given user has system_admin roleprotected PermissionsConfigTO
loadConfiguration
(String site, String filename) protected PermissionsConfigTO
protected PermissionsConfigTO
protected void
loadPermissions
(String siteId, org.dom4j.Element root, PermissionsConfigTO config) protected void
loadRoles
(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 permissionsvoid
setAuditServiceInternal
(AuditServiceInternal auditServiceInternal) void
setCache
(com.google.common.cache.Cache<String, PermissionsConfigTO> cache) void
setConfigurationService
(ConfigurationService configurationService) void
setContentService
(ContentService contentService) void
setContentTypeService
(ContentTypeService contentTypeService) void
setEmailService
(org.springframework.mail.javamail.JavaMailSender emailService) void
setEmailServiceNoAuth
(org.springframework.mail.javamail.JavaMailSender emailServiceNoAuth) void
setFreeMarkerConfig
(org.springframework.beans.factory.ObjectFactory<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> freeMarkerConfig) void
setGeneralLockService
(GeneralLockService generalLockService) void
setGroupService
(GroupService groupService) void
setSiteService
(SiteService siteService) void
setStudioConfiguration
(StudioConfiguration studioConfiguration) void
setUserServiceInternal
(UserServiceInternal userServiceInternal) @jakarta.validation.Valid boolean
userExists
(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:SecurityService
Returns the username of the current user OR NULL if no user is authenticated- Specified by:
getCurrentUser
in interfaceSecurityService
- Returns:
- current user
-
getUserProfile
@Valid public @Valid Map<String,Object> getUserProfile(String user) throws ServiceLayerException, UserNotFoundException - Specified by:
getUserProfile
in interfaceSecurityService
- Throws:
ServiceLayerException
UserNotFoundException
-
getUserProfileByGitName
public Map<String,Object> getUserProfileByGitName(String gitName) throws ServiceLayerException, UserNotFoundException Description copied from interface:SecurityService
Get user by git name. Special use case because git stores user as string of first and last name separated by ' '- Specified by:
getUserProfileByGitName
in interfaceSecurityService
- Parameters:
gitName
- first and last name separated with ' '- Returns:
- user
- Throws:
ServiceLayerException
- general service errorUserNotFoundException
- user not found
-
getUserPermissions
- Specified by:
getUserPermissions
in 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:
getUserRoles
in interfaceSecurityService
-
getUserRoles
- Specified by:
getUserRoles
in interfaceSecurityService
-
getUserRoles
@Valid public @Valid Set<NormalizedRole> getUserRoles(String site, String user, boolean includeGlobal) - Specified by:
getUserRoles
in 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:SecurityService
Get all users- Specified by:
getAllUsersTotal
in interfaceSecurityService
- Returns:
- number of all users
- Throws:
ServiceLayerException
- general service error
-
isSystemAdmin
Description copied from interface:SecurityService
Check if given user has system_admin role- Specified by:
isSystemAdmin
in interfaceSecurityService
- Parameters:
username
- user- Returns:
- true if user is system_admin, false otherwise
-
isSiteAdmin
Description copied from interface:SecurityService
Check if given user is site admin- Specified by:
isSiteAdmin
in 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:SecurityService
Check if user exists- Specified by:
userExists
in 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:SecurityService
Returns theAuthentication
for the current user or null if not user is authenticated.- Specified by:
getAuthentication
in interfaceSecurityService
- Returns:
- authentication
-
getUserGlobalRoles
@Valid public @Valid List<NormalizedRole> getUserGlobalRoles(long userId, String username) throws ServiceLayerException, UserNotFoundException - Specified by:
getUserGlobalRoles
in interfaceSecurityService
- Throws:
ServiceLayerException
UserNotFoundException
-
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
-