import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
@SlingServlet(paths = "/bin/permissioncheck/html", generateComponent = true, generateService = true)
public class AuthCheckerServlet extends SlingSafeMethodsServlet {
public void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) {
String uri = request.getParameter("uri");
Resource resource = request.getResourceResolver().resolve(uri);
if(ResourceUtil.isNonExistingResource(resource)) {
response.setStatus(SlingHttpServletResponse.SC_FORBIDDEN);
} else {
response.setStatus(SlingHttpServletResponse.SC_OK);
}
}
}
No comments:
Post a Comment
If you have any doubts or questions, please let us know.