/** * Constructs an UnauthorizedException for the specified user's attempt to take a specified action. * * @param user * the current user * @param action * the action attempted */ public UnauthorizedException(User user, String action) { super(formatMessage(user, action, null)); }
if (response != null) { if (HttpStatus.SC_UNAUTHORIZED == response.getStatusLine().getStatusCode()) { throw new UnauthorizedException("You do not have permission to cleanup"); } else { logger.info("Successful request to workflow cleanup endpoint");
throw new NotFoundException("Workflow instance with id='" + workflowInstanceId + "' not found"); } else if (response.getStatusLine().getStatusCode() == SC_UNAUTHORIZED) { throw new UnauthorizedException("You do not have permission to resume"); } else if (response.getStatusLine().getStatusCode() == SC_CONFLICT) { throw new IllegalStateException("Can not resume a workflow where the current state is not in paused");
/** * Check if the current user has access to the capture agent with the given id. * @param agentId * The agent id to check. * @throws UnauthorizedException * If the user doesn't have access. */ public static void checkAgentAccess(final SecurityService securityService, final String agentId) throws UnauthorizedException { if (isBlank(agentId)) { return; } final User user = securityService.getUser(); if (user.hasRole(SecurityConstants.GLOBAL_ADMIN_ROLE) || user.hasRole(user.getOrganization().getAdminRole())) { return; } if (!user.hasRole(SecurityUtil.getCaptureAgentRole(agentId))) { throw new UnauthorizedException(user, "schedule"); } }
/** * Constructs an UnauthorizedException for the specified user's attempt to take a specified action. * * @param user * the current user * @param action * the action attempted * @param acl * the access control list that prevented the action */ public UnauthorizedException(User user, String action, AccessControlList acl) { super(formatMessage(user, action, acl)); }