use of jakarta.ejb.EJBAccessException in project tomee by apache.
the class SecureServlet method doGet.
protected void doGet(final HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/plain");
final ServletOutputStream out = response.getOutputStream();
out.println("Servlet");
Principal principal = request.getUserPrincipal();
if (principal != null) {
out.println("Servlet.getUserPrincipal()=" + principal + " [" + principal.getName() + "]");
} else {
out.println("Servlet.getUserPrincipal()=<null>");
}
out.println("Servlet.isCallerInRole(\"user\")=" + request.isUserInRole("user"));
out.println("Servlet.isCallerInRole(\"manager\")=" + request.isUserInRole("manager"));
out.println("Servlet.isCallerInRole(\"fake\")=" + request.isUserInRole("fake"));
out.println();
out.println("@EJB=" + secureEJBLocal);
if (secureEJBLocal != null) {
principal = secureEJBLocal.getCallerPrincipal();
if (principal != null) {
out.println("@EJB.getCallerPrincipal()=" + principal + " [" + principal.getName() + "]");
} else {
out.println("@EJB.getCallerPrincipal()=<null>");
}
out.println("@EJB.isCallerInRole(\"user\")=" + secureEJBLocal.isCallerInRole("user"));
out.println("@EJB.isCallerInRole(\"manager\")=" + secureEJBLocal.isCallerInRole("manager"));
out.println("@EJB.isCallerInRole(\"fake\")=" + secureEJBLocal.isCallerInRole("fake"));
try {
secureEJBLocal.allowUserMethod();
out.println("@EJB.allowUserMethod() ALLOWED");
} catch (EJBAccessException e) {
out.println("@EJB.allowUserMethod() DENIED");
}
try {
secureEJBLocal.allowManagerMethod();
out.println("@EJB.allowManagerMethod() ALLOWED");
} catch (EJBAccessException e) {
out.println("@EJB.allowManagerMethod() DENIED");
}
try {
secureEJBLocal.allowFakeMethod();
out.println("@EJB.allowFakeMethod() ALLOWED");
} catch (final EJBAccessException e) {
out.println("@EJB.allowFakeMethod() DENIED");
}
try {
secureEJBLocal.denyAllMethod();
out.println("@EJB.denyAllMethod() ALLOWED");
} catch (EJBAccessException e) {
out.println("@EJB.denyAllMethod() DENIED");
}
}
out.println();
}
Aggregations