/** * Returns the IP address of the upstream client component. In general this * will correspond the the user agent IP address. This is useful if there * are intermediary components like proxies and load balancers. * * If the supporting {@link #getForwardedAddresses()} method returns a non * empty list, the IP address will be the first element. Otherwise, the * value of {@link #getAddress()} will be returned.<br> * <br> * Note that your HTTP server connectors need to have a special * "useForwardedForHeader" parameter explicitly set to "true" in order to * activate this feature, due to potential security issues. * * @return The most upstream IP address. * @see #getAddress() * @see #getForwardedAddresses() */ public String getUpstreamAddress() { if (this.forwardedAddresses == null || this.forwardedAddresses.isEmpty()) { return getAddress(); } return this.forwardedAddresses.get(0); }
return request.getClientInfo().getAddress();
@Override public String getFromAddress() { return getTarget().getClientInfo().getAddress(); }
@Override public String getRemoteAddr() { return getTarget().getClientInfo().getAddress(); }
/** * Pre-processing method testing if the client IP address is in the set of * blocked addresses. */ @Override protected int beforeHandle(Request request, Response response) { int result = STOP; if (getBlockedAddresses() .contains(request.getClientInfo().getAddress())) { response.setStatus(Status.CLIENT_ERROR_FORBIDDEN, "Your IP address was blocked"); } else { result = CONTINUE; } return result; }
/** * Pre-processing method testing if the client IP address is in the set of * blocked addresses. */ @Override protected int beforeHandle(Request request, Response response) { int result = STOP; if (getBlockedAddresses() .contains(request.getClientInfo().getAddress())) { response.setStatus(Status.CLIENT_ERROR_FORBIDDEN, "Your IP address was blocked"); } else { result = CONTINUE; } return result; }
+ ( ( request != null ) ? request.getClientInfo().getAddress() : "?" ) );
@Override public void parseResponse(ChallengeResponse challenge, Request request, Series<Header> httpHeaders) { try { byte[] credentialsEncoded = Base64.decode(challenge.getRawValue()); if (credentialsEncoded == null) { getLogger() .info("Cannot decode credentials: " + challenge.getRawValue()); } String credentials = new String(credentialsEncoded, "ISO-8859-1"); int separator = credentials.indexOf(':'); if (separator == -1) { // Log the blocking getLogger().info( "Invalid credentials given by client with IP: " + ((request != null) ? request.getClientInfo() .getAddress() : "?")); } else { challenge.setIdentifier(credentials.substring(0, separator)); challenge.setSecret(credentials.substring(separator + 1)); } } catch (UnsupportedEncodingException e) { getLogger().log(Level.INFO, "Unsupported HTTP Basic encoding error", e); } catch (IllegalArgumentException e) { getLogger().log(Level.INFO, "Unable to decode the HTTP Basic credential", e); } }
void checkPosMediaType(Representation entity) throws GeoWebCacheException { String remoteAdr = getRequest().getClientInfo().getAddress(); if (entity == null || ((!entity.getMediaType().includes(MediaType.APPLICATION_XML)) && (!entity.getMediaType().includes(MediaType.APPLICATION_JSON)))) { String message = "Request from "+ remoteAdr + " did not specify MIME type" + " of the document posted. Please specify application/xml " + " or application/json"; throw new GeoWebCacheException(message); } else { log.info("Received seed request from " + remoteAdr); } }
@Override public void handle(Request request, Response response) { String entity = "Method : " + request.getMethod() + "\nResource URI : " + request.getResourceRef() + "\nIP address : " + request.getClientInfo().getAddress() + "\nAgent name : " + request.getClientInfo().getAgentName() + "\nAgent version: " + request.getClientInfo().getAgentVersion(); response.setEntity(entity, MediaType.TEXT_PLAIN); } };
@Override public void handle(Request request, Response response) { String entity = "Method : " + request.getMethod() + "\nResource URI : " + request.getResourceRef() + "\nIP address : " + request.getClientInfo().getAddress() + "\nAgent name : " + request.getClientInfo().getAgentName() + "\nAgent version: " + request.getClientInfo().getAgentVersion(); response.setEntity(entity, MediaType.TEXT_PLAIN); }
@Override public void handle(Request request, Response response) { String entity = "Method : " + request.getMethod() + "\nResource URI : " + request.getResourceRef() + "\nIP address : " + request.getClientInfo().getAddress() + "\nAgent name : " + request.getClientInfo().getAgentName() + "\nAgent version: " + request.getClientInfo().getAgentVersion(); response.setEntity(entity, MediaType.TEXT_PLAIN); }
@Override public void handle(Request request, Response response) { String entity = "Method : " + request.getMethod() + "\nResource URI : " + request.getResourceRef() + "\nIP address : " + request.getClientInfo().getAddress() + "\nAgent name : " + request.getClientInfo().getAgentName() + "\nAgent version: " + request.getClientInfo().getAgentVersion(); response.setEntity(entity, MediaType.TEXT_PLAIN); } };
.toString(this.request.isConfidential()); } else if (variableName.equals("cia")) { result = this.request.getClientInfo().getAddress(); } else if (variableName.equals("cig")) { result = this.request.getClientInfo().getAgent();
return Boolean.toString(this.request.isConfidential()); case "cia": return this.request.getClientInfo().getAddress(); case "ciua": return this.request.getClientInfo().getUpstreamAddress();
clientInfo.setAddress(rci.getAddress()); clientInfo.setAgent(rci.getAgent());