Refine search
/** * Determine the username for the given request. * <p>The default implementation takes the name of the UserPrincipal, if any. * Can be overridden in subclasses. * @param request current HTTP request * @return the username, or {@code null} if none found * @see javax.servlet.http.HttpServletRequest#getUserPrincipal() */ @Nullable protected String getUsernameForRequest(HttpServletRequest request) { Principal userPrincipal = request.getUserPrincipal(); return (userPrincipal != null ? userPrincipal.getName() : null); }
@Override protected String getPreAuthenticatedPrincipalName(HttpServletRequest request) { return request.getUserPrincipal() == null ? null : request.getUserPrincipal().getName(); } }
public void handle(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { if (request != null) { LOG.info("Access from: {} url: {} principal: {}", request.getRemoteAddr(), request.getRequestURL(), (request.getUserPrincipal() == null ? "" : request.getUserPrincipal().getName())); } chain.doFilter(request, response); }
private String getUserName(HttpServletRequest httpServletRequest) { final Principal userPrincipal = httpServletRequest.getUserPrincipal(); return userPrincipal != null ? userPrincipal.getName() : null; }
/** * Determine the username for the given request. * <p>The default implementation takes the name of the UserPrincipal, if any. * Can be overridden in subclasses. * @param request current HTTP request * @return the username, or {@code null} if none found * @see javax.servlet.http.HttpServletRequest#getUserPrincipal() */ @Nullable protected String getUsernameForRequest(HttpServletRequest request) { Principal userPrincipal = request.getUserPrincipal(); return (userPrincipal != null ? userPrincipal.getName() : null); }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.getWriter().write("This is a public servlet \n"); String webName = null; if (request.getUserPrincipal() != null) { webName = request.getUserPrincipal().getName(); } response.getWriter().write("web username: " + webName + "\n"); boolean webHasRole = request.isUserInRole("architect"); response.getWriter().write("web user has role \"architect\": " + webHasRole + "\n"); }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.getWriter().write("This is a protected servlet \n"); String webName = null; if (request.getUserPrincipal() != null) { webName = request.getUserPrincipal().getName(); } response.getWriter().write("web username: " + webName + "\n"); boolean webHasRole = request.isUserInRole("architect"); response.getWriter().write("web user has role \"architect\": " + webHasRole + "\n"); }
/** * Gets the user name from the request principal. * * @param req the servlet request * @return the authenticated user, or null if none is authenticated */ @Override public String getUserName(HttpServletRequest req) { Principal princ = null; if (req != null && (princ = req.getUserPrincipal()) != null) { String userName = princ.getName(); if (userName != null && !userName.isEmpty()) { LOG.debug("HTTP request had user (" + userName + ")"); return userName; } } return null; }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String webName = null; if (request.getUserPrincipal() != null) { webName = request.getUserPrincipal().getName(); } String ejbName = ""; try { ejbName = publicEJB.getUserName(); } catch (Exception e) { logger.log(SEVERE, "", e); } response.getWriter().write("web username: " + webName + "\n" + "EJB username: " + ejbName + "\n"); }
/** * Gets the user name from the request principal. * * @param req the servlet request * @return the authenticated user, or null if none is authenticated */ @Override public String getUserName(HttpServletRequest req) { String ret = null; if (req != null) { Principal princ = req.getUserPrincipal(); if (princ != null) { ret = princ.getName(); } if (ret != null && !ret.isEmpty()) { LOG.debug("Get user name {} from http request principal", ret); } else { ret = req.getRemoteUser(); if (ret != null && !ret.isEmpty()) { LOG.debug("Get user name {} from http request remote user", ret); } } } return ret; }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String webName = null; if (request.getUserPrincipal() != null) { webName = request.getUserPrincipal().getName(); } String ejbName = publicEJB.getUserName(); try { ejbName = publicEJB.getUserName(); } catch (Exception e) { logger.log(SEVERE, "", e); } response.getWriter().write("web username: " + webName + "\n" + "EJB username: " + ejbName + "\n"); }
@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"); HttpSession session = request.getSession(false); if (session != null) { response.getWriter().write("Session ID: " + session.getId()); } else { response.getWriter().write("No session"); } }
@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"); HttpSession session = request.getSession(false); if (session != null) { response.getWriter().write("Session ID: " + session.getId()); } else { response.getWriter().write("No session"); } }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String webName = null; if (request.getUserPrincipal() != null) { webName = request.getUserPrincipal().getName(); } String ejbName = ""; try { ejbName = protectedEJB.getUserName(); } catch (Exception e) { logger.log(SEVERE, "", e); } response.getWriter().write("web username: " + webName + "\n" + "EJB username: " + ejbName + "\n"); boolean webHasRole = request.isUserInRole("architect"); boolean ejbHasRole = false; try { ejbHasRole = protectedEJB.isUserArchitect(); } catch (Exception e) { logger.log(SEVERE, "", e); } response.getWriter().write( "web user has role \"architect\": " + webHasRole + "\n" + "EJB user has role \"architect\": " + ejbHasRole + "\n"); }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String webName = null; if (request.getUserPrincipal() != null) { webName = request.getUserPrincipal().getName(); } String ejbName = ""; try { ejbName = protectedEJB.getUserName(); } catch (Exception e) { logger.log(SEVERE, "", e); } response.getWriter().write("web username: " + webName + "\n" + "EJB username: " + ejbName + "\n"); boolean webHasRole = request.isUserInRole("architect"); boolean ejbHasRole = false; try { ejbHasRole = protectedEJB.isUserArchitect(); } catch (Exception e) { logger.log(SEVERE, "", e); } response.getWriter().write( "web user has role \"architect\": " + webHasRole + "\n" + "EJB user has role \"architect\": " + ejbHasRole + "\n"); }
if (request.getUserPrincipal() != null) { webName = request.getUserPrincipal().getName(); if (request.getUserPrincipal() != null) { webNameAfterLogout = request.getUserPrincipal().getName();
if (request.getUserPrincipal() != null) { webName = request.getUserPrincipal().getName(); boolean authenticateOutcome = request.authenticate(response); if (request.getUserPrincipal() != null) { webName = request.getUserPrincipal().getName();
@GET @Path( "/{username}" ) public Response getUser( @PathParam( "username" ) String username, @Context HttpServletRequest req ) { Principal principal = req.getUserPrincipal(); if ( principal == null || !principal.getName().equals( username ) ) { return output.notFound(); } LoginContext loginContext = getLoginContextFromUserPrincipal( principal ); UserManager userManager = userManagerSupplier.getUserManager( loginContext.subject(), false ); try { User user = userManager.getUser( username ); return output.ok( new AuthorizationRepresentation( user ) ); } catch ( InvalidArgumentsException e ) { return output.notFound(); } }
UserGroupInformation ugi = null; AuthenticationToken authToken = (AuthenticationToken) request.getUserPrincipal(); if (authToken != null && authToken != AuthenticationToken.ANONYMOUS) { DelegationTokenAuthenticationHandler.DELEGATION_TOKEN_UGI_ATTRIBUTE); if (ugi == null) { String realUser = request.getUserPrincipal().getName(); ugi = UserGroupInformation.createRemoteUser(realUser, handlerAuthMethod);
final Principal principal = request.getUserPrincipal(); if (principal != null) { putAttribute(attributes, "http.principal.name", principal.getName()); if (certs != null && certs.length > 0) { final X509Certificate cert = certs[0]; subjectDn = cert.getSubjectDN().getName(); final String issuerDn = cert.getIssuerDN().getName();