SentryGenericProviderBackend extends CacheProvider implements ProviderBackend { @Override public void initialize(ProviderBackendContext context) { if (initialized) { throw new IllegalStateException("SentryGenericProviderBackend has already been initialized, cannot be initialized twice"); } Preconditions.checkNotNull(serviceName, "Service name is not defined. Use configuration parameter: " + conf.get(ApiConstants.ClientConfig.SERVICE_NAME)); Preconditions.checkNotNull(componentType, "Component type is not defined. Use configuration parameter: " + conf.get(ApiConstants.ClientConfig.COMPONENT_TYPE)); if (enableCaching) { if (privilegeConverter == null) { throw new SentryConfigurationException(ApiConstants.ClientConfig.PRIVILEGE_CONVERTER + " not configured."); } Constructor<?> privilegeConverterConstructor; TSentryPrivilegeConverter sentryPrivilegeConverter; try { privilegeConverterConstructor = Class.forName(privilegeConverter).getDeclaredConstructor(String.class, String.class); privilegeConverterConstructor.setAccessible(true); sentryPrivilegeConverter = (TSentryPrivilegeConverter) privilegeConverterConstructor.newInstance(getComponentType(), getServiceName()); } catch (NoSuchMethodException | ClassNotFoundException | InstantiationException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException("Failed to create privilege converter of type " + privilegeConverter, e); } LOGGER.debug("Starting Updateable Cache"); UpdatableCache cache = new UpdatableCache(conf, getComponentType(), getServiceName(), sentryPrivilegeConverter); try { cache.startUpdateThread(true); } catch (Exception e) { throw new RuntimeException("Failed to get privileges from Sentry to build cache.", e); } super.initialize(cache); } this.initialized = true; } SentryGenericProviderBackend(Configuration conf, String resource); @Override void initialize(ProviderBackendContext context); @Override ImmutableSet<String> getPrivileges(Set<String> groups,
      ActiveRoleSet roleSet, Authorizable... authorizableHierarchy); @Override ImmutableSet<Privilege> getPrivilegeObjects(Set<String> groups, Set<String> users,
    ActiveRoleSet roleSet, Authorizable... authorizableHierarchy); @Override ImmutableSet<String> getRoles(Set<String> groups, ActiveRoleSet roleSet); @Override void validatePolicy(boolean strictValidation); @Override ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
                                              ActiveRoleSet roleSet, Authorizable... authorizableHierarchy); @Override void close(); void setComponentType(String componentType); String getComponentType(); String getServiceName(); void setServiceName(String serviceName);  }
@Test(expected = NullPointerException.class) public void testScopeParamsValidated() throws Exception { Configuration conf = new Configuration(); SentryGenericProviderBackend providerBackend = new SentryGenericProviderBackend(conf, "resource"); providerBackend.initialize(new ProviderBackendContext()); }