@Override public Integer apply(@Nullable String input) { return Permissions.getType(input); } });
protected boolean isGlobalPermission(final int permissionId) { return Permissions.isGlobalPermission(permissionId); }
return getText("admin.permissions.descriptions.ADMINISTER"); return getText("admin.permissions.descriptions.USE"); return getText("admin.permissions.descriptions.SYS_ADMIN"); return getText("admin.permissions.descriptions.PROJECT_ADMIN"); return getText("admin.permissions.descriptions.BROWSE"); return getText("admin.permissions.descriptions.CREATE_ISSUE"); return getText("admin.permissions.descriptions.EDIT_ISSUE"); return getText("admin.permissions.descriptions.SCHEDULE_ISSUE"); return getText("admin.permissions.descriptions.ASSIGN_ISSUE"); return getText("admin.permissions.descriptions.ASSIGNABLE_USER"); return getText("admin.permissions.descriptions.CREATE_ATTACHMENT"); return getText("admin.permissions.descriptions.RESOLVE_ISSUE"); return getText("admin.permissions.descriptions.CLOSE_ISSUE"); return getText("admin.permissions.descriptions.TRANSITION_ISSUE"); return getText("admin.permissions.descriptions.COMMENT_ISSUE");
for (String role : roles) final int permission = Permissions.getType(role); if (permission == -1) return new VoteContext(PASS); if (Permissions.isGlobalPermission(permission))
private static String resolve(final Integer permissionId) { String name = Permissions.getShortName(permissionId); ProjectPermissionKey key = systemProjectPermissionKeyByShortName(name); if (key == null) { throw new IllegalArgumentException("No permission for id : " + permissionId + " in system"); } return key.permissionKey(); } }
@SuppressWarnings("unchecked") private Set<String> getGroupsWithUsePermission() { Set<String> groupsWithUsePermission = new HashSet<String>(); for (Integer permission : (Collection<Integer>) Permissions.getUsePermissions()) { groupsWithUsePermission.addAll(globalPermissionManager.getGroupNames(permission)); } return groupsWithUsePermission; }
@Override protected String getLoginUrl(final HttpServletRequest httpServletRequest, final Set<String> missingRoles) { UserRole userRole = null; // Inform user that there is certain level of privileges required to access page // SecurityFilter is using roles-required attribute from actions.xml if (missingRoles.contains(Permissions.getShortName(Permissions.SYSTEM_ADMIN))) { userRole = UserRole.SYSADMIN; } else if(missingRoles.contains(Permissions.getShortName(Permissions.ADMINISTER))) { userRole = UserRole.ADMIN; } final SecurityConfig securityConfig = SecurityConfigFactory.getInstance(); String loginURL = securityConfig.getLoginURL(userRole != null, false); if(userRole != null) { loginURL = loginURL.replaceAll("\\$\\{userRole\\}", userRole.toString()); } return RedirectUtils.getLoginURL(loginURL, httpServletRequest); }
@SuppressWarnings("unchecked") public boolean hasUsePermission(final String userName) { final User user = getUser(userName); if (user == null) { return false; } for (final Integer permission : (Collection<Integer>) Permissions.getUsePermissions()) { if (globalPermissionManager.hasPermission(permission, user)) { return true; } } return false; }
public void init(Map<String,String> params) throws PluginParseException { permission = Permissions.getType(params.get("permission")); if (permission == -1) { throw new PluginParseException("Could not determine permission type for: " + params.get("permission")); } super.init(params); }
/** * Retrieves all the entites for this permission and then removes them. * * @param scheme to remove entites from must NOT be null * @param permissionId to remove must NOT be a global permission * @return True is all the entities are removed * @throws RemoveException */ @Override public boolean removeEntities(final GenericValue scheme, final Long permissionId) throws RemoveException { if (Permissions.isGlobalPermission(permissionId.intValue())) { throw new IllegalArgumentException("PermissionId passed must not be a global permissions " + permissionId.toString() + " is global"); } final boolean result = super.removeEntities(scheme, permissionId); schemeEntityCache.remove(getSchemeEntityCacheKey(scheme)); return result; }
public void init(Map params) throws PluginParseException { permission = Permissions.getType((String) params.get("permission")); if (permission == -1) { throw new PluginParseException("Could not determine permission type for: " + params.get("permission")); } super.init(params); }
public boolean hasPermission(PermissionManager manager, ApplicationUser user, Project project) { for (int permission : permissions) { if (Permissions.isGlobalPermission(permission)) { if (manager.hasPermission(permission, user)) { return true; } } else { if (manager.hasPermission(new ProjectPermissionKey(permission), project, user)) { return true; } } } return false; } }
private Decision authoriseForRoleViaJIRA(ApplicationUser user, String role) { // taken from the old JiraRoleMapper code and moved into here for consistency final int permissionType = Permissions.getType(role); if (permissionType == -1) { // change of behaviour here. In the old day before pluggable roles, then set of roles // was a known set and hence this post condition was a valid thing to do. // // but now with pluggable roles, this is no longer the case // //throw new IllegalArgumentException("Unknown role '" + role + "'"); // return DENIED; } return toDecision(permissionManager.hasPermission(permissionType, user)); }