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.hadoop.chukwa.rest.resource.ViewResource.java
@GET @Path("vid/{vid}") public ViewBean getView(@Context HttpServletRequest request, @PathParam("vid") String vid) { ViewStore view;/*ww w .j a v a 2s .c o m*/ ViewBean vr; String uid = request.getRemoteUser(); try { view = new ViewStore(uid, vid); vr = view.get(); if (request.getRemoteUser().intern() != vr.getOwner().intern() && vr.getPermissionType().intern() != "public".intern()) { throw new WebApplicationException( Response.status(Response.Status.FORBIDDEN).entity("permission denied.").build()); } } catch (IllegalAccessException e) { throw new WebApplicationException( Response.status(Response.Status.NOT_FOUND).entity("View does not exist.").build()); } return vr; }
From source file:org.watterssoft.appsupport.ticket.ui.TicketController.java
@RequestMapping(value = "/viewTicket/{ticketId}", method = RequestMethod.GET) public @ResponseBody TicketDTO viewTicket(HttpServletRequest request, @PathVariable Long ticketId) { Ticket ticket = ticketService.getTicketById(ticketId); List<ApplicationDTO> applications = applicationService.getAllUserApplicationDTO(request.getRemoteUser()); return new TicketDTO(ticket, applications); }
From source file:edu.emory.cci.aiw.cvrg.eureka.servlet.filter.HaveUserRecordFilter.java
@Override public void doFilter(ServletRequest inRequest, ServletResponse inResponse, FilterChain inFilterChain) throws IOException, ServletException { HttpServletRequest servletRequest = (HttpServletRequest) inRequest; HttpServletResponse servletResponse = (HttpServletResponse) inResponse; String remoteUser = servletRequest.getRemoteUser(); if (!StringUtils.isEmpty(remoteUser)) { try {//from w w w . j a v a 2s .co m User user = this.servicesClient.getMe(); if (!user.isActive()) { HttpSession session = servletRequest.getSession(false); if (session != null) { session.invalidate(); } sendForbiddenError(servletResponse, servletRequest, true); } else { inRequest.setAttribute("user", user); inFilterChain.doFilter(inRequest, inResponse); } } catch (ClientException ex) { if (Status.FORBIDDEN.equals(ex.getResponseStatus())) { HttpSession session = servletRequest.getSession(false); if (session != null) { session.invalidate(); } sendForbiddenError(servletResponse, servletRequest, false); } else if (Status.UNAUTHORIZED.equals(ex.getResponseStatus())) { HttpSession session = servletRequest.getSession(false); if (session != null) { session.invalidate(); } servletResponse.sendRedirect(servletRequest.getContextPath() + "/logout?goHome=true"); } else { throw new ServletException("Error getting user " + servletRequest.getRemoteUser(), ex); } } } else { inFilterChain.doFilter(inRequest, inResponse); } }
From source file:org.beangle.security.web.auth.preauth.j2ee.RemoteUsernameSource.java
public String obtainUsername(HttpServletRequest request) { String username = null;//from www .j a v a 2s . c o m Principal p = request.getUserPrincipal(); if (null != p) { username = p.getName(); } if (StringUtils.isEmpty(username)) { username = request.getRemoteUser(); } if (null != username && isStripPrefix()) { username = stripPrefix(username); } if (null != username) { logger.debug("Obtained username=[{}] from remote user", username); } return username; }
From source file:edu.cornell.mannlib.vitro.webapp.controller.authenticate.FriendController.java
private void writeWarningToTheLog(HttpServletRequest req) { log.warn("LOGGING IN VIA FRIEND FROM ADDR=" + req.getRemoteAddr() + ", PORT=" + req.getRemotePort() + ", HOST=" + req.getRemoteHost() + ", USER=" + req.getRemoteUser()); }
From source file:org.apache.hadoop.chukwa.rest.resource.ViewResource.java
@GET @Path("list") public String getUserViewList(@Context HttpServletRequest request) { String result = ""; String uid = null;/*from www . j a v a 2s . com*/ try { if (uid == null) { uid = request.getRemoteUser(); } result = ViewStore.list(uid).toString(); } catch (Exception e) { throw new WebApplicationException( Response.status(Response.Status.NOT_FOUND).entity("View does not exist.").build()); } return result; }
From source file:managedbeans.UsuarioController.java
public boolean hasIdentity() { FacesContext context = FacesContext.getCurrentInstance(); ExternalContext externalContext = context.getExternalContext(); HttpServletRequest request = (HttpServletRequest) externalContext.getRequest(); if (request.getRemoteUser() == null) { return false; }/*ww w . j av a 2 s . co m*/ return true; }
From source file:org.watterssoft.appsupport.application.ui.ApplicationController.java
@RequestMapping(value = "/addApplication", method = RequestMethod.POST) public @ResponseBody void addApplication(@RequestBody ApplicationDTO applicationDTO, HttpServletRequest request) { Application application = new Application(applicationDTO.getName(), applicationDTO.getVersion(), applicationDTO.getUrl());/*from ww w .ja va 2 s. co m*/ application = applicationService.save(application, userService.getUserByUserName(request.getRemoteUser())); applicationDTO.setId(application.getId()); }
From source file:com.tremolosecurity.scale.user.ScaleSession.java
@PostConstruct public void init() { try {/*from w w w.j av a 2 s . c o m*/ HttpClientInfo httpci = this.commonConfig.createHttpClientInfo(); http = HttpClients.custom().setConnectionManager(httpci.getCm()) .setDefaultRequestConfig(httpci.getGlobalConfig()) .setHostnameVerifier(new AllowAllHostnameVerifier()).build(); URL uurl = new URL(commonConfig.getScaleConfig().getServiceConfiguration().getUnisonURL()); int port = uurl.getPort(); HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext() .getRequest(); this.login = request.getRemoteUser(); } catch (Exception e) { logger.error("Could not initialize ScaleSession", e); } }
From source file:org.apache.hadoop.chukwa.rest.resource.ViewResource.java
@DELETE @Path("delete/{owner}/vid/{vid}") public ReturnCodeBean deleteView(@Context HttpServletRequest request, @PathParam("owner") String owner, @PathParam("vid") String vid) { try {/*from w ww.jav a 2s . c om*/ if (owner.intern() == request.getRemoteUser().intern()) { log.info("owner: " + owner + " vid: " + vid); ViewStore vs = new ViewStore(owner, vid); vs.delete(); } else { throw new WebApplicationException( Response.status(Response.Status.FORBIDDEN).entity("View delete failed.").build()); } } catch (Exception e) { log.error(ExceptionUtil.getStackTrace(e)); throw new WebApplicationException( Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("View delete failed.").build()); } return new ReturnCodeBean(ReturnCodeBean.SUCCESS, "Deleted"); }