List of usage examples for javax.servlet.http HttpServletRequest getRemoteAddr
public String getRemoteAddr();
From source file:psiprobe.controllers.wrapper.RestartJvmController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { boolean done = false; try {/*from w ww .ja v a 2s . co m*/ Class.forName("org.tanukisoftware.wrapper.WrapperManager"); logger.info("JVM is RESTARTED by {}", request.getRemoteAddr()); WrapperManager.restartAndReturn(); done = true; } catch (ClassNotFoundException e) { logger.info("WrapperManager not found. Do you have wrapper.jar in the classpath?"); logger.trace("", e); } return new ModelAndView(getViewName(), "done", done); }
From source file:com.haulmont.restapi.auth.ExternalOAuthTokenGranter.java
@Override public OAuth2AccessTokenResult issueToken(OAuth2AccessTokenRequest tokenRequest) { RestApiConfig config = configuration.getConfig(RestApiConfig.class); String login = tokenRequest.getLogin(); Locale locale = tokenRequest.getLocale(); Map<String, String> parameters = new HashMap<>(); parameters.put("username", login); parameters.put("client_id", config.getRestClientId()); parameters.put("scope", "rest-api"); parameters.put("grant", GRANT_TYPE); UserSession session;// ww w.ja va 2 s. c om try { TrustedClientCredentials credentials = new TrustedClientCredentials(login, config.getTrustedClientPassword(), locale); credentials.setClientType(ClientType.REST_API); ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder .currentRequestAttributes(); if (attributes != null) { HttpServletRequest request = attributes.getRequest(); credentials.setIpAddress(request.getRemoteAddr()); credentials.setClientInfo(makeClientInfo(request.getHeader(HttpHeaders.USER_AGENT))); } else { credentials.setClientInfo(makeClientInfo("")); } credentials.setParams(tokenRequest.getLoginParams()); session = authenticationService.login(credentials).getSession(); } catch (RestApiAccessDeniedException ex) { log.info("User is not allowed to use the REST API {}", login); throw new BadCredentialsException("User is not allowed to use the REST API"); } catch (LoginException e) { log.info("Unable to issue token for REST API: {}", login); throw new BadCredentialsException("Bad credentials"); } parameters.put(SESSION_ID_DETAILS_ATTRIBUTE, session.getId().toString()); for (Map.Entry<String, String> tokenParam : tokenRequest.getTokenDetails().entrySet()) { parameters.put(EXTENDED_DETAILS_ATTRIBUTE_PREFIX + tokenParam.getKey(), tokenParam.getValue()); } // issue token using obtained Session, it is required for DB operations inside of persistent token store OAuth2AccessToken accessToken = withSecurityContext(new SecurityContext(session), () -> { ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(config.getRestClientId()); TokenRequest tr = getRequestFactory().createTokenRequest(parameters, authenticatedClient); return grant(GRANT_TYPE, tr); }); return new OAuth2AccessTokenResult(session, accessToken); }
From source file:Main.java
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); // Print out the IP address of the caller out.println(request.getRemoteAddr()); }
From source file:psiprobe.controllers.wrapper.ThreadDumpController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { boolean done = false; try {//w w w .j av a 2s .c om Class.forName("org.tanukisoftware.wrapper.WrapperManager"); logger.info("ThreadDump requested by {}", request.getRemoteAddr()); WrapperManager.requestThreadDump(); done = true; } catch (ClassNotFoundException e) { logger.info("WrapperManager not found. Do you have wrapper.jar in the classpath?"); logger.trace("", e); } return new ModelAndView(getViewName(), "done", done); }
From source file:com.alfaariss.oa.authorization.method.web.forceaction.ForceActionAuthorizationMethod.java
/** * @see com.alfaariss.oa.sso.authorization.web.IWebAuthorizationMethod#authorize(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, com.alfaariss.oa.api.session.ISession) *///w w w .java 2 s. c om public UserEvent authorize(HttpServletRequest oRequest, HttpServletResponse oResponse, ISession oSession) throws OAException { UserEvent event = _oAction.perform(oSession); _eventLogger.info(new UserEventLogItem(oSession, oRequest.getRemoteAddr(), event, this, null)); return event; }
From source file:com.seguriboxltv.backing.AdminUserBean.java
private String GetIp() { HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext() .getRequest();/*from www. j a v a2 s . c o m*/ String ipAddress = request.getHeader("X-FORWARDED-FOR"); if (ipAddress == null) { ipAddress = request.getRemoteAddr(); } return ipAddress; }
From source file:ru.mystamps.web.service.SiteServiceImpl.java
/** * @author Sergey Chechenev/*from ww w. ja va 2 s .c o m*/ */ @Override @Transactional public void logAboutMissingCsrfToken(HttpServletRequest request) { logEvent(MISSING_CSRF_TOKEN, request.getRequestURI(), request.getMethod(), SecurityContextUtils.getUserId(), request.getRemoteAddr(), request.getHeader("referer"), request.getHeader("user-agent"), new Date()); }
From source file:ru.mystamps.web.service.SiteServiceImpl.java
/** * @author Sergey Chechenev// w w w .j a v a2 s. co m */ @Override @Transactional public void logAboutInvalidCsrfToken(HttpServletRequest request) { logEvent(INVALID_CSRF_TOKEN, request.getRequestURI(), request.getMethod(), SecurityContextUtils.getUserId(), request.getRemoteAddr(), request.getHeader("referer"), request.getHeader("user-agent"), new Date()); }
From source file:com.mobilewallet.services.ForgotPasswordService.java
@GET @Produces(MediaType.APPLICATION_JSON)/*from w w w .j av a 2 s.c o m*/ public Object sendPassword(@Context HttpServletRequest request, @QueryParam("email") String email) { log.info("Forgot Password Email : " + email); try { ForgotPasswordEmailThread sv = new ForgotPasswordEmailThread(email.toLowerCase(), request.getRemoteAddr()); Thread t = new Thread(sv); t.start(); } catch (Exception ex) { ex.printStackTrace(); } JSONObject obj = new JSONObject(); try { obj.put("sent", true); } catch (Exception ex) { } return obj.toString(); }
From source file:fr.scc.elo.controller.ServiceController.java
@GET @Path("/connections") @Produces({ MediaType.TEXT_HTML }) @ApiOperation(value = "pour savoir si l'ip source peut enregistrer un match", response = MatchResponse.class) public Response checkConnections(@Context HttpServletRequest http) throws EloException { Map<String, ConnectionData> connectionDataMap = null; if (connectionService.acceptIPUpdate(http.getRemoteAddr())) { connectionDataMap = ConnectionFilter.getConnectionDataMap(); } else {//from www .ja v a 2 s . c o m connectionDataMap = new HashMap<>(); } Map<String, Object> map = new HashMap<>(); map.put("coData", connectionDataMap.values()); return Response.ok(new Viewable("/allConnections", map)).build(); }