Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
        public override void init(FilterConfig filterConfig)
        {
            string authenticationProviderClassName = filterConfig.getInitParameter(AUTHENTICATION_PROVIDER_PARAM);

            if (string.ReferenceEquals(authenticationProviderClassName, null))
            {
                throw new ServletException("Cannot instantiate authentication filter: no authentication provider set. init-param " + AUTHENTICATION_PROVIDER_PARAM + " missing");
            }

            try
            {
                Type authenticationProviderClass = Type.GetType(authenticationProviderClassName);
                authenticationProvider = (AuthenticationProvider)System.Activator.CreateInstance(authenticationProviderClass);
            }
            catch (ClassNotFoundException e)
            {
                throw new ServletException("Cannot instantiate authentication filter: authentication provider not found", e);
            }
            catch (InstantiationException e)
            {
                throw new ServletException("Cannot instantiate authentication filter: cannot instantiate authentication provider", e);
            }
            catch (IllegalAccessException e)
            {
                throw new ServletException("Cannot instantiate authentication filter: constructor not accessible", e);
            }
            catch (System.InvalidCastException e)
            {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                throw new ServletException("Cannot instantiate authentication filter: authentication provider does not implement interface " + typeof(AuthenticationProvider).FullName, e);
            }

            servletPathPrefix = filterConfig.getInitParameter(SERVLET_PATH_PREFIX);
        }