test_class.declarator: userRepository
test_class.modifier: @Resource
      private
test_class.original_string: @Resource
      private UserRepository userRepository;
test_class.type: UserRepository
test_class.var_name: userRepository
test_class.declarator: pageRepository
test_class.modifier: @Resource
      private
test_class.original_string: @Resource
      private PageRepository pageRepository;
test_class.type: PageRepository
test_class.var_name: pageRepository
test_class.declarator: moduleRepository
test_class.modifier: @Resource
      private
test_class.original_string: @Resource
      private ModuleRepository moduleRepository;
test_class.type: ModuleRepository
test_class.var_name: moduleRepository
test_class.declarator: securityService
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private SecurityService securityService;
test_class.type: SecurityService
test_class.var_name: securityService
test_class.file: abixen-platform-core/src/test/java/com/abixen/platform/core/application/service/SecurityServiceTest.java
test_class.identifier: SecurityServiceTest
test_case.body: @Ignore
      @Test
      public void userAdminHasPermissionToEditModule() {
          log.debug("userAdminHasPermissionToEditModule()");
          User admin = userRepository.findOne(1L);
          Module module = moduleRepository.findOne(2L);
          Boolean hasPermission = securityService.hasUserPermissionToObject(admin, PermissionName.MODULE_EDIT, module);
  
          assertTrue(hasPermission);
      }
test_case.class_method_signature: SecurityServiceTest.userAdminHasPermissionToEditModule()
test_case.full_signature: @Ignore @Test public void userAdminHasPermissionToEditModule()
test_case.identifier: userAdminHasPermissionToEditModule
test_case.invocations: debug findOne findOne hasUserPermissionToObject assertTrue
test_case.modifiers: @Ignore @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void userAdminHasPermissionToEditModule()
focal_class.declarator: userService
focal_class.modifier: private final
focal_class.original_string: private final UserService userService;
focal_class.type: UserService
focal_class.var_name: userService
focal_class.declarator: aclEntryService
focal_class.modifier: private final
focal_class.original_string: private final AclEntryService aclEntryService;
focal_class.type: AclEntryService
focal_class.var_name: aclEntryService
focal_class.file: abixen-platform-core/src/main/java/com/abixen/platform/core/application/service/SecurityService.java
focal_class.identifier: SecurityService
focal_class.class_method_signature: SecurityService.SecurityService(UserService userService,
                             AclEntryService aclEntryService)
focal_class.full_signature: @Autowired public  SecurityService(UserService userService,
                             AclEntryService aclEntryService)
focal_class.identifier: SecurityService
focal_class.modifiers: @Autowired public
focal_class.parameters: (UserService userService,
                             AclEntryService aclEntryService)
focal_class.signature:  SecurityService(UserService userService,
                             AclEntryService aclEntryService)
focal_class.class_method_signature: SecurityService.hasUserPermissionToObject(final User user, final PermissionName permissionName, final SecurableModel securableModel)
focal_class.full_signature: public Boolean hasUserPermissionToObject(final User user, final PermissionName permissionName, final SecurableModel securableModel)
focal_class.identifier: hasUserPermissionToObject
focal_class.modifiers: public
focal_class.parameters: (final User user, final PermissionName permissionName, final SecurableModel securableModel)
focal_class.return: Boolean
focal_class.signature: Boolean hasUserPermissionToObject(final User user, final PermissionName permissionName, final SecurableModel securableModel)
focal_class.class_method_signature: SecurityService.hasUserPermissionToClass(User user, PermissionName permissionName, String domainCanonicalClassName)
focal_class.full_signature: public Boolean hasUserPermissionToClass(User user, PermissionName permissionName, String domainCanonicalClassName)
focal_class.identifier: hasUserPermissionToClass
focal_class.modifiers: public
focal_class.parameters: (User user, PermissionName permissionName, String domainCanonicalClassName)
focal_class.return: Boolean
focal_class.signature: Boolean hasUserPermissionToClass(User user, PermissionName permissionName, String domainCanonicalClassName)
focal_class.class_method_signature: SecurityService.getAuthorizedUser()
focal_class.full_signature: public PlatformUser getAuthorizedUser()
focal_class.identifier: getAuthorizedUser
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: PlatformUser
focal_class.signature: PlatformUser getAuthorizedUser()
focal_class.class_method_signature: SecurityService.hasPermission(String username, SecurableModel securibleObject, String permissionName)
focal_class.full_signature: public boolean hasPermission(String username, SecurableModel securibleObject, String permissionName)
focal_class.identifier: hasPermission
focal_class.modifiers: public
focal_class.parameters: (String username, SecurableModel securibleObject, String permissionName)
focal_class.return: boolean
focal_class.signature: boolean hasPermission(String username, SecurableModel securibleObject, String permissionName)
focal_method.body: public Boolean hasUserPermissionToObject(final User user, final PermissionName permissionName, final SecurableModel securableModel) {
          if (user == null) {
              throw new IllegalArgumentException("User can not be null.");
          }
          if (permissionName == null) {
              throw new IllegalArgumentException("Permission Name can not be null.");
          }
          if (securableModel == null) {
              throw new IllegalArgumentException("SecurableModel can not be null.");
          }
  
          if (hasUserPermissionToClass(user, permissionName, securableModel.getClass().getCanonicalName())) {
              return true;
          }
  
          final List<Long> userRoleIds = new ArrayList<>();
          for (Role role : user.getRoles()) {
              userRoleIds.add(role.getId());
          }
          final List<AclEntry> rolesAclEntries = aclEntryService.findAll(permissionName, AclSidType.ROLE, userRoleIds, AclClassName.getByName(securableModel.getClass().getCanonicalName()), securableModel.getId());
  
          if (rolesAclEntries.size() > 0) {
              if (log.isDebugEnabled()) {
                  log.debug("User " + user.getUsername() + " has permission " + permissionName + " to object " + securableModel.getClass().getCanonicalName() + "[id=" + securableModel.getId() + "] based on the ACL security settings.");
              }
              return true;
          }
  
          if (securableModel.getCreatedBy() != null && securableModel.getCreatedBy().getId().equals(user.getId())) {
              List<AclEntry> ownerAclEntries = aclEntryService.findAll(permissionName, AclSidType.OWNER, 0L, AclClassName.getByName(securableModel.getClass().getCanonicalName()), securableModel.getId());
              if (ownerAclEntries.size() > 0) {
                  if (log.isDebugEnabled()) {
                      log.debug("User " + user.getUsername() + " has permission " + permissionName + " to object " + securableModel.getClass().getCanonicalName() + "[id=" + securableModel.getId() + "] based on that he is the owner.");
                  }
                  return true;
              }
          }
  
          if (log.isDebugEnabled()) {
              log.debug("User " + user.getUsername() + " has not permission " + permissionName + " to object " + securableModel.getClass().getCanonicalName() + "[id=" + securableModel.getId() + "].");
          }
          return false;
      }
focal_method.class_method_signature: SecurityService.hasUserPermissionToObject(final User user, final PermissionName permissionName, final SecurableModel securableModel)
focal_method.full_signature: public Boolean hasUserPermissionToObject(final User user, final PermissionName permissionName, final SecurableModel securableModel)
focal_method.identifier: hasUserPermissionToObject
focal_method.invocations: hasUserPermissionToClass getCanonicalName getClass getRoles add getId findAll getByName getCanonicalName getClass getId size isDebugEnabled debug getUsername getCanonicalName getClass getId getCreatedBy equals getId getCreatedBy getId findAll getByName getCanonicalName getClass getId size isDebugEnabled debug getUsername getCanonicalName getClass getId isDebugEnabled debug getUsername getCanonicalName getClass getId
focal_method.modifiers: public
focal_method.parameters: (final User user, final PermissionName permissionName, final SecurableModel securableModel)
focal_method.return: Boolean
focal_method.signature: Boolean hasUserPermissionToObject(final User user, final PermissionName permissionName, final SecurableModel securableModel)