@Test public void test58getSecureServicePoliciesIfUpdatedAllowedFail() throws Exception { HttpServletRequest request = Mockito.mock(HttpServletRequest.class); Long lastKnownVersion = 1L; String pluginId = "1"; XXService xService = xService(); XXServiceDef xServiceDef = serviceDef(); xServiceDef.setImplclassname("org.apache.ranger.services.kms.RangerServiceKMS"); String serviceName = xService.getName(); RangerService rs = rangerService(); XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class); Mockito.when(serviceUtil.isValidService(serviceName, request)).thenReturn(true); Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao); Mockito.when(xServiceDao.findByName(serviceName)).thenReturn(xService); Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao); Mockito.when(xServiceDefDao.getById(xService.getType())).thenReturn(xServiceDef); Mockito.when(svcStore.getServiceByNameForDP(serviceName)).thenReturn(rs); Mockito.when(bizUtil.isUserAllowed(rs, ServiceREST.Allowed_User_List_For_Grant_Revoke)).thenReturn(true); Mockito.when(restErrorUtil.createRESTException(Mockito.anyInt(), Mockito.anyString(), Mockito.anyBoolean())) .thenThrow(new WebApplicationException()); thrown.expect(WebApplicationException.class); serviceREST.getSecureServicePoliciesIfUpdated(serviceName, lastKnownVersion, 0L, pluginId, "", "", false, capabilityVector, request); }
@GET @Path("/secure/policies/download/{serviceName}") @Produces({ "application/json", "application/xml" }) public 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) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("==> ServiceREST.getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ", " + pluginId + ", " + clusterName + ", " + supportsPolicyDeltas + ")"); } ServicePolicies ret = null; int httpCode = HttpServletResponse.SC_OK; String logMsg = null; RangerPerfTracer perf = null; boolean isAllowed = false; boolean isAdmin = bizUtil.isAdmin(); boolean isKeyAdmin = bizUtil.isKeyAdmin(); request.setAttribute("downloadPolicy", "secure"); Long downloadedVersion = null; boolean isValid = false; try { isValid = serviceUtil.isValidService(serviceName, request); } catch (WebApplicationException webException) { httpCode = webException.getResponse().getStatus(); logMsg = webException.getResponse().getEntity().toString(); } catch (Exception e) { httpCode = HttpServletResponse.SC_BAD_REQUEST; logMsg = e.getMessage(); } if (isValid) { if (lastKnownVersion == null) { lastKnownVersion = Long.valueOf(-1); } try { if (RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getSecureServicePoliciesIfUpdated(serviceName=" + serviceName + ",lastKnownVersion=" + lastKnownVersion + ",lastActivationTime=" + lastActivationTime + ")"); } XXService xService = daoManager.getXXService().findByName(serviceName); XXServiceDef xServiceDef = daoManager.getXXServiceDef().getById(xService.getType()); RangerService rangerService = null; if (StringUtils.equals(xServiceDef.getImplclassname(), EmbeddedServiceDefsUtil.KMS_IMPL_CLASS_NAME)) { rangerService = svcStore.getServiceByNameForDP(serviceName); if (isKeyAdmin) { isAllowed = true; } else { if (rangerService != null) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Download); if (!isAllowed) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Grant_Revoke); } } } } else { rangerService = svcStore.getServiceByName(serviceName); if (isAdmin) { isAllowed = true; } else { if (rangerService != null) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Download); if (!isAllowed) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Grant_Revoke); } } } } if (isAllowed) { ServicePolicies servicePolicies = svcStore.getServicePoliciesIfUpdated(serviceName, lastKnownVersion, !supportsPolicyDeltas); if (servicePolicies == null) { downloadedVersion = lastKnownVersion; httpCode = HttpServletResponse.SC_NOT_MODIFIED; logMsg = "No change since last update"; } else { Map<String, RangerSecurityZone.RangerSecurityZoneService> securityZones = zoneStore.getSecurityZonesForService(serviceName); ServicePolicies updatedServicePolicies = servicePolicies; if (MapUtils.isNotEmpty(securityZones)) { updatedServicePolicies = RangerPolicyAdminCache.getUpdatedServicePoliciesForZones(servicePolicies, securityZones); patchAssociatedTagServiceInSecurityZoneInfos(updatedServicePolicies); } downloadedVersion = updatedServicePolicies.getPolicyVersion(); if (lastKnownVersion == -1L || !supportsPolicyDeltas) { ret = filterServicePolicies(updatedServicePolicies); } else { ret = updatedServicePolicies; } ret.setServiceConfig(svcStore.getServiceConfigForPlugin(ret.getServiceId())); httpCode = HttpServletResponse.SC_OK; logMsg = "Returning " + (ret.getPolicies() != null ? ret.getPolicies().size() : (ret.getPolicyDeltas() != null ? ret.getPolicyDeltas().size() : 0)) + " policies. Policy version=" + ret.getPolicyVersion(); } } else { LOG.error("getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ") failed as User doesn't have permission to download Policy"); httpCode = HttpServletResponse.SC_UNAUTHORIZED; logMsg = "User doesn't have permission to download policy"; } } catch (Throwable excp) { LOG.error("getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ") failed", excp); httpCode = HttpServletResponse.SC_BAD_REQUEST; logMsg = excp.getMessage(); } finally { createPolicyDownloadAudit(serviceName, lastKnownVersion, pluginId, httpCode, clusterName, zoneName, request); RangerPerfTracer.log(perf); } } assetMgr.createPluginInfo(serviceName, pluginId, request, RangerPluginInfo.ENTITY_TYPE_POLICIES, downloadedVersion, lastKnownVersion, lastActivationTime, httpCode, clusterName, pluginCapabilities); if (httpCode != HttpServletResponse.SC_OK) { boolean logError = httpCode != HttpServletResponse.SC_NOT_MODIFIED; throw restErrorUtil.createRESTException(httpCode, logMsg, logError); } if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceREST.getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ", " + pluginId + ", " + clusterName + ", " + supportsPolicyDeltas + "): count=" + ((ret == null || ret.getPolicies() == null) ? 0 : ret.getPolicies().size())); } return ret; }
ServiceREST { @GET @Path("/secure/policies/download/{serviceName}") @Produces({ "application/json", "application/xml" }) public 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) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("==> ServiceREST.getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ", " + pluginId + ", " + clusterName + ", " + supportsPolicyDeltas + ")"); } ServicePolicies ret = null; int httpCode = HttpServletResponse.SC_OK; String logMsg = null; RangerPerfTracer perf = null; boolean isAllowed = false; boolean isAdmin = bizUtil.isAdmin(); boolean isKeyAdmin = bizUtil.isKeyAdmin(); request.setAttribute("downloadPolicy", "secure"); Long downloadedVersion = null; boolean isValid = false; try { isValid = serviceUtil.isValidService(serviceName, request); } catch (WebApplicationException webException) { httpCode = webException.getResponse().getStatus(); logMsg = webException.getResponse().getEntity().toString(); } catch (Exception e) { httpCode = HttpServletResponse.SC_BAD_REQUEST; logMsg = e.getMessage(); } if (isValid) { if (lastKnownVersion == null) { lastKnownVersion = Long.valueOf(-1); } try { if (RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getSecureServicePoliciesIfUpdated(serviceName=" + serviceName + ",lastKnownVersion=" + lastKnownVersion + ",lastActivationTime=" + lastActivationTime + ")"); } XXService xService = daoManager.getXXService().findByName(serviceName); XXServiceDef xServiceDef = daoManager.getXXServiceDef().getById(xService.getType()); RangerService rangerService = null; if (StringUtils.equals(xServiceDef.getImplclassname(), EmbeddedServiceDefsUtil.KMS_IMPL_CLASS_NAME)) { rangerService = svcStore.getServiceByNameForDP(serviceName); if (isKeyAdmin) { isAllowed = true; } else { if (rangerService != null) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Download); if (!isAllowed) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Grant_Revoke); } } } } else { rangerService = svcStore.getServiceByName(serviceName); if (isAdmin) { isAllowed = true; } else { if (rangerService != null) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Download); if (!isAllowed) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Grant_Revoke); } } } } if (isAllowed) { ServicePolicies servicePolicies = svcStore.getServicePoliciesIfUpdated(serviceName, lastKnownVersion, !supportsPolicyDeltas); if (servicePolicies == null) { downloadedVersion = lastKnownVersion; httpCode = HttpServletResponse.SC_NOT_MODIFIED; logMsg = "No change since last update"; } else { Map<String, RangerSecurityZone.RangerSecurityZoneService> securityZones = zoneStore.getSecurityZonesForService(serviceName); ServicePolicies updatedServicePolicies = servicePolicies; if (MapUtils.isNotEmpty(securityZones)) { updatedServicePolicies = RangerPolicyAdminCache.getUpdatedServicePoliciesForZones(servicePolicies, securityZones); patchAssociatedTagServiceInSecurityZoneInfos(updatedServicePolicies); } downloadedVersion = updatedServicePolicies.getPolicyVersion(); if (lastKnownVersion == -1L || !supportsPolicyDeltas) { ret = filterServicePolicies(updatedServicePolicies); } else { ret = updatedServicePolicies; } ret.setServiceConfig(svcStore.getServiceConfigForPlugin(ret.getServiceId())); httpCode = HttpServletResponse.SC_OK; logMsg = "Returning " + (ret.getPolicies() != null ? ret.getPolicies().size() : (ret.getPolicyDeltas() != null ? ret.getPolicyDeltas().size() : 0)) + " policies. Policy version=" + ret.getPolicyVersion(); } } else { LOG.error("getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ") failed as User doesn't have permission to download Policy"); httpCode = HttpServletResponse.SC_UNAUTHORIZED; logMsg = "User doesn't have permission to download policy"; } } catch (Throwable excp) { LOG.error("getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ") failed", excp); httpCode = HttpServletResponse.SC_BAD_REQUEST; logMsg = excp.getMessage(); } finally { createPolicyDownloadAudit(serviceName, lastKnownVersion, pluginId, httpCode, clusterName, zoneName, request); RangerPerfTracer.log(perf); } } assetMgr.createPluginInfo(serviceName, pluginId, request, RangerPluginInfo.ENTITY_TYPE_POLICIES, downloadedVersion, lastKnownVersion, lastActivationTime, httpCode, clusterName, pluginCapabilities); if (httpCode != HttpServletResponse.SC_OK) { boolean logError = httpCode != HttpServletResponse.SC_NOT_MODIFIED; throw restErrorUtil.createRESTException(httpCode, logMsg, logError); } if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceREST.getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ", " + pluginId + ", " + clusterName + ", " + supportsPolicyDeltas + "): count=" + ((ret == null || ret.getPolicies() == null) ? 0 : ret.getPolicies().size())); } return ret; } }
ServiceREST { @GET @Path("/secure/policies/download/{serviceName}") @Produces({ "application/json", "application/xml" }) public 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) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("==> ServiceREST.getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ", " + pluginId + ", " + clusterName + ", " + supportsPolicyDeltas + ")"); } ServicePolicies ret = null; int httpCode = HttpServletResponse.SC_OK; String logMsg = null; RangerPerfTracer perf = null; boolean isAllowed = false; boolean isAdmin = bizUtil.isAdmin(); boolean isKeyAdmin = bizUtil.isKeyAdmin(); request.setAttribute("downloadPolicy", "secure"); Long downloadedVersion = null; boolean isValid = false; try { isValid = serviceUtil.isValidService(serviceName, request); } catch (WebApplicationException webException) { httpCode = webException.getResponse().getStatus(); logMsg = webException.getResponse().getEntity().toString(); } catch (Exception e) { httpCode = HttpServletResponse.SC_BAD_REQUEST; logMsg = e.getMessage(); } if (isValid) { if (lastKnownVersion == null) { lastKnownVersion = Long.valueOf(-1); } try { if (RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getSecureServicePoliciesIfUpdated(serviceName=" + serviceName + ",lastKnownVersion=" + lastKnownVersion + ",lastActivationTime=" + lastActivationTime + ")"); } XXService xService = daoManager.getXXService().findByName(serviceName); XXServiceDef xServiceDef = daoManager.getXXServiceDef().getById(xService.getType()); RangerService rangerService = null; if (StringUtils.equals(xServiceDef.getImplclassname(), EmbeddedServiceDefsUtil.KMS_IMPL_CLASS_NAME)) { rangerService = svcStore.getServiceByNameForDP(serviceName); if (isKeyAdmin) { isAllowed = true; } else { if (rangerService != null) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Download); if (!isAllowed) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Grant_Revoke); } } } } else { rangerService = svcStore.getServiceByName(serviceName); if (isAdmin) { isAllowed = true; } else { if (rangerService != null) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Download); if (!isAllowed) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Grant_Revoke); } } } } if (isAllowed) { ServicePolicies servicePolicies = svcStore.getServicePoliciesIfUpdated(serviceName, lastKnownVersion, !supportsPolicyDeltas); if (servicePolicies == null) { downloadedVersion = lastKnownVersion; httpCode = HttpServletResponse.SC_NOT_MODIFIED; logMsg = "No change since last update"; } else { Map<String, RangerSecurityZone.RangerSecurityZoneService> securityZones = zoneStore.getSecurityZonesForService(serviceName); ServicePolicies updatedServicePolicies = servicePolicies; if (MapUtils.isNotEmpty(securityZones)) { updatedServicePolicies = RangerPolicyAdminCache.getUpdatedServicePoliciesForZones(servicePolicies, securityZones); patchAssociatedTagServiceInSecurityZoneInfos(updatedServicePolicies); } downloadedVersion = updatedServicePolicies.getPolicyVersion(); if (lastKnownVersion == -1L || !supportsPolicyDeltas) { ret = filterServicePolicies(updatedServicePolicies); } else { ret = updatedServicePolicies; } ret.setServiceConfig(svcStore.getServiceConfigForPlugin(ret.getServiceId())); httpCode = HttpServletResponse.SC_OK; logMsg = "Returning " + (ret.getPolicies() != null ? ret.getPolicies().size() : (ret.getPolicyDeltas() != null ? ret.getPolicyDeltas().size() : 0)) + " policies. Policy version=" + ret.getPolicyVersion(); } } else { LOG.error("getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ") failed as User doesn't have permission to download Policy"); httpCode = HttpServletResponse.SC_UNAUTHORIZED; logMsg = "User doesn't have permission to download policy"; } } catch (Throwable excp) { LOG.error("getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ") failed", excp); httpCode = HttpServletResponse.SC_BAD_REQUEST; logMsg = excp.getMessage(); } finally { createPolicyDownloadAudit(serviceName, lastKnownVersion, pluginId, httpCode, clusterName, zoneName, request); RangerPerfTracer.log(perf); } } assetMgr.createPluginInfo(serviceName, pluginId, request, RangerPluginInfo.ENTITY_TYPE_POLICIES, downloadedVersion, lastKnownVersion, lastActivationTime, httpCode, clusterName, pluginCapabilities); if (httpCode != HttpServletResponse.SC_OK) { boolean logError = httpCode != HttpServletResponse.SC_NOT_MODIFIED; throw restErrorUtil.createRESTException(httpCode, logMsg, logError); } if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceREST.getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ", " + pluginId + ", " + clusterName + ", " + supportsPolicyDeltas + "): count=" + ((ret == null || ret.getPolicies() == null) ? 0 : ret.getPolicies().size())); } return ret; } ServiceREST(); }
ServiceREST { @GET @Path("/secure/policies/download/{serviceName}") @Produces({ "application/json", "application/xml" }) public 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) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("==> ServiceREST.getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ", " + pluginId + ", " + clusterName + ", " + supportsPolicyDeltas + ")"); } ServicePolicies ret = null; int httpCode = HttpServletResponse.SC_OK; String logMsg = null; RangerPerfTracer perf = null; boolean isAllowed = false; boolean isAdmin = bizUtil.isAdmin(); boolean isKeyAdmin = bizUtil.isKeyAdmin(); request.setAttribute("downloadPolicy", "secure"); Long downloadedVersion = null; boolean isValid = false; try { isValid = serviceUtil.isValidService(serviceName, request); } catch (WebApplicationException webException) { httpCode = webException.getResponse().getStatus(); logMsg = webException.getResponse().getEntity().toString(); } catch (Exception e) { httpCode = HttpServletResponse.SC_BAD_REQUEST; logMsg = e.getMessage(); } if (isValid) { if (lastKnownVersion == null) { lastKnownVersion = Long.valueOf(-1); } try { if (RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getSecureServicePoliciesIfUpdated(serviceName=" + serviceName + ",lastKnownVersion=" + lastKnownVersion + ",lastActivationTime=" + lastActivationTime + ")"); } XXService xService = daoManager.getXXService().findByName(serviceName); XXServiceDef xServiceDef = daoManager.getXXServiceDef().getById(xService.getType()); RangerService rangerService = null; if (StringUtils.equals(xServiceDef.getImplclassname(), EmbeddedServiceDefsUtil.KMS_IMPL_CLASS_NAME)) { rangerService = svcStore.getServiceByNameForDP(serviceName); if (isKeyAdmin) { isAllowed = true; } else { if (rangerService != null) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Download); if (!isAllowed) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Grant_Revoke); } } } } else { rangerService = svcStore.getServiceByName(serviceName); if (isAdmin) { isAllowed = true; } else { if (rangerService != null) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Download); if (!isAllowed) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Grant_Revoke); } } } } if (isAllowed) { ServicePolicies servicePolicies = svcStore.getServicePoliciesIfUpdated(serviceName, lastKnownVersion, !supportsPolicyDeltas); if (servicePolicies == null) { downloadedVersion = lastKnownVersion; httpCode = HttpServletResponse.SC_NOT_MODIFIED; logMsg = "No change since last update"; } else { Map<String, RangerSecurityZone.RangerSecurityZoneService> securityZones = zoneStore.getSecurityZonesForService(serviceName); ServicePolicies updatedServicePolicies = servicePolicies; if (MapUtils.isNotEmpty(securityZones)) { updatedServicePolicies = RangerPolicyAdminCache.getUpdatedServicePoliciesForZones(servicePolicies, securityZones); patchAssociatedTagServiceInSecurityZoneInfos(updatedServicePolicies); } downloadedVersion = updatedServicePolicies.getPolicyVersion(); if (lastKnownVersion == -1L || !supportsPolicyDeltas) { ret = filterServicePolicies(updatedServicePolicies); } else { ret = updatedServicePolicies; } ret.setServiceConfig(svcStore.getServiceConfigForPlugin(ret.getServiceId())); httpCode = HttpServletResponse.SC_OK; logMsg = "Returning " + (ret.getPolicies() != null ? ret.getPolicies().size() : (ret.getPolicyDeltas() != null ? ret.getPolicyDeltas().size() : 0)) + " policies. Policy version=" + ret.getPolicyVersion(); } } else { LOG.error("getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ") failed as User doesn't have permission to download Policy"); httpCode = HttpServletResponse.SC_UNAUTHORIZED; logMsg = "User doesn't have permission to download policy"; } } catch (Throwable excp) { LOG.error("getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ") failed", excp); httpCode = HttpServletResponse.SC_BAD_REQUEST; logMsg = excp.getMessage(); } finally { createPolicyDownloadAudit(serviceName, lastKnownVersion, pluginId, httpCode, clusterName, zoneName, request); RangerPerfTracer.log(perf); } } assetMgr.createPluginInfo(serviceName, pluginId, request, RangerPluginInfo.ENTITY_TYPE_POLICIES, downloadedVersion, lastKnownVersion, lastActivationTime, httpCode, clusterName, pluginCapabilities); if (httpCode != HttpServletResponse.SC_OK) { boolean logError = httpCode != HttpServletResponse.SC_NOT_MODIFIED; throw restErrorUtil.createRESTException(httpCode, logMsg, logError); } if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceREST.getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ", " + pluginId + ", " + clusterName + ", " + supportsPolicyDeltas + "): count=" + ((ret == null || ret.getPolicies() == null) ? 0 : ret.getPolicies().size())); } 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("/secure/policies/download/{serviceName}") @Produces({ "application/json", "application/xml" }) public 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) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("==> ServiceREST.getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ", " + pluginId + ", " + clusterName + ", " + supportsPolicyDeltas + ")"); } ServicePolicies ret = null; int httpCode = HttpServletResponse.SC_OK; String logMsg = null; RangerPerfTracer perf = null; boolean isAllowed = false; boolean isAdmin = bizUtil.isAdmin(); boolean isKeyAdmin = bizUtil.isKeyAdmin(); request.setAttribute("downloadPolicy", "secure"); Long downloadedVersion = null; boolean isValid = false; try { isValid = serviceUtil.isValidService(serviceName, request); } catch (WebApplicationException webException) { httpCode = webException.getResponse().getStatus(); logMsg = webException.getResponse().getEntity().toString(); } catch (Exception e) { httpCode = HttpServletResponse.SC_BAD_REQUEST; logMsg = e.getMessage(); } if (isValid) { if (lastKnownVersion == null) { lastKnownVersion = Long.valueOf(-1); } try { if (RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getSecureServicePoliciesIfUpdated(serviceName=" + serviceName + ",lastKnownVersion=" + lastKnownVersion + ",lastActivationTime=" + lastActivationTime + ")"); } XXService xService = daoManager.getXXService().findByName(serviceName); XXServiceDef xServiceDef = daoManager.getXXServiceDef().getById(xService.getType()); RangerService rangerService = null; if (StringUtils.equals(xServiceDef.getImplclassname(), EmbeddedServiceDefsUtil.KMS_IMPL_CLASS_NAME)) { rangerService = svcStore.getServiceByNameForDP(serviceName); if (isKeyAdmin) { isAllowed = true; } else { if (rangerService != null) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Download); if (!isAllowed) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Grant_Revoke); } } } } else { rangerService = svcStore.getServiceByName(serviceName); if (isAdmin) { isAllowed = true; } else { if (rangerService != null) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Download); if (!isAllowed) { isAllowed = bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Grant_Revoke); } } } } if (isAllowed) { ServicePolicies servicePolicies = svcStore.getServicePoliciesIfUpdated(serviceName, lastKnownVersion, !supportsPolicyDeltas); if (servicePolicies == null) { downloadedVersion = lastKnownVersion; httpCode = HttpServletResponse.SC_NOT_MODIFIED; logMsg = "No change since last update"; } else { Map<String, RangerSecurityZone.RangerSecurityZoneService> securityZones = zoneStore.getSecurityZonesForService(serviceName); ServicePolicies updatedServicePolicies = servicePolicies; if (MapUtils.isNotEmpty(securityZones)) { updatedServicePolicies = RangerPolicyAdminCache.getUpdatedServicePoliciesForZones(servicePolicies, securityZones); patchAssociatedTagServiceInSecurityZoneInfos(updatedServicePolicies); } downloadedVersion = updatedServicePolicies.getPolicyVersion(); if (lastKnownVersion == -1L || !supportsPolicyDeltas) { ret = filterServicePolicies(updatedServicePolicies); } else { ret = updatedServicePolicies; } ret.setServiceConfig(svcStore.getServiceConfigForPlugin(ret.getServiceId())); httpCode = HttpServletResponse.SC_OK; logMsg = "Returning " + (ret.getPolicies() != null ? ret.getPolicies().size() : (ret.getPolicyDeltas() != null ? ret.getPolicyDeltas().size() : 0)) + " policies. Policy version=" + ret.getPolicyVersion(); } } else { LOG.error("getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ") failed as User doesn't have permission to download Policy"); httpCode = HttpServletResponse.SC_UNAUTHORIZED; logMsg = "User doesn't have permission to download policy"; } } catch (Throwable excp) { LOG.error("getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ") failed", excp); httpCode = HttpServletResponse.SC_BAD_REQUEST; logMsg = excp.getMessage(); } finally { createPolicyDownloadAudit(serviceName, lastKnownVersion, pluginId, httpCode, clusterName, zoneName, request); RangerPerfTracer.log(perf); } } assetMgr.createPluginInfo(serviceName, pluginId, request, RangerPluginInfo.ENTITY_TYPE_POLICIES, downloadedVersion, lastKnownVersion, lastActivationTime, httpCode, clusterName, pluginCapabilities); if (httpCode != HttpServletResponse.SC_OK) { boolean logError = httpCode != HttpServletResponse.SC_NOT_MODIFIED; throw restErrorUtil.createRESTException(httpCode, logMsg, logError); } if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceREST.getSecureServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ", " + lastActivationTime + ", " + pluginId + ", " + clusterName + ", " + supportsPolicyDeltas + "): count=" + ((ret == null || ret.getPolicies() == null) ? 0 : ret.getPolicies().size())); } 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; }