@Override protected void initializeAuthHandler(String authHandlerClassName, FilterConfig filterConfig) throws ServletException { // A single CuratorFramework should be used for a ZK cluster. // If the ZKSignerSecretProvider has already created it, it has to // be set here... to be used by the ZKDelegationTokenSecretManager ZKDelegationTokenSecretManager.setCurator((CuratorFramework) filterConfig.getServletContext().getAttribute(ZKSignerSecretProvider. ZOOKEEPER_SIGNER_SECRET_PROVIDER_CURATOR_CLIENT_ATTRIBUTE)); super.initializeAuthHandler(authHandlerClassName, filterConfig); ZKDelegationTokenSecretManager.setCurator(null); }
@SuppressWarnings("unchecked") private Class<? extends SignerSecretProvider> getProviderClass(Properties config) throws ServletException { String providerClassName; String signerSecretProviderName = config.getProperty(SIGNER_SECRET_PROVIDER, null); // fallback to old behavior if (signerSecretProviderName == null) { String signatureSecret = config.getProperty(SIGNATURE_SECRET, null); if (signatureSecret != null) { providerClassName = StringSignerSecretProvider.class.getName(); } else { providerClassName = RandomSignerSecretProvider.class.getName(); randomSecret = true; } } else { if ("random".equals(signerSecretProviderName)) { providerClassName = RandomSignerSecretProvider.class.getName(); randomSecret = true; } else if ("string".equals(signerSecretProviderName)) { providerClassName = StringSignerSecretProvider.class.getName(); } else if ("zookeeper".equals(signerSecretProviderName)) { providerClassName = ZKSignerSecretProvider.class.getName(); } else { providerClassName = signerSecretProviderName; customSecretProvider = true; } } try { return (Class<? extends SignerSecretProvider>) Thread.currentThread(). getContextClassLoader().loadClass(providerClassName); } catch (ClassNotFoundException ex) { throw new ServletException(ex); } }