Beispiel #1
0
        protected internal virtual void Log(Response.Status status, Exception ex)
        {
            UserGroupInformation ugi = KMSMDCFilter.GetUgi();
            string method            = KMSMDCFilter.GetMethod();
            string url = KMSMDCFilter.GetURL();
            string msg = GetOneLineMessage(ex);

            Log.Warn("User:'******' Method:{} URL:{} Response:{}-{}", ugi, method, url, status, msg
                     , ex);
        }
Beispiel #2
0
        /// <summary>Maps different exceptions thrown by KMS to HTTP status codes.</summary>
        public virtual Response ToResponse(Exception exception)
        {
            Response.Status status;
            bool            doAudit   = true;
            Exception       throwable = exception;

            if (exception is ContainerException)
            {
                throwable = exception.InnerException;
            }
            if (throwable is SecurityException)
            {
                status = Response.Status.Forbidden;
            }
            else
            {
                if (throwable is AuthenticationException)
                {
                    status = Response.Status.Forbidden;
                    // we don't audit here because we did it already when checking access
                    doAudit = false;
                }
                else
                {
                    if (throwable is AuthorizationException)
                    {
                        status = Response.Status.Forbidden;
                        // we don't audit here because we did it already when checking access
                        doAudit = false;
                    }
                    else
                    {
                        if (throwable is AccessControlException)
                        {
                            status = Response.Status.Forbidden;
                        }
                        else
                        {
                            if (exception is IOException)
                            {
                                status = Response.Status.InternalServerError;
                            }
                            else
                            {
                                if (exception is NotSupportedException)
                                {
                                    status = Response.Status.BadRequest;
                                }
                                else
                                {
                                    if (exception is ArgumentException)
                                    {
                                        status = Response.Status.BadRequest;
                                    }
                                    else
                                    {
                                        status = Response.Status.InternalServerError;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (doAudit)
            {
                KMSWebApp.GetKMSAudit().Error(KMSMDCFilter.GetUgi(), KMSMDCFilter.GetMethod(), KMSMDCFilter
                                              .GetURL(), GetOneLineMessage(exception));
            }
            return(CreateResponse(status, throwable));
        }