@Test public void test26getServices() throws Exception { List<RangerService> ret = new ArrayList<RangerService>(); SearchFilter filter = new SearchFilter(); filter.setParam(SearchFilter.POLICY_NAME, "policyName"); filter.setParam(SearchFilter.SERVICE_NAME, "serviceName"); Mockito.when(svcStore.getServices(filter)).thenReturn(ret); List<RangerService> dbRangerService = serviceREST.getServices(filter); Assert.assertNotNull(dbRangerService); Mockito.verify(svcStore).getServices(filter); }
@GET @Path("/services") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICES + "\")") public RangerServiceList getServices(@Context HttpServletRequest request) { if (LOG.isDebugEnabled()) { LOG.debug("==> ServiceREST.getServices()"); } RangerServiceList ret = null; RangerPerfTracer perf = null; PList<RangerService> paginatedSvcs = null; SearchFilter filter = searchUtil.getSearchFilter(request, svcService.sortFields); try { if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServices()"); } paginatedSvcs = svcStore.getPaginatedServices(filter); if(paginatedSvcs!= null && !paginatedSvcs.getList().isEmpty()){ UserSessionBase userSession = ContextUtil .getCurrentUserSession(); if (userSession != null && userSession.getLoginId() != null) { VXUser loggedInVXUser = xUserService .getXUserByUserName(userSession.getLoginId()); if (loggedInVXUser != null) { if (loggedInVXUser.getUserRoleList().size() == 1 && loggedInVXUser.getUserRoleList().contains( RangerConstants.ROLE_USER)) { List<RangerService> updateServiceList = new ArrayList<RangerService>(); for(RangerService rangerService : paginatedSvcs.getList()){ if(rangerService != null){ updateServiceList.add(hideCriticalServiceDetailsForRoleUser(rangerService)); } } if(updateServiceList != null && !updateServiceList.isEmpty()){ paginatedSvcs.setList(updateServiceList); } } } } } if(paginatedSvcs != null) { ret = new RangerServiceList(); ret.setServices(paginatedSvcs.getList()); ret.setPageSize(paginatedSvcs.getPageSize()); ret.setResultSize(paginatedSvcs.getResultSize()); ret.setStartIndex(paginatedSvcs.getStartIndex()); ret.setTotalCount(paginatedSvcs.getTotalCount()); ret.setSortBy(paginatedSvcs.getSortBy()); ret.setSortType(paginatedSvcs.getSortType()); } } catch(WebApplicationException excp) { throw excp; } catch (Throwable excp) { LOG.error("getServices() failed", excp); throw restErrorUtil.createRESTException(excp.getMessage()); } finally { RangerPerfTracer.log(perf); } if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceREST.getServices(): count=" + (ret == null ? 0 : ret.getListSize())); } return ret; }
ServiceREST { @GET @Path("/services") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICES + "\")") public RangerServiceList getServices(@Context HttpServletRequest request) { if (LOG.isDebugEnabled()) { LOG.debug("==> ServiceREST.getServices()"); } RangerServiceList ret = null; RangerPerfTracer perf = null; PList<RangerService> paginatedSvcs = null; SearchFilter filter = searchUtil.getSearchFilter(request, svcService.sortFields); try { if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServices()"); } paginatedSvcs = svcStore.getPaginatedServices(filter); if(paginatedSvcs!= null && !paginatedSvcs.getList().isEmpty()){ UserSessionBase userSession = ContextUtil .getCurrentUserSession(); if (userSession != null && userSession.getLoginId() != null) { VXUser loggedInVXUser = xUserService .getXUserByUserName(userSession.getLoginId()); if (loggedInVXUser != null) { if (loggedInVXUser.getUserRoleList().size() == 1 && loggedInVXUser.getUserRoleList().contains( RangerConstants.ROLE_USER)) { List<RangerService> updateServiceList = new ArrayList<RangerService>(); for(RangerService rangerService : paginatedSvcs.getList()){ if(rangerService != null){ updateServiceList.add(hideCriticalServiceDetailsForRoleUser(rangerService)); } } if(updateServiceList != null && !updateServiceList.isEmpty()){ paginatedSvcs.setList(updateServiceList); } } } } } if(paginatedSvcs != null) { ret = new RangerServiceList(); ret.setServices(paginatedSvcs.getList()); ret.setPageSize(paginatedSvcs.getPageSize()); ret.setResultSize(paginatedSvcs.getResultSize()); ret.setStartIndex(paginatedSvcs.getStartIndex()); ret.setTotalCount(paginatedSvcs.getTotalCount()); ret.setSortBy(paginatedSvcs.getSortBy()); ret.setSortType(paginatedSvcs.getSortType()); } } catch(WebApplicationException excp) { throw excp; } catch (Throwable excp) { LOG.error("getServices() failed", excp); throw restErrorUtil.createRESTException(excp.getMessage()); } finally { RangerPerfTracer.log(perf); } if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceREST.getServices(): count=" + (ret == null ? 0 : ret.getListSize())); } return ret; } }
ServiceREST { @GET @Path("/services") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICES + "\")") public RangerServiceList getServices(@Context HttpServletRequest request) { if (LOG.isDebugEnabled()) { LOG.debug("==> ServiceREST.getServices()"); } RangerServiceList ret = null; RangerPerfTracer perf = null; PList<RangerService> paginatedSvcs = null; SearchFilter filter = searchUtil.getSearchFilter(request, svcService.sortFields); try { if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServices()"); } paginatedSvcs = svcStore.getPaginatedServices(filter); if(paginatedSvcs!= null && !paginatedSvcs.getList().isEmpty()){ UserSessionBase userSession = ContextUtil .getCurrentUserSession(); if (userSession != null && userSession.getLoginId() != null) { VXUser loggedInVXUser = xUserService .getXUserByUserName(userSession.getLoginId()); if (loggedInVXUser != null) { if (loggedInVXUser.getUserRoleList().size() == 1 && loggedInVXUser.getUserRoleList().contains( RangerConstants.ROLE_USER)) { List<RangerService> updateServiceList = new ArrayList<RangerService>(); for(RangerService rangerService : paginatedSvcs.getList()){ if(rangerService != null){ updateServiceList.add(hideCriticalServiceDetailsForRoleUser(rangerService)); } } if(updateServiceList != null && !updateServiceList.isEmpty()){ paginatedSvcs.setList(updateServiceList); } } } } } if(paginatedSvcs != null) { ret = new RangerServiceList(); ret.setServices(paginatedSvcs.getList()); ret.setPageSize(paginatedSvcs.getPageSize()); ret.setResultSize(paginatedSvcs.getResultSize()); ret.setStartIndex(paginatedSvcs.getStartIndex()); ret.setTotalCount(paginatedSvcs.getTotalCount()); ret.setSortBy(paginatedSvcs.getSortBy()); ret.setSortType(paginatedSvcs.getSortType()); } } catch(WebApplicationException excp) { throw excp; } catch (Throwable excp) { LOG.error("getServices() failed", excp); throw restErrorUtil.createRESTException(excp.getMessage()); } finally { RangerPerfTracer.log(perf); } if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceREST.getServices(): count=" + (ret == null ? 0 : ret.getListSize())); } return ret; } ServiceREST(); }
ServiceREST { @GET @Path("/services") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICES + "\")") public RangerServiceList getServices(@Context HttpServletRequest request) { if (LOG.isDebugEnabled()) { LOG.debug("==> ServiceREST.getServices()"); } RangerServiceList ret = null; RangerPerfTracer perf = null; PList<RangerService> paginatedSvcs = null; SearchFilter filter = searchUtil.getSearchFilter(request, svcService.sortFields); try { if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServices()"); } paginatedSvcs = svcStore.getPaginatedServices(filter); if(paginatedSvcs!= null && !paginatedSvcs.getList().isEmpty()){ UserSessionBase userSession = ContextUtil .getCurrentUserSession(); if (userSession != null && userSession.getLoginId() != null) { VXUser loggedInVXUser = xUserService .getXUserByUserName(userSession.getLoginId()); if (loggedInVXUser != null) { if (loggedInVXUser.getUserRoleList().size() == 1 && loggedInVXUser.getUserRoleList().contains( RangerConstants.ROLE_USER)) { List<RangerService> updateServiceList = new ArrayList<RangerService>(); for(RangerService rangerService : paginatedSvcs.getList()){ if(rangerService != null){ updateServiceList.add(hideCriticalServiceDetailsForRoleUser(rangerService)); } } if(updateServiceList != null && !updateServiceList.isEmpty()){ paginatedSvcs.setList(updateServiceList); } } } } } if(paginatedSvcs != null) { ret = new RangerServiceList(); ret.setServices(paginatedSvcs.getList()); ret.setPageSize(paginatedSvcs.getPageSize()); ret.setResultSize(paginatedSvcs.getResultSize()); ret.setStartIndex(paginatedSvcs.getStartIndex()); ret.setTotalCount(paginatedSvcs.getTotalCount()); ret.setSortBy(paginatedSvcs.getSortBy()); ret.setSortType(paginatedSvcs.getSortType()); } } catch(WebApplicationException excp) { throw excp; } catch (Throwable excp) { LOG.error("getServices() failed", excp); throw restErrorUtil.createRESTException(excp.getMessage()); } finally { RangerPerfTracer.log(perf); } if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceREST.getServices(): count=" + (ret == null ? 0 : ret.getListSize())); } return ret; } ServiceREST(); @PostConstruct void initStore(); @POST @Path("/definitions") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_SERVICE_DEF + "\")") RangerServiceDef createServiceDef(RangerServiceDef serviceDef); @PUT @Path("/definitions/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.UPDATE_SERVICE_DEF + "\")") RangerServiceDef updateServiceDef(RangerServiceDef serviceDef); @DELETE @Path("/definitions/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DELETE_SERVICE_DEF + "\")") void deleteServiceDef(@PathParam("id") Long id, @Context HttpServletRequest request); @GET @Path("/definitions/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_DEF + "\")") RangerServiceDef getServiceDef(@PathParam("id") Long id); @GET @Path("/definitions/name/{name}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_DEF_BY_NAME + "\")") RangerServiceDef getServiceDefByName(@PathParam("name") String name); @GET @Path("/definitions") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_DEFS + "\")") RangerServiceDefList getServiceDefs(@Context HttpServletRequest request); @GET @Path("/policies/{serviceDefName}/for-resource") @Produces({ "application/json", "application/xml" }) List<RangerPolicy> getPoliciesForResource(@PathParam("serviceDefName") String serviceDefName,
												  @DefaultValue("") @QueryParam("serviceName") String serviceName,
												  @Context HttpServletRequest request); @POST @Path("/services") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_SERVICE + "\")") RangerService createService(RangerService service); @PUT @Path("/services/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.UPDATE_SERVICE + "\")") RangerService updateService(RangerService service,
                                       @Context HttpServletRequest request); @DELETE @Path("/services/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DELETE_SERVICE + "\")") void deleteService(@PathParam("id") Long id); @GET @Path("/services/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE + "\")") RangerService getService(@PathParam("id") Long id); @GET @Path("/services/name/{name}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_BY_NAME + "\")") RangerService getServiceByName(@PathParam("name") String name); @GET @Path("/services") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICES + "\")") RangerServiceList getServices(@Context HttpServletRequest request); List<RangerService> getServices(SearchFilter filter); @GET @Path("/services/count") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.COUNT_SERVICES + "\")") Long countServices(@Context HttpServletRequest request); @POST @Path("/services/validateConfig") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.VALIDATE_CONFIG + "\")") VXResponse validateConfig(RangerService service); @POST @Path("/services/lookupResource/{serviceName}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.LOOKUP_RESOURCE + "\")") List<String> lookupResource(@PathParam("serviceName") String serviceName, ResourceLookupContext context); @POST @Path("/services/grant/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse grantAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest grantRequest, @Context HttpServletRequest request); @POST @Path("/secure/services/grant/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse secureGrantAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest grantRequest, @Context HttpServletRequest request); @POST @Path("/services/revoke/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse revokeAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest revokeRequest, @Context HttpServletRequest request); @POST @Path("/secure/services/revoke/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse secureRevokeAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest revokeRequest, @Context HttpServletRequest request); @POST @Path("/policies") @Produces({ "application/json", "application/xml" }) RangerPolicy createPolicy(RangerPolicy policy, @Context HttpServletRequest request); @POST @Path("/policies/apply") @Produces({ "application/json", "application/xml" }) RangerPolicy applyPolicy(RangerPolicy policy, @Context HttpServletRequest request); @PUT @Path("/policies/{id}") @Produces({ "application/json", "application/xml" }) RangerPolicy updatePolicy(RangerPolicy policy); @DELETE @Path("/policies/{id}") @Produces({ "application/json", "application/xml" }) void deletePolicy(@PathParam("id") Long id); @GET @Path("/policies/{id}") @Produces({ "application/json", "application/xml" }) RangerPolicy getPolicy(@PathParam("id") Long id); @GET @Path("/policyLabels") @Produces({ "application/json", "application/xml" }) List<String> getPolicyLabels(@Context HttpServletRequest request); @GET @Path("/policies") @Produces({ "application/json", "application/xml" }) RangerPolicyList getPolicies(@Context HttpServletRequest request); @GET @Path("/policies/downloadExcel") @Produces("application/ms-excel") void getPoliciesInExcel(@Context HttpServletRequest request,
			@Context HttpServletResponse response); @GET @Path("/policies/csv") @Produces("text/csv") void getPoliciesInCsv(@Context HttpServletRequest request, @Context HttpServletResponse response); @GET @Path("/policies/exportJson") @Produces("text/json") void getPoliciesInJson(@Context HttpServletRequest request,
			@Context HttpServletResponse response,
			@QueryParam("checkPoliciesExists") Boolean checkPoliciesExists); @POST @Path("/policies/importPoliciesFromFile") @Consumes({MediaType.MULTIPART_FORM_DATA, MediaType.APPLICATION_JSON}) @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAdminOrKeyAdminRole()") void importPoliciesFromFile(
			@Context HttpServletRequest request,
			@FormDataParam("servicesMapJson") InputStream serviceMapStream,
			@FormDataParam("zoneMapJson") InputStream zoneMapStream,
			@FormDataParam("file") InputStream uploadedInputStream,
			@FormDataParam("file") FormDataContentDisposition fileDetail,
			@QueryParam("isOverride") Boolean isOverride,
			@QueryParam("importType") String importType); List<RangerPolicy> getPolicies(SearchFilter filter); @GET @Path("/policies/count") @Produces({ "application/json", "application/xml" }) Long countPolicies( @Context HttpServletRequest request); @GET @Path("/policies/service/{id}") @Produces({ "application/json", "application/xml" }) RangerPolicyList getServicePolicies(@PathParam("id") Long serviceId,
			@Context HttpServletRequest request); @GET @Path("/policies/service/name/{name}") @Produces({ "application/json", "application/xml" }) RangerPolicyList getServicePoliciesByName(@PathParam("name") String serviceName,
			@Context HttpServletRequest request); @GET @Path("/policies/download/{serviceName}") @Produces({ "application/json", "application/xml" }) ServicePolicies getServicePoliciesIfUpdated(
			@PathParam("serviceName") String serviceName,
			@QueryParam("lastKnownVersion") Long lastKnownVersion,
			@DefaultValue("0") @QueryParam("lastActivationTime") Long lastActivationTime,
			@QueryParam("pluginId") String pluginId,
			@DefaultValue("") @QueryParam("clusterName") String clusterName,
			@DefaultValue("") @QueryParam("zoneName") String zoneName,
			@DefaultValue("false") @QueryParam("supportsPolicyDeltas") Boolean supportsPolicyDeltas,
			@DefaultValue("") @QueryParam("pluginCapabilities") String pluginCapabilities,
			@Context HttpServletRequest request); @GET @Path("/secure/policies/download/{serviceName}") @Produces({ "application/json", "application/xml" }) ServicePolicies getSecureServicePoliciesIfUpdated(
			@PathParam("serviceName") String serviceName,
			@QueryParam("lastKnownVersion") Long lastKnownVersion,
			@DefaultValue("0") @QueryParam("lastActivationTime") Long lastActivationTime,
			@QueryParam("pluginId") String pluginId,
			@DefaultValue("") @QueryParam("clusterName") String clusterName,
			@DefaultValue("") @QueryParam("zoneName") String zoneName,
			@DefaultValue("false") @QueryParam("supportsPolicyDeltas") Boolean supportsPolicyDeltas,
			@DefaultValue("") @QueryParam("pluginCapabilities") String pluginCapabilities,
			@Context HttpServletRequest request); @DELETE @Path("/server/policydeltas") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") void deletePolicyDeltas(@DefaultValue("7") @QueryParam("days") Integer olderThan, @Context HttpServletRequest request); @DELETE @Path("/server/purgepolicies/{serviceName}") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") void purgeEmptyPolicies(@PathParam("serviceName") String serviceName, @Context HttpServletRequest request); @GET @Path("/policies/eventTime") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_POLICY_FROM_EVENT_TIME + "\")") RangerPolicy getPolicyFromEventTime(@Context HttpServletRequest request); @GET @Path("/policy/{policyId}/versionList") @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_POLICY_VERSION_LIST + "\")") VXString getPolicyVersionList(@PathParam("policyId") Long policyId); @GET @Path("/policy/{policyId}/version/{versionNo}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_POLICY_FOR_VERSION_NO + "\")") RangerPolicy getPolicyForVersionNumber(@PathParam("policyId") Long policyId,
			@PathParam("versionNo") int versionNo); @GET @Path("/plugins/info") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_PLUGINS_INFO + "\")") RangerPluginInfoList getPluginsInfo(@Context HttpServletRequest request); RangerPolicyAdmin getPolicyAdminForDelegatedAdmin(String serviceName); @GET @Path("/checksso") @Produces(MediaType.TEXT_PLAIN) String checkSSO(); @GET @Path("/csrfconf") @Produces({ "application/json"}) HashMap<String, Object> getCSRFProperties(); @GET @Path("/metrics/type/{type}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\""+ RangerAPIList.GET_METRICS_BY_TYPE + "\")") String getMetricByType(@PathParam("type") String type); }
ServiceREST { @GET @Path("/services") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICES + "\")") public RangerServiceList getServices(@Context HttpServletRequest request) { if (LOG.isDebugEnabled()) { LOG.debug("==> ServiceREST.getServices()"); } RangerServiceList ret = null; RangerPerfTracer perf = null; PList<RangerService> paginatedSvcs = null; SearchFilter filter = searchUtil.getSearchFilter(request, svcService.sortFields); try { if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServices()"); } paginatedSvcs = svcStore.getPaginatedServices(filter); if(paginatedSvcs!= null && !paginatedSvcs.getList().isEmpty()){ UserSessionBase userSession = ContextUtil .getCurrentUserSession(); if (userSession != null && userSession.getLoginId() != null) { VXUser loggedInVXUser = xUserService .getXUserByUserName(userSession.getLoginId()); if (loggedInVXUser != null) { if (loggedInVXUser.getUserRoleList().size() == 1 && loggedInVXUser.getUserRoleList().contains( RangerConstants.ROLE_USER)) { List<RangerService> updateServiceList = new ArrayList<RangerService>(); for(RangerService rangerService : paginatedSvcs.getList()){ if(rangerService != null){ updateServiceList.add(hideCriticalServiceDetailsForRoleUser(rangerService)); } } if(updateServiceList != null && !updateServiceList.isEmpty()){ paginatedSvcs.setList(updateServiceList); } } } } } if(paginatedSvcs != null) { ret = new RangerServiceList(); ret.setServices(paginatedSvcs.getList()); ret.setPageSize(paginatedSvcs.getPageSize()); ret.setResultSize(paginatedSvcs.getResultSize()); ret.setStartIndex(paginatedSvcs.getStartIndex()); ret.setTotalCount(paginatedSvcs.getTotalCount()); ret.setSortBy(paginatedSvcs.getSortBy()); ret.setSortType(paginatedSvcs.getSortType()); } } catch(WebApplicationException excp) { throw excp; } catch (Throwable excp) { LOG.error("getServices() failed", excp); throw restErrorUtil.createRESTException(excp.getMessage()); } finally { RangerPerfTracer.log(perf); } if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceREST.getServices(): count=" + (ret == null ? 0 : ret.getListSize())); } return ret; } ServiceREST(); @PostConstruct void initStore(); @POST @Path("/definitions") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_SERVICE_DEF + "\")") RangerServiceDef createServiceDef(RangerServiceDef serviceDef); @PUT @Path("/definitions/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.UPDATE_SERVICE_DEF + "\")") RangerServiceDef updateServiceDef(RangerServiceDef serviceDef); @DELETE @Path("/definitions/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DELETE_SERVICE_DEF + "\")") void deleteServiceDef(@PathParam("id") Long id, @Context HttpServletRequest request); @GET @Path("/definitions/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_DEF + "\")") RangerServiceDef getServiceDef(@PathParam("id") Long id); @GET @Path("/definitions/name/{name}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_DEF_BY_NAME + "\")") RangerServiceDef getServiceDefByName(@PathParam("name") String name); @GET @Path("/definitions") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_DEFS + "\")") RangerServiceDefList getServiceDefs(@Context HttpServletRequest request); @GET @Path("/policies/{serviceDefName}/for-resource") @Produces({ "application/json", "application/xml" }) List<RangerPolicy> getPoliciesForResource(@PathParam("serviceDefName") String serviceDefName,
												  @DefaultValue("") @QueryParam("serviceName") String serviceName,
												  @Context HttpServletRequest request); @POST @Path("/services") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_SERVICE + "\")") RangerService createService(RangerService service); @PUT @Path("/services/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.UPDATE_SERVICE + "\")") RangerService updateService(RangerService service,
                                       @Context HttpServletRequest request); @DELETE @Path("/services/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DELETE_SERVICE + "\")") void deleteService(@PathParam("id") Long id); @GET @Path("/services/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE + "\")") RangerService getService(@PathParam("id") Long id); @GET @Path("/services/name/{name}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_BY_NAME + "\")") RangerService getServiceByName(@PathParam("name") String name); @GET @Path("/services") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICES + "\")") RangerServiceList getServices(@Context HttpServletRequest request); List<RangerService> getServices(SearchFilter filter); @GET @Path("/services/count") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.COUNT_SERVICES + "\")") Long countServices(@Context HttpServletRequest request); @POST @Path("/services/validateConfig") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.VALIDATE_CONFIG + "\")") VXResponse validateConfig(RangerService service); @POST @Path("/services/lookupResource/{serviceName}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.LOOKUP_RESOURCE + "\")") List<String> lookupResource(@PathParam("serviceName") String serviceName, ResourceLookupContext context); @POST @Path("/services/grant/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse grantAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest grantRequest, @Context HttpServletRequest request); @POST @Path("/secure/services/grant/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse secureGrantAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest grantRequest, @Context HttpServletRequest request); @POST @Path("/services/revoke/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse revokeAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest revokeRequest, @Context HttpServletRequest request); @POST @Path("/secure/services/revoke/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse secureRevokeAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest revokeRequest, @Context HttpServletRequest request); @POST @Path("/policies") @Produces({ "application/json", "application/xml" }) RangerPolicy createPolicy(RangerPolicy policy, @Context HttpServletRequest request); @POST @Path("/policies/apply") @Produces({ "application/json", "application/xml" }) RangerPolicy applyPolicy(RangerPolicy policy, @Context HttpServletRequest request); @PUT @Path("/policies/{id}") @Produces({ "application/json", "application/xml" }) RangerPolicy updatePolicy(RangerPolicy policy); @DELETE @Path("/policies/{id}") @Produces({ "application/json", "application/xml" }) void deletePolicy(@PathParam("id") Long id); @GET @Path("/policies/{id}") @Produces({ "application/json", "application/xml" }) RangerPolicy getPolicy(@PathParam("id") Long id); @GET @Path("/policyLabels") @Produces({ "application/json", "application/xml" }) List<String> getPolicyLabels(@Context HttpServletRequest request); @GET @Path("/policies") @Produces({ "application/json", "application/xml" }) RangerPolicyList getPolicies(@Context HttpServletRequest request); @GET @Path("/policies/downloadExcel") @Produces("application/ms-excel") void getPoliciesInExcel(@Context HttpServletRequest request,
			@Context HttpServletResponse response); @GET @Path("/policies/csv") @Produces("text/csv") void getPoliciesInCsv(@Context HttpServletRequest request, @Context HttpServletResponse response); @GET @Path("/policies/exportJson") @Produces("text/json") void getPoliciesInJson(@Context HttpServletRequest request,
			@Context HttpServletResponse response,
			@QueryParam("checkPoliciesExists") Boolean checkPoliciesExists); @POST @Path("/policies/importPoliciesFromFile") @Consumes({MediaType.MULTIPART_FORM_DATA, MediaType.APPLICATION_JSON}) @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAdminOrKeyAdminRole()") void importPoliciesFromFile(
			@Context HttpServletRequest request,
			@FormDataParam("servicesMapJson") InputStream serviceMapStream,
			@FormDataParam("zoneMapJson") InputStream zoneMapStream,
			@FormDataParam("file") InputStream uploadedInputStream,
			@FormDataParam("file") FormDataContentDisposition fileDetail,
			@QueryParam("isOverride") Boolean isOverride,
			@QueryParam("importType") String importType); List<RangerPolicy> getPolicies(SearchFilter filter); @GET @Path("/policies/count") @Produces({ "application/json", "application/xml" }) Long countPolicies( @Context HttpServletRequest request); @GET @Path("/policies/service/{id}") @Produces({ "application/json", "application/xml" }) RangerPolicyList getServicePolicies(@PathParam("id") Long serviceId,
			@Context HttpServletRequest request); @GET @Path("/policies/service/name/{name}") @Produces({ "application/json", "application/xml" }) RangerPolicyList getServicePoliciesByName(@PathParam("name") String serviceName,
			@Context HttpServletRequest request); @GET @Path("/policies/download/{serviceName}") @Produces({ "application/json", "application/xml" }) ServicePolicies getServicePoliciesIfUpdated(
			@PathParam("serviceName") String serviceName,
			@QueryParam("lastKnownVersion") Long lastKnownVersion,
			@DefaultValue("0") @QueryParam("lastActivationTime") Long lastActivationTime,
			@QueryParam("pluginId") String pluginId,
			@DefaultValue("") @QueryParam("clusterName") String clusterName,
			@DefaultValue("") @QueryParam("zoneName") String zoneName,
			@DefaultValue("false") @QueryParam("supportsPolicyDeltas") Boolean supportsPolicyDeltas,
			@DefaultValue("") @QueryParam("pluginCapabilities") String pluginCapabilities,
			@Context HttpServletRequest request); @GET @Path("/secure/policies/download/{serviceName}") @Produces({ "application/json", "application/xml" }) ServicePolicies getSecureServicePoliciesIfUpdated(
			@PathParam("serviceName") String serviceName,
			@QueryParam("lastKnownVersion") Long lastKnownVersion,
			@DefaultValue("0") @QueryParam("lastActivationTime") Long lastActivationTime,
			@QueryParam("pluginId") String pluginId,
			@DefaultValue("") @QueryParam("clusterName") String clusterName,
			@DefaultValue("") @QueryParam("zoneName") String zoneName,
			@DefaultValue("false") @QueryParam("supportsPolicyDeltas") Boolean supportsPolicyDeltas,
			@DefaultValue("") @QueryParam("pluginCapabilities") String pluginCapabilities,
			@Context HttpServletRequest request); @DELETE @Path("/server/policydeltas") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") void deletePolicyDeltas(@DefaultValue("7") @QueryParam("days") Integer olderThan, @Context HttpServletRequest request); @DELETE @Path("/server/purgepolicies/{serviceName}") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") void purgeEmptyPolicies(@PathParam("serviceName") String serviceName, @Context HttpServletRequest request); @GET @Path("/policies/eventTime") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_POLICY_FROM_EVENT_TIME + "\")") RangerPolicy getPolicyFromEventTime(@Context HttpServletRequest request); @GET @Path("/policy/{policyId}/versionList") @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_POLICY_VERSION_LIST + "\")") VXString getPolicyVersionList(@PathParam("policyId") Long policyId); @GET @Path("/policy/{policyId}/version/{versionNo}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_POLICY_FOR_VERSION_NO + "\")") RangerPolicy getPolicyForVersionNumber(@PathParam("policyId") Long policyId,
			@PathParam("versionNo") int versionNo); @GET @Path("/plugins/info") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_PLUGINS_INFO + "\")") RangerPluginInfoList getPluginsInfo(@Context HttpServletRequest request); RangerPolicyAdmin getPolicyAdminForDelegatedAdmin(String serviceName); @GET @Path("/checksso") @Produces(MediaType.TEXT_PLAIN) String checkSSO(); @GET @Path("/csrfconf") @Produces({ "application/json"}) HashMap<String, Object> getCSRFProperties(); @GET @Path("/metrics/type/{type}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\""+ RangerAPIList.GET_METRICS_BY_TYPE + "\")") String getMetricByType(@PathParam("type") String type); final static public String PARAM_SERVICE_NAME; final static public String PARAM_SERVICE_TYPE; final static public String PARAM_POLICY_NAME; final static public String PARAM_ZONE_NAME; final static public String PARAM_UPDATE_IF_EXISTS; final static public String PARAM_MERGE_IF_EXISTS; final static public String PARAM_DELETE_IF_EXISTS; final static public String PARAM_IMPORT_IN_PROGRESS; static final String Allowed_User_List_For_Download; static final String Allowed_User_List_For_Grant_Revoke; static final String isCSRF_ENABLED; static final String BROWSER_USER_AGENT_PARAM; static final String CUSTOM_METHODS_TO_IGNORE_PARAM; static final String CUSTOM_HEADER_PARAM; }