@Test public void hasPagePermissionWithPageRestrictingAccessMustHonorAdminPermission() throws IOException { Page page = Page.fromText("title", "text"); page.setViewRestrictionRole("viewRole"); when(pageStore.getPage("project", "branch", DocumentrConstants.HOME_PAGE_NAME + "/foo", false)) .thenReturn(page); Authentication authentication = mockAuthentication(new PermissionGrantedAuthority( GrantedAuthorityTarget.APPLICATION, Permission.ADMIN)); assertTrue(permissionEvaluator.hasPagePermission(authentication, "project", "branch", DocumentrConstants.HOME_PAGE_NAME + "/foo", Permission.VIEW)); }
public boolean hasPagePermission(Authentication authentication, String projectName, String branchName, String path, Permission permission) { if (hasBranchPermission(authentication, projectName, branchName, Permission.ADMIN)) { return true; } else if (hasBranchPermission(authentication, projectName, branchName, permission)) { try { String viewRestrictionRole = pageStore.getViewRestrictionRole(projectName, branchName, path); return StringUtils.isBlank(viewRestrictionRole) || hasRoleOnBranch(authentication, projectName, branchName, viewRestrictionRole); } catch (IOException e) { throw new AuthenticationServiceException(e.getMessage(), e); } catch (PageNotFoundException e) { throw new AuthenticationServiceException(e.getMessage(), e); } } return false; }
DocumentrPermissionEvaluator implements PermissionEvaluator { public boolean hasPagePermission(Authentication authentication, String projectName, String branchName, String path, Permission permission) { if (hasBranchPermission(authentication, projectName, branchName, Permission.ADMIN)) { return true; } else if (hasBranchPermission(authentication, projectName, branchName, permission)) { try { String viewRestrictionRole = pageStore.getViewRestrictionRole(projectName, branchName, path); return StringUtils.isBlank(viewRestrictionRole) || hasRoleOnBranch(authentication, projectName, branchName, viewRestrictionRole); } catch (IOException e) { throw new AuthenticationServiceException(e.getMessage(), e); } catch (PageNotFoundException e) { throw new AuthenticationServiceException(e.getMessage(), e); } } return false; } }
DocumentrPermissionEvaluator implements PermissionEvaluator { public boolean hasPagePermission(Authentication authentication, String projectName, String branchName, String path, Permission permission) { if (hasBranchPermission(authentication, projectName, branchName, Permission.ADMIN)) { return true; } else if (hasBranchPermission(authentication, projectName, branchName, permission)) { try { String viewRestrictionRole = pageStore.getViewRestrictionRole(projectName, branchName, path); return StringUtils.isBlank(viewRestrictionRole) || hasRoleOnBranch(authentication, projectName, branchName, viewRestrictionRole); } catch (IOException e) { throw new AuthenticationServiceException(e.getMessage(), e); } catch (PageNotFoundException e) { throw new AuthenticationServiceException(e.getMessage(), e); } } return false; }  }
DocumentrPermissionEvaluator implements PermissionEvaluator { public boolean hasPagePermission(Authentication authentication, String projectName, String branchName, String path, Permission permission) { if (hasBranchPermission(authentication, projectName, branchName, Permission.ADMIN)) { return true; } else if (hasBranchPermission(authentication, projectName, branchName, permission)) { try { String viewRestrictionRole = pageStore.getViewRestrictionRole(projectName, branchName, path); return StringUtils.isBlank(viewRestrictionRole) || hasRoleOnBranch(authentication, projectName, branchName, viewRestrictionRole); } catch (IOException e) { throw new AuthenticationServiceException(e.getMessage(), e); } catch (PageNotFoundException e) { throw new AuthenticationServiceException(e.getMessage(), e); } } return false; }  @Override boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission); @Override boolean hasPermission(Authentication authentication, Serializable targetId, String targetType,
			Object permission); boolean hasApplicationPermission(Authentication authentication, Permission permission); boolean hasProjectPermission(Authentication authentication, String projectName, Permission permission); boolean hasAnyProjectPermission(Authentication authentication, Permission permission); boolean hasBranchPermission(Authentication authentication, String projectName, String branchName,
			Permission permission); boolean hasAnyBranchPermission(Authentication authentication, String projectName, Permission permission); boolean hasPagePermission(Authentication authentication, String projectName, String branchName,
			String path, Permission permission); boolean hasPagePermissionInOtherBranches(Authentication authentication, String projectName,
			String branchName, String path, Permission permission); Set<String> getBranchesForPermission(Authentication authentication, Permission permission); boolean isAdmin(String loginName); boolean isLastAdminRole(String roleName); }
DocumentrPermissionEvaluator implements PermissionEvaluator { public boolean hasPagePermission(Authentication authentication, String projectName, String branchName, String path, Permission permission) { if (hasBranchPermission(authentication, projectName, branchName, Permission.ADMIN)) { return true; } else if (hasBranchPermission(authentication, projectName, branchName, permission)) { try { String viewRestrictionRole = pageStore.getViewRestrictionRole(projectName, branchName, path); return StringUtils.isBlank(viewRestrictionRole) || hasRoleOnBranch(authentication, projectName, branchName, viewRestrictionRole); } catch (IOException e) { throw new AuthenticationServiceException(e.getMessage(), e); } catch (PageNotFoundException e) { throw new AuthenticationServiceException(e.getMessage(), e); } } return false; }  @Override boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission); @Override boolean hasPermission(Authentication authentication, Serializable targetId, String targetType,
			Object permission); boolean hasApplicationPermission(Authentication authentication, Permission permission); boolean hasProjectPermission(Authentication authentication, String projectName, Permission permission); boolean hasAnyProjectPermission(Authentication authentication, Permission permission); boolean hasBranchPermission(Authentication authentication, String projectName, String branchName,
			Permission permission); boolean hasAnyBranchPermission(Authentication authentication, String projectName, Permission permission); boolean hasPagePermission(Authentication authentication, String projectName, String branchName,
			String path, Permission permission); boolean hasPagePermissionInOtherBranches(Authentication authentication, String projectName,
			String branchName, String path, Permission permission); Set<String> getBranchesForPermission(Authentication authentication, Permission permission); boolean isAdmin(String loginName); boolean isLastAdminRole(String roleName);  }