001/*
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 */
006package org.fcrepo.http.commons.exceptionhandlers;
007
008import static javax.ws.rs.core.Response.status;
009import static javax.ws.rs.core.Response.Status.FORBIDDEN;
010import static org.slf4j.LoggerFactory.getLogger;
011
012import java.security.AccessControlException;
013
014import javax.ws.rs.core.Response;
015import javax.ws.rs.ext.ExceptionMapper;
016import javax.ws.rs.ext.Provider;
017
018import org.slf4j.Logger;
019
020/**
021 * Translate Java Security AccessControlExceptions into HTTP 403 Forbidden errors
022 *
023 * @author lsitu
024 * @author awoods
025 * @author gregjan
026 */
027@Provider
028public class AccessControlJavaSecurityExceptionMapper implements
029        ExceptionMapper<AccessControlException>, ExceptionDebugLogging {
030
031    private static final Logger LOGGER =
032        getLogger(AccessControlJavaSecurityExceptionMapper.class);
033
034    @Override
035    public Response toResponse(final AccessControlException e) {
036        debugException(this, e, LOGGER);
037        return status(FORBIDDEN).build();
038    }
039
040}