/** * Get the source address of the HTTP request. * * @return the source address of the HTTP request */ public InetSocketAddress getSourceAddress() { if (sourceAddress != null) { return sourceAddress; } return connection.getPeerAddress(InetSocketAddress.class); }
@Override public String readAttribute(HttpServerExchange exchange) { final InetSocketAddress peerAddress = exchange.getConnection().getPeerAddress(InetSocketAddress.class); try { return peerAddress.getHostName(); } catch (Throwable e) { return peerAddress.getHostString(); } }
@Override public String readAttribute(final HttpServerExchange exchange) { final InetSocketAddress sourceAddress = exchange.getSourceAddress(); InetAddress address = sourceAddress.getAddress(); if (address == null) { //this can happen when we have an unresolved X-forwarded-for address //in this case we just return the IP of the balancer address = ((InetSocketAddress) exchange.getConnection().getPeerAddress()).getAddress(); } if(address == null) { return null; } return address.getHostAddress(); }
jdbcLogAttribute.pattern = pattern; jdbcLogAttribute.remoteHost = ((InetSocketAddress) exchange.getConnection().getPeerAddress()).getAddress().getHostAddress(); SecurityContext sc = exchange.getSecurityContext(); if (sc == null || !sc.isAuthenticated()) {
/** * Get the source address of the HTTP request. * * @return the source address of the HTTP request */ public InetSocketAddress getSourceAddress() { if (sourceAddress != null) { return sourceAddress; } return connection.getPeerAddress(InetSocketAddress.class); }
/** * Get the source address of the HTTP request. * * @return the source address of the HTTP request */ public InetSocketAddress getSourceAddress() { if (sourceAddress != null) { return sourceAddress; } return connection.getPeerAddress(InetSocketAddress.class); }
@Override public String readAttribute(HttpServerExchange exchange) { final InetSocketAddress peerAddress = exchange.getConnection().getPeerAddress(InetSocketAddress.class); try { return peerAddress.getHostName(); } catch (Throwable e) { return peerAddress.getHostString(); } }
@Override public String readAttribute(HttpServerExchange exchange) { final InetSocketAddress peerAddress = exchange.getConnection().getPeerAddress(InetSocketAddress.class); try { return peerAddress.getHostName(); } catch (Throwable e) { return peerAddress.getHostString(); } }
protected String getRemoteHostAddress(HttpServerExchange exchange) { return ((InetSocketAddress) exchange.getConnection().getPeerAddress()).getAddress().getHostAddress(); }
@Override public String readAttribute(final HttpServerExchange exchange) { final InetSocketAddress sourceAddress = exchange.getSourceAddress(); InetAddress address = sourceAddress.getAddress(); if (address == null) { //this can happen when we have an unresolved X-forwarded-for address //in this case we just return the IP of the balancer address = ((InetSocketAddress) exchange.getConnection().getPeerAddress()).getAddress(); } if(address == null) { return null; } return address.getHostAddress(); }
@Override public String readAttribute(final HttpServerExchange exchange) { final InetSocketAddress sourceAddress = exchange.getSourceAddress(); InetAddress address = sourceAddress.getAddress(); if (address == null) { //this can happen when we have an unresolved X-forwarded-for address //in this case we just return the IP of the balancer address = ((InetSocketAddress) exchange.getConnection().getPeerAddress()).getAddress(); } if(address == null) { return null; } return address.getHostAddress(); }
private void initialiseRealmIdentityManager(HttpServerExchange exchange) { InetAddress inetAddress = null; SocketAddress address = exchange.getConnection().getPeerAddress(); if (address instanceof InetSocketAddress) { inetAddress = ((InetSocketAddress) address).getAddress(); } RealmIdentityManager.setRequestSpecific(mechanism, inetAddress); }
@Override public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange, SecurityContext context) { Principal user = new RealmUser(ANONYMOUS_USER); Subject subject = new Subject(); subject.getPrincipals().add(user); SocketAddress address = exchange.getConnection().getPeerAddress(); if (address instanceof InetSocketAddress) { subject.getPrincipals().add(new InetAddressPrincipal(((InetSocketAddress) address).getAddress())); } context.authenticationComplete(new RealmIdentityAccount(subject, user), ANONYMOUS_MECH, false); return AuthenticationMechanismOutcome.AUTHENTICATED; }
@Override public boolean parseClientAddress(HttpServerExchange req, Endpoint.Builder builder) { if (super.parseClientAddress(req, builder)) return true; InetSocketAddress addr = (InetSocketAddress) req.getConnection().getPeerAddress(); if (builder.parseIp(addr.getAddress())) { builder.port(addr.getPort()); return true; } return false; } }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { SecurityIdentity securityIdentity = exchange.getAttachment(IDENTITY_KEY); SocketAddress peerSocketAddress = exchange.getConnection().getPeerAddress(); InetAddress remoteAddress = peerSocketAddress instanceof InetSocketAddress ? ((InetSocketAddress) peerSocketAddress).getAddress() : null; try { AccessAuditContext.doAs(securityIdentity, remoteAddress, (PrivilegedExceptionAction<Void>) () -> { wrapped.handleRequest(exchange); return null; }); } catch (PrivilegedActionException e) { throw e.getException(); } }
protected void setRequesterInfo(ALookupRequest lookup, HttpServerExchange exchange) { InetSocketAddress addr = (InetSocketAddress) exchange.getConnection().getPeerAddress(); lookup.setRequester(addr.getAddress().getHostAddress()); String xff = exchange.getRequestHeaders().getFirst("X-Forwarded-For"); log.debug("XFF header: {}", xff); lookup.setRecursive(StringUtils.isBlank(xff)); if (!lookup.isRecursive()) { lookup.setRecurseHosts(Arrays.asList(xff.split(","))); lookup.setRequester(lookup.getRecurseHosts().get(lookup.getRecurseHosts().size() - 1)); } lookup.setUserAgent(exchange.getRequestHeaders().getFirst("User-Agent")); }
jdbcLogAttribute.pattern = pattern; jdbcLogAttribute.remoteHost = ((InetSocketAddress) exchange.getConnection().getPeerAddress()).getAddress().getHostAddress(); SecurityContext sc = exchange.getSecurityContext(); if (sc == null || !sc.isAuthenticated()) {
jdbcLogAttribute.pattern = pattern; jdbcLogAttribute.remoteHost = ((InetSocketAddress) exchange.getConnection().getPeerAddress()).getAddress().getHostAddress(); SecurityContext sc = exchange.getSecurityContext(); if (sc == null || !sc.isAuthenticated()) {
final SocketAddress address = exchange.getConnection().getPeerAddress(); final String remoteHost = (address != null && address instanceof InetSocketAddress) ? ((InetSocketAddress) address).getHostString() : "localhost"; request.putAttachment(ProxiedRequestAttachments.REMOTE_HOST, remoteHost);