[Fix] Return 403 instead of 401 for StrolchAccessDeniedException
This commit is contained in:
parent
ff0f6b57eb
commit
f19484abc0
|
@ -24,6 +24,7 @@ import javax.ws.rs.ext.Provider;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import li.strolch.exception.StrolchAccessDeniedException;
|
import li.strolch.exception.StrolchAccessDeniedException;
|
||||||
|
import li.strolch.exception.StrolchNotAuthenticatedException;
|
||||||
import li.strolch.privilege.model.Restrictable;
|
import li.strolch.privilege.model.Restrictable;
|
||||||
import li.strolch.rest.helper.ResponseUtil;
|
import li.strolch.rest.helper.ResponseUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -59,7 +60,12 @@ public class StrolchRestfulExceptionMapper implements ExceptionMapper<Exception>
|
||||||
sb.append(restrictable.getPrivilegeValue());
|
sb.append(restrictable.getPrivilegeValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.status(Status.UNAUTHORIZED).entity(sb.toString()).type(MediaType.TEXT_PLAIN).build();
|
return Response.status(Status.FORBIDDEN).entity(sb.toString()).type(MediaType.TEXT_PLAIN).build();
|
||||||
|
|
||||||
|
} else if (ex instanceof StrolchNotAuthenticatedException) {
|
||||||
|
StrolchNotAuthenticatedException e = (StrolchNotAuthenticatedException) ex;
|
||||||
|
logger.error("User tried to access resource, but was not authenticated: " + ex.getMessage());
|
||||||
|
return Response.status(Status.UNAUTHORIZED).entity(e.getMessage()).type(MediaType.TEXT_PLAIN).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseUtil.toResponse(ex);
|
return ResponseUtil.toResponse(ex);
|
||||||
|
|
Loading…
Reference in New Issue