/** * The default behavior of this method is to return getRemoteAddr() * on the wrapped request object. */ public String getRemoteAddr() { return this.request.getRemoteAddr(); }
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { if (log.isDebugEnabled()) { StringBuilder sb = new StringBuilder(); sb.append(servletRequest.getRemoteAddr()).append(" - "); sb.append(((HttpServletRequest)servletRequest).getRequestURI()); log.debug(sb.toString()); } filterChain.doFilter(servletRequest, servletResponse); }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { String ip = request.getRemoteAddr(); if (accept(ip)) { chain.doFilter(request, response); } else { logger.warn("Did not accept IP " + ip); ((HttpServletResponse) response).sendError(HttpServletResponse.SC_FORBIDDEN); } }
/** * Returns the Internet Protocol (IP) address of the client * or last proxy that sent the request. * * @return IP address of the remote peer * @throws UnknownHostException if no IP address for the peer could be found, */ public InetAddress getRemoteAddr() throws UnknownHostException { return InetAddress.getByName(context.getRequest().getRemoteAddr()); }
protected static String getRemoteAddress(AsyncContext context) { String remoteAddress = null; if (context.getRequest() != null && context.getRequest().getRemoteAddr() != null) { remoteAddress = context.getRequest().getRemoteAddr(); } if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = "<UNKNOWN ADDRESS>"; } return remoteAddress; }
if (!"127.0.0.1".equals(servletRequest.getRemoteAddr()))
private void handleSessionRequest(AsyncContext context, HttpBindBody body) throws IOException { final String sid = body.getSid(); if (JiveGlobals.getBooleanProperty("log.httpbind.enabled", false)) { Log.info("HTTP RECV(" + sid + "): " + body.asXML()); } HttpSession session = sessionManager.getSession(sid); if (session == null) { if (Log.isDebugEnabled()) { Log.debug("Client provided invalid session: " + sid + ". [" + context.getRequest().getRemoteAddr() + "]"); } sendLegacyError(context, BoshBindingError.itemNotFound, "Invalid SID value."); return; } synchronized (session) { try { session.forwardRequest(body, context); } catch (HttpBindException e) { sendError(session, context, e.getBindingError()); } catch (HttpConnectionClosedException nc) { Log.error("Error sending packet to client.", nc); context.complete(); } } }
/** * The default behavior of this method is to return getRemoteAddr() * on the wrapped request object. */ public String getRemoteAddr() { return this.request.getRemoteAddr(); }
/** * The default behavior of this method is to return getRemoteAddr() * on the wrapped request object. */ public String getRemoteAddr() { return this.request.getRemoteAddr(); }
private Set<String> localAddresses = new HashSet<String>(); @Override public void init(FilterConfig config) throws ServletException { try { localAddresses.add(InetAddress.getLocalHost().getHostAddress()); for (InetAddress inetAddress : InetAddress.getAllByName("localhost")) { localAddresses.add(inetAddress.getHostAddress()); } } catch (IOException e) { throw new ServletException("Unable to lookup local addresses"); } } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { if (localAddresses.contains(request.getRemoteAddr())) { // Locally accessed. } else { // Remotely accessed. } }
public static void put(final String key, final ServletRequest servletRequest) { put(key, "RemoteAddr", servletRequest.getRemoteAddr()); put(key, "RemoteHost", servletRequest.getRemoteHost()); put(key, "RemotePort", servletRequest.getRemotePort()); }
/** * The default behavior of this method is to return getRemoteAddr() * on the wrapped request object. */ public String getRemoteAddr() { return this.request.getRemoteAddr(); }
/** * The default behavior of this method is to return getRemoteAddr() * on the wrapped request object. */ public String getRemoteAddr() { return this.request.getRemoteAddr(); }
/** * The default behavior of this method is to return getRemoteAddr() * on the wrapped request object. */ public String getRemoteAddr() { return this.request.getRemoteAddr(); }
/** * The default behavior of this method is to return getRemoteAddr() * on the wrapped request object. */ public String getRemoteAddr() { return this.request.getRemoteAddr(); }
/** * The default behavior of this method is to return getRemoteAddr() * on the wrapped request object. */ public String getRemoteAddr() { return this.request.getRemoteAddr(); }
/** * The default behavior of this method is to return getRemoteAddr() * on the wrapped request object. */ public String getRemoteAddr() { return this.request.getRemoteAddr(); }
/** * The default behavior of this method is to return getRemoteAddr() * on the wrapped request object. */ public String getRemoteAddr() { return this.request.getRemoteAddr(); }
@Override protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception { String remoteAddr = request.getRemoteAddr() ; if ( LOCALHOST_IpV6.equals(remoteAddr) || LOCALHOST_IpV4.equals(remoteAddr) ) return true ; return false ; } }
@Override protected boolean onAccessDenied(final ServletRequest request, final ServletResponse response) throws IOException { log.debug("Rejecting request from {} due to invalid cross-site request forgery token", request.getRemoteAddr()); HttpServletResponse httpResponse = (HttpServletResponse) response; httpResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED); httpResponse.setContentType("text/plain"); httpResponse.getWriter().print(ERROR_MESSAGE_TOKEN_MISMATCH); return false; }