List of usage examples for javax.servlet.http HttpServletRequest getRemoteUser
public String getRemoteUser();
null
if the user has not been authenticated. From source file:org.apache.safe.servlet.BaseServlet.java
/** * Return the user name of the request if any. * * @param request request./*from w w w. ja va 2 s .com*/ * @return the user name, <code>null</code> if there is none. */ protected String getUser(HttpServletRequest request) { return request.getRemoteUser(); }
From source file:com.jaeksoft.searchlib.renderer.plugin.AuthPluginHttpHeader.java
@Override public User getUser(Renderer renderer, HttpServletRequest request) throws IOException { String remoteUser = request.getRemoteUser(); if (remoteUser == null) remoteUser = request.getHeader("X-OSS-REMOTE-USER"); if (StringUtils.isEmpty(remoteUser)) throw new AuthException("No user"); String[] groups = null;//from w ww. j a v a 2s . co m String remoteGroups = request.getHeader("X-OSS-REMOTE-GROUPS"); if (remoteGroups != null) groups = StringUtils.split(remoteGroups, ','); User user = new User(remoteUser, remoteUser, null, groups); Logging.info( "USER authenticated: " + user.userId + " Groups count: " + (groups == null ? 0 : groups.length)); return user; }
From source file:org.openmrs.contrib.metadatarepository.webapp.controller.PackageController.java
@RequestMapping(value = "/mypackages*", method = RequestMethod.GET) public ModelAndView myPackages(@RequestParam(required = false, value = "q") String query, HttpServletRequest request) throws Exception { User user = umagr.getUserByUsername(request.getRemoteUser()); return new ModelAndView("/mypackages", Constants.PACKAGE_LIST, magr.searchByUser(query, user)); }
From source file:org.jboss.dashboard.ui.controller.requestChain.HttpSSOProcessor.java
public boolean processRequest() throws Exception { HttpServletRequest request = getHttpRequest(); String login = request.getRemoteUser(); UserStatus us = UserStatus.lookup(); // Catch J2EE container login requests. if (!StringUtils.isBlank(login) && us.isAnonymous()) { // Login as root. if (us.getRootLogin().equals(login)) { us.initSessionAsRoot();/* w ww .j a va 2s .c o m*/ } // Login as normal user. else { Set<String> roleIds = new HashSet<String>(); Set<Role> roles = getRolesManager().getAllRoles(); for (Role role : roles) { String roleId = role.getName(); if (request.isUserInRole(roleId)) roleIds.add(roleId); } us.initSession(login, roleIds); } } return true; }
From source file:org.smigo.config.RequestLogFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse resp = (HttpServletResponse) response; HttpServletRequest req = (HttpServletRequest) request; resp.addHeader("SmigoUser", req.getRemoteUser()); log.info("Incoming request:" + req.getMethod() + req.getRequestURL().toString()); request.setAttribute(REQUEST_TIMER, System.nanoTime()); chain.doFilter(request, response);//from w w w. j av a 2 s . co m logHandler.log(req, resp); }
From source file:org.watterssoft.appsupport.application.ui.ApplicationController.java
@RequestMapping("/list") public @ResponseBody List<ApplicationDTO> getUserApplications(HttpServletRequest request) { return applicationService.getAllUserApplicationDTO(request.getRemoteUser()); }
From source file:org.watterssoft.appsupport.landing.ui.LandingController.java
@RequestMapping("/landingData") public @ResponseBody LandingDTO loadLandingDTO(HttpServletRequest request) { DateTime dateTime = new DateTime(); return landingService.getLandingPageForUser(request.getRemoteUser(), dateTime.minusDays(10).toDate()); }
From source file:edu.emory.cci.aiw.cvrg.eureka.servlet.filter.UserInfoFilter.java
@Override public void doFilter(ServletRequest inRequest, ServletResponse inResponse, FilterChain inFilterChain) throws IOException, ServletException { HttpServletRequest servletRequest = (HttpServletRequest) inRequest; String remoteUser = servletRequest.getRemoteUser(); boolean userIsActivated = false; if (!StringUtils.isEmpty(remoteUser)) { User user = (User) inRequest.getAttribute("user"); if (user != null && user.isActive()) { userIsActivated = true;/*from w w w. ja va 2s . co m*/ } } inRequest.setAttribute("userIsActivated", userIsActivated); inFilterChain.doFilter(inRequest, inResponse); }
From source file:org.jasig.cas.adaptors.trusted.web.flow.PrincipalFromRequestRemoteUserNonInteractiveCredentialsAction.java
protected Credentials constructCredentialsFromRequest(final RequestContext context) { final HttpServletRequest request = WebUtils.getHttpServletRequest(context); final String remoteUser = request.getRemoteUser(); if (StringUtils.hasText(remoteUser)) { if (logger.isDebugEnabled()) { logger.debug("Remote User [" + remoteUser + "] found in HttpServletRequest"); }//from ww w. j a v a 2s .c o m return new PrincipalBearingCredentials(new SimplePrincipal(remoteUser)); } if (logger.isDebugEnabled()) { logger.debug("Remote User not found in HttpServletRequest."); } return null; }
From source file:com.deepsky.spring_security.samples.ServletApiController.java
/** * Demonstrates that Spring Security automatically populates {@link javax.servlet.http.HttpServletRequest#getRemoteUser()} with the * current username./* w w w . ja va 2 s.c om*/ * @param request * @return */ @ModelAttribute("remoteUser") public String remoteUser(HttpServletRequest request) { return request.getRemoteUser(); }