use of org.javaee7.jaspic.customprincipal.sam.MyPrincipal in project javaee7-samples by javaee-samples.
the class PublicServlet method doGet.
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().write("This is a public servlet \n");
String webName = null;
boolean isCustomPrincipal = false;
if (request.getUserPrincipal() != null) {
Principal principal = request.getUserPrincipal();
isCustomPrincipal = principal instanceof MyPrincipal;
webName = principal.getName();
}
boolean webHasRole = request.isUserInRole("architect");
response.getWriter().write("isCustomPrincipal: " + isCustomPrincipal + "\n");
response.getWriter().write("web username: " + webName + "\n");
response.getWriter().write("web user has role \"architect\": " + webHasRole + "\n");
}
use of org.javaee7.jaspic.customprincipal.sam.MyPrincipal in project javaee7-samples by javaee-samples.
the class ProtectedServlet method doGet.
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().write("This is a protected servlet \n");
String webName = null;
boolean isCustomPrincipal = false;
if (request.getUserPrincipal() != null) {
Principal principal = request.getUserPrincipal();
isCustomPrincipal = principal instanceof MyPrincipal;
webName = request.getUserPrincipal().getName();
}
boolean webHasRole = request.isUserInRole("architect");
response.getWriter().write("isCustomPrincipal: " + isCustomPrincipal + "\n");
response.getWriter().write("web username: " + webName + "\n");
response.getWriter().write("web user has role \"architect\": " + webHasRole + "\n");
}
use of org.javaee7.jaspic.customprincipal.sam.MyPrincipal in project javaee7-samples by javaee-samples.
the class PublicServlet method doGet.
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().write("This is a public servlet \n");
String webName = null;
boolean isCustomPrincipal = false;
if (request.getUserPrincipal() != null) {
Principal principal = request.getUserPrincipal();
isCustomPrincipal = principal instanceof MyPrincipal;
webName = principal.getName();
}
boolean webHasRole = request.isUserInRole("architect");
response.getWriter().write("isCustomPrincipal: " + isCustomPrincipal + "\n");
response.getWriter().write("web username: " + webName + "\n");
response.getWriter().write("web user has role \"architect\": " + webHasRole + "\n");
}
use of org.javaee7.jaspic.customprincipal.sam.MyPrincipal in project javaee7-samples by javaee-samples.
the class ProtectedServlet method doGet.
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().write("This is a protected servlet \n");
String webName = null;
boolean isCustomPrincipal = false;
if (request.getUserPrincipal() != null) {
Principal principal = request.getUserPrincipal();
isCustomPrincipal = principal instanceof MyPrincipal;
webName = request.getUserPrincipal().getName();
}
boolean webHasRole = request.isUserInRole("architect");
response.getWriter().write("isCustomPrincipal: " + isCustomPrincipal + "\n");
response.getWriter().write("web username: " + webName + "\n");
response.getWriter().write("web user has role \"architect\": " + webHasRole + "\n");
}
Aggregations