protected void canRunJob(Principal principal, MultivaluedMap<String,String> queryParameters, List<String> requiredRoles, List<String> requiredAuths) throws UnauthorizedQueryException { if (principal instanceof DatawavePrincipal == false) { throw new UnauthorizedQueryException(DatawaveErrorCode.JOB_EXECUTION_UNAUTHORIZED, "Principal must be DatawavePrincipal"); } DatawavePrincipal datawavePrincipal = (DatawavePrincipal) principal; if (requiredRoles != null && !requiredRoles.isEmpty()) { Set<String> usersRoles = new HashSet<>(datawavePrincipal.getPrimaryUser().getRoles()); if (!usersRoles.containsAll(requiredRoles)) { throw new UnauthorizedQueryException(DatawaveErrorCode.JOB_EXECUTION_UNAUTHORIZED, MessageFormat.format("Requires the following roles: {0}", requiredRoles)); } } if (null != queryParameters) { if (requiredAuths != null && !requiredAuths.isEmpty()) { String authsString = queryParameters.getFirst("auths"); List<String> authorizations = AuthorizationsUtil.splitAuths(authsString); if (!authorizations.containsAll(requiredAuths)) { throw new UnauthorizedQueryException(DatawaveErrorCode.JOB_EXECUTION_UNAUTHORIZED, MessageFormat.format( "Requires the following auths: {0}", requiredAuths)); } } } } }
throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", crq.getUser(), owner));
throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", userid, query.getSettings() .getOwner()));
throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", userid, q.getOwner()));
throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", owner, query.getSettings() .getOwner()));
throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", userid, query.getSettings() .getOwner()));
if (!authorized) { UnauthorizedQueryException qe = new UnauthorizedQueryException(DatawaveErrorCode.JOB_EXECUTION_UNAUTHORIZED, MessageFormat.format( "Requires one of: {0}", service.getAuthorizedRoles())); response.addException(qe);
throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", userid, query.getSettings() .getOwner()));
response.addMessage("CachedResults load canceled."); } else { UnauthorizedQueryException e = new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", query.getSettings().getOwner(), owner)); throw new UnauthorizedException(e, response);
throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", crq.getUser(), owner));
throw new PreConditionFailedQueryException(DatawaveErrorCode.QUERY_NOT_CACHED); if (!crq.getUser().equals(owner)) { throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", crq.getUser(), owner));
UnauthorizedQueryException e = new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", crq.getUser(), owner)); response.addException(e);
throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", loadCrq.getUser(), owner));
throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", userid, query.getSettings() .getOwner()));
throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", crq.getUser(), owner));
throw new PreConditionFailedQueryException(DatawaveErrorCode.QUERY_NOT_CACHED); if (!crq.getUser().equals(owner)) { throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", crq.getUser(), owner));
throw new PreConditionFailedQueryException(DatawaveErrorCode.QUERY_NOT_CACHED); if (!crq.getUser().equals(owner)) { throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", crq.getUser(), owner));
throw new UnauthorizedQueryException(DatawaveErrorCode.QUERY_OWNER_MISMATCH, MessageFormat.format("{0} != {1}", crq.getUser(), owner));