Package mops.businesslogic.security
Class SecurityServiceImpl
- java.lang.Object
-
- mops.businesslogic.security.SecurityServiceImpl
-
- All Implemented Interfaces:
SecurityService
@Service public class SecurityServiceImpl extends java.lang.Object implements SecurityService
Checks roles permissions.
-
-
Constructor Summary
Constructors Constructor Description SecurityServiceImpl(GroupService groupService, PermissionService permissionService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkDeletePermission(Account account, Directory directory)
Checks if the user has deleting rights.void
checkIfRole(Account account, long groupId, java.lang.String allowedRole)
Checks if user is has a role.void
checkReadPermission(Account account, Directory directory)
Checks if the user has reading rights.void
checkWritePermission(Account account, Directory directory)
Checks if the user has writing rights.UserPermission
getPermissionsOfUser(Account account, Directory directory)
Gets all 3 permissions of a user in a directory.java.lang.String
getUserRole(long groupId, Account account)
Get the role of a given user in a group.boolean
isUserAdmin(Account account, long groupId)
Checks if user is has the admin role.
-
-
-
Constructor Detail
-
SecurityServiceImpl
public SecurityServiceImpl(GroupService groupService, PermissionService permissionService)
-
-
Method Detail
-
getPermissionsOfUser
public UserPermission getPermissionsOfUser(Account account, Directory directory) throws MopsException
Gets all 3 permissions of a user in a directory.- Specified by:
getPermissionsOfUser
in interfaceSecurityService
- Parameters:
account
- user credentialsdirectory
- the directory- Returns:
- a permission flag object
- Throws:
MopsException
-
checkWritePermission
public void checkWritePermission(Account account, Directory directory) throws MopsException
Checks if the user has writing rights.- Specified by:
checkWritePermission
in interfaceSecurityService
- Parameters:
account
- user credentialsdirectory
- id of the directory to check- Throws:
MopsException
- checked exception to present to UI
-
checkReadPermission
public void checkReadPermission(Account account, Directory directory) throws MopsException
Checks if the user has reading rights.- Specified by:
checkReadPermission
in interfaceSecurityService
- Parameters:
account
- user credentialsdirectory
- id of the directory to check- Throws:
MopsException
- checked exception to present to UI
-
checkDeletePermission
public void checkDeletePermission(Account account, Directory directory) throws MopsException
Checks if the user has deleting rights.- Specified by:
checkDeletePermission
in interfaceSecurityService
- Parameters:
account
- user credentialsdirectory
- id of the directory to check- Throws:
MopsException
- checked exception to present to UI
-
isUserAdmin
public boolean isUserAdmin(Account account, long groupId) throws MopsException
Checks if user is has the admin role.- Specified by:
isUserAdmin
in interfaceSecurityService
- Parameters:
account
- user credentialsgroupId
- id of the group to check- Returns:
- true if admin
- Throws:
MopsException
-
checkIfRole
public void checkIfRole(Account account, long groupId, java.lang.String allowedRole) throws MopsException
Checks if user is has a role.- Specified by:
checkIfRole
in interfaceSecurityService
- Parameters:
account
- user credentialsgroupId
- id of the group to checkallowedRole
- role which has the right- Throws:
MopsException
- checked exception to present to UI
-
getUserRole
public java.lang.String getUserRole(long groupId, Account account) throws MopsException
Get the role of a given user in a group.- Specified by:
getUserRole
in interfaceSecurityService
- Parameters:
groupId
- group to checkaccount
- given user- Returns:
- user role
- Throws:
MopsException
-
-