public void handleMessage()

in src/main/java/org/apache/directory/fortress/rest/SecurityOutFaultInterceptor.java [52:82]


    public void handleMessage( Message message ) throws Fault
    {
        Fault fault = (Fault) message.getContent( Exception.class );
        Throwable ex = fault.getCause();
        HttpServletResponse response = (HttpServletResponse) message.getExchange().getInMessage()
            .get( AbstractHTTPDestination.HTTP_RESPONSE );

        // Not a security violation:
        if ( !(ex instanceof SecurityException) )
        {
            LOG.warn("SecurityOutFaultInterceptor caught exception: " + ex );
            response.setStatus( 500 );
        }
        // Security violation:
        else
        {
            int status = ex instanceof AccessDeniedException ? 403 : 401;
            response.setStatus( status );
            LOG.warn("SecurityOutFaultInterceptor caught security violation: " + ex );
        }
        try
        {
            response.getOutputStream().write( ex.getMessage().getBytes() );
            response.getOutputStream().flush();
        }
        catch ( IOException iex )
        {
            LOG.warn("SecurityOutFaultInterceptor caught IOException: " + iex);
        }
        message.getInterceptorChain().abort();
    }