void removeGroup(final Group group) throws PermissionException { try { crowdService.removeGroup(group); } catch (OperationNotPermittedException e) { throw new PermissionException(e); } }
private static void checkErrorMessages(final RemoteResponse<?> response) throws PermissionException { // Parse the error messages and throw an appropriate exception if we need to // This is not ideal, but the Confluence Remote API does not give us much choice! if (response.containsErrorWithText("NotPermittedException")) { throw new PermissionException(); } }
void setPasswordImpl(final ApplicationUser user, final String newPassword) throws PermissionException, UserNotFoundException, InvalidCredentialException { try { userUtil.changePassword(user, newPassword); } catch (OperationNotPermittedException e) { throw new PermissionException(e); } } }
private void checkPermissions(final ApplicationUser user, final SharedEntity entity) throws PermissionException { if (!hasUserPermissionToSeeEntity(user, entity)) { throw new PermissionException( "User (" + user + ") does not have permission to see entity - " + entity.getEntityType() + ":" + entity.getId()); } } }
private Issue parseForIssue(final String issueId) throws PermissionException { if (issueId == null) { return null; } try { final Long id = Long.parseLong(issueId); final Issue issue = ComponentAccessor.getIssueManager().getIssueObject(id); if (issue != null) { // ok does the user have permission to see that issue if (!hasPermissionToViewAttachment(issue)) { throw new PermissionException("The user does not have permission to see this issue"); } } return issue; } catch (NumberFormatException e) { return null; } }
private Set<ReindexRequest> processRequests(boolean waitForCompletion, Set<ReindexRequestType> reindexRequestTypes, final boolean runInBackground) throws PermissionException { final ApplicationUser user = jiraAuthenticationContext.getUser(); if (!permissionManager.hasPermission(Permissions.ADMINISTER, user)) { throw new PermissionException(); } if (reindexRequestManager.isReindexInProgress()) { throw new IllegalStateException(i18n().getText("admin.indexing.alreadyinprogress")); } Set<ReindexRequest> requests = reindexRequestManager.processPendingRequests(waitForCompletion, reindexRequestTypes, runInBackground); return ImmutableSet.copyOf(requests); }
private void validateAddAttachment(final ApplicationUser author, final Issue issue) throws AttachmentException, PermissionException { if (!attachmentManager.attachmentsEnabled()) { throw new AttachmentException("Attachments are disabled"); } if (hasNoPermissionToCreateAttachments(author, issue)) { throw new PermissionException(String.format("User '%s' has no permission to create attachments in project '%s'", getAuthorNameOrAnonymousIfNull(author), issue.getProjectObject().getKey())); } }
/** * @see AbstractViewFileServlet#getInputStream(String, com.atlassian.jira.util.io.InputStreamConsumer) */ protected void getInputStream(String attachmentQuery, InputStreamConsumer<Unit> consumer) throws PermissionException, IOException { Attachment attachment = getAttachment(attachmentQuery); if (!hasPermissionToViewAttachment(getUserName(), attachment)) { throw new PermissionException("You do not have permissions to view this issue"); } ComponentAccessor.getAttachmentManager().streamAttachmentContent(attachment, consumer); }
/** * @see AbstractViewFileServlet#getInputStream(String, com.atlassian.jira.util.io.InputStreamConsumer) */ @Override protected void getInputStream(final String attachmentPath, final InputStreamConsumer<Unit> consumer) throws IOException, PermissionException { Attachment attachment = getAttachment(attachmentPath); if (!hasPermissionToViewAttachment(getUserName(), attachment)) { throw new PermissionException("You do not have permissions to view this attachment"); } ComponentAccessor.getComponentOfType(ThumbnailManager.class).streamThumbnailContent(attachment, consumer); }
void doAddUserToGroup(final Group group, final ApplicationUser userToAdd) throws PermissionException, AddException { validateParameters(group, userToAdd); if (!crowdService.isUserMemberOfGroup(userToAdd.getDirectoryUser(), group)) { try { crowdService.addUserToGroup(userToAdd.getDirectoryUser(), group); } catch (OperationNotPermittedException e) { throw new PermissionException(e); } catch (OperationFailedException e) { throw new AddException(e); } } }
throw new PermissionException(e);
@Override public void changePassword(final ApplicationUser user, final String newPassword) throws PermissionException, InvalidCredentialException { Assertions.notNull("user", user); new PasswordResetTokenBuilder(crowdService).resetToken(user); ComponentAccessor.getComponent(RememberMeTokenDao.class).removeAllForUser(user.getName()); ComponentAccessor.getComponent(LoginManager.class).resetFailedLoginCount(user); try { crowdService.updateUserCredential(user.getDirectoryUser(), newPassword); } catch (OperationNotPermittedException e) { throw new PermissionException(e); } catch (InvalidCredentialException e) { throw new RuntimeException(e); } }
@Override public void removeUserFromGroup(final Group group, final ApplicationUser userToRemove) throws PermissionException, RemoveException { validateParameters(group, userToRemove); if (crowdService.isUserDirectGroupMember(userToRemove.getDirectoryUser(), group)) { try { crowdService.removeUserFromGroup(userToRemove.getDirectoryUser(), group); } catch (OperationNotPermittedException e) { throw new PermissionException(e); } catch (OperationFailedException e) { throw new RemoveException(e); } } clearCache(); }
throw new PermissionException(e);
throw new PermissionException("The requesting user (" + (user == null ? "anonymous" : user.getName()) + ") does not have the permission to edit the issue.");
throw new PermissionException(); throw new PermissionException(); default: throw new ResponseException(response.getStatusText());