/** * Creates a new HttpDigestAuthLogicHandler instance * * @param proxyIoSession The Proxy IoSession * @throws ProxyAuthException The Proxy AuthException */ public HttpDigestAuthLogicHandler(ProxyIoSession proxyIoSession) throws ProxyAuthException { super(proxyIoSession); ((HttpProxyRequest) request).checkRequiredProperties(HttpProxyConstants.USER_PROPERTY, HttpProxyConstants.PWD_PROPERTY); }
StringBuilder sb = new StringBuilder(); sb.append(getHttpVerb()).append(' ').append(getHttpURI()).append(' ').append(getHttpVersion()) .append(HttpProxyConstants.CRLF); if (getHeaders() != null) { for (Map.Entry<String, List<String>> header : getHeaders().entrySet()) { if (!hostHeaderFound) { hostHeaderFound = "host".equalsIgnoreCase(header.getKey()); if (!hostHeaderFound && getHttpVersion() == HttpProxyConstants.HTTP_1_1) { sb.append("Host: ").append(getHost()).append(HttpProxyConstants.CRLF);
Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders() : new HashMap<String, List<String>>(); map.put("username", req.getProperties().get(HttpProxyConstants.USER_PROPERTY)); StringUtilities.copyDirective(directives, map, "realm"); StringUtilities.copyDirective(directives, map, "uri"); map.put("uri", req.getHttpURI()); .getHttpVerb().toUpperCase(), req.getProperties().get(HttpProxyConstants.PWD_PROPERTY), proxyIoSession.getCharsetName(), response.getBody())); req.setHeaders(headers);
/** * {@inheritDoc} */ @Override public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException { logger.debug(" doHandshake()"); if (step > 0) { throw new ProxyAuthException("Authentication request already sent"); } // Send request HttpProxyRequest req = (HttpProxyRequest) request; Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders() : new HashMap<String, List<String>>(); String username = req.getProperties().get(HttpProxyConstants.USER_PROPERTY); String password = req.getProperties().get(HttpProxyConstants.PWD_PROPERTY); StringUtilities.addValueToHeader(headers, "Proxy-Authorization", "Basic " + createAuthorization(username, password), true); addKeepAliveHeaders(headers); req.setHeaders(headers); writeRequest(nextFilter, req); step++; }
private static ProxyRequest createHttpProxyRequest(InetSocketAddress address, String proxyVersion, String proxyUser, String proxyPassword, String proxyDomain, String proxyWorkstation) { HashMap<String, String> props = new HashMap<>(); props.put(HttpProxyConstants.USER_PROPERTY, proxyUser); props.put(HttpProxyConstants.PWD_PROPERTY, proxyPassword); if (proxyDomain != null && proxyWorkstation != null) { props.put(HttpProxyConstants.DOMAIN_PROPERTY, proxyDomain); props.put(HttpProxyConstants.WORKSTATION_PROPERTY, proxyWorkstation); } HttpProxyRequest req = new HttpProxyRequest(address); req.setProperties(props); if (proxyVersion != null && proxyVersion.equalsIgnoreCase("1.1")) { req.setHttpVersion(HttpProxyConstants.HTTP_1_1); } else { req.setHttpVersion(HttpProxyConstants.HTTP_1_0); } return req; }
/** * Performs the handshake processing. * * @param nextFilter the next filter */ @Override public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException { logger.debug(" doHandshake()"); if (authHandler != null) { authHandler.doHandshake(nextFilter); } else { if (requestSent) { // Safety check throw new ProxyAuthException("Authentication request already sent"); } logger.debug(" sending HTTP request"); // Compute request headers HttpProxyRequest req = (HttpProxyRequest) getProxyIoSession().getRequest(); Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders() : new HashMap<String, List<String>>(); AbstractAuthLogicHandler.addKeepAliveHeaders(headers); req.setHeaders(headers); // Write request to the proxy writeRequest(nextFilter, req); requestSent = true; } }
/** * @return the host to which we are connecting. */ public final synchronized String getHost() { if (host == null) { if (getEndpointAddress() != null && !getEndpointAddress().isUnresolved()) { host = getEndpointAddress().getHostName(); } if (host == null && httpURI != null) { try { host = (new URL(httpURI)).getHost(); } catch (MalformedURLException e) { logger.debug("Malformed URL", e); } } } return host; }
StringBuilder sb = new StringBuilder(); sb.append(getHttpVerb()).append(' ').append(getHttpURI()).append(' ').append(getHttpVersion()) .append(HttpProxyConstants.CRLF); if (getHeaders() != null) { for (Map.Entry<String, List<String>> header : getHeaders().entrySet()) { if (!hostHeaderFound) { hostHeaderFound = "host".equalsIgnoreCase(header.getKey()); if (!hostHeaderFound && getHttpVersion() == HttpProxyConstants.HTTP_1_1) { sb.append("Host: ").append(getHost()).append(HttpProxyConstants.CRLF);
Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders() : new HashMap<String, List<String>>(); map.put("username", req.getProperties().get(HttpProxyConstants.USER_PROPERTY)); StringUtilities.copyDirective(directives, map, "realm"); StringUtilities.copyDirective(directives, map, "uri"); map.put("uri", req.getHttpURI()); .getHttpVerb().toUpperCase(), req.getProperties().get(HttpProxyConstants.PWD_PROPERTY), proxyIoSession.getCharsetName(), response.getBody())); req.setHeaders(headers);
/** * {@inheritDoc} */ @Override public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException { logger.debug(" doHandshake()"); if (step > 0) { throw new ProxyAuthException("Authentication request already sent"); } // Send request HttpProxyRequest req = (HttpProxyRequest) request; Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders() : new HashMap<String, List<String>>(); String username = req.getProperties().get(HttpProxyConstants.USER_PROPERTY); String password = req.getProperties().get(HttpProxyConstants.PWD_PROPERTY); StringUtilities.addValueToHeader(headers, "Proxy-Authorization", "Basic " + createAuthorization(username, password), true); addKeepAliveHeaders(headers); req.setHeaders(headers); writeRequest(nextFilter, req); step++; }
private static ProxyRequest createHttpProxyRequest(InetSocketAddress address, String proxyVersion, String proxyUser, String proxyPassword, String proxyDomain, String proxyWorkstation) { HashMap<String, String> props = new HashMap<>(); props.put(HttpProxyConstants.USER_PROPERTY, proxyUser); props.put(HttpProxyConstants.PWD_PROPERTY, proxyPassword); if (proxyDomain != null && proxyWorkstation != null) { props.put(HttpProxyConstants.DOMAIN_PROPERTY, proxyDomain); props.put(HttpProxyConstants.WORKSTATION_PROPERTY, proxyWorkstation); } HttpProxyRequest req = new HttpProxyRequest(address); req.setProperties(props); if (proxyVersion != null && proxyVersion.equalsIgnoreCase("1.1")) { req.setHttpVersion(HttpProxyConstants.HTTP_1_1); } else { req.setHttpVersion(HttpProxyConstants.HTTP_1_0); } return req; }
/** * Performs the handshake processing. * * @param nextFilter the next filter */ @Override public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException { logger.debug(" doHandshake()"); if (authHandler != null) { authHandler.doHandshake(nextFilter); } else { if (requestSent) { // Safety check throw new ProxyAuthException("Authentication request already sent"); } logger.debug(" sending HTTP request"); // Compute request headers HttpProxyRequest req = (HttpProxyRequest) getProxyIoSession().getRequest(); Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders() : new HashMap<String, List<String>>(); AbstractAuthLogicHandler.addKeepAliveHeaders(headers); req.setHeaders(headers); // Write request to the proxy writeRequest(nextFilter, req); requestSent = true; } }
/** * @return the host to which we are connecting. */ public final synchronized String getHost() { if (host == null) { if (getEndpointAddress() != null && !getEndpointAddress().isUnresolved()) { host = getEndpointAddress().getHostName(); } if (host == null && httpURI != null) { try { host = (new URL(httpURI)).getHost(); } catch (MalformedURLException e) { logger.debug("Malformed URL", e); } } } return host; }
StringBuilder sb = new StringBuilder(); sb.append(getHttpVerb()).append(' ').append(getHttpURI()).append(' ') .append(getHttpVersion()).append(HttpProxyConstants.CRLF); if (getHeaders() != null) { for (Map.Entry<String, List<String>> header : getHeaders() .entrySet()) { if (!hostHeaderFound) { && getHttpVersion() == HttpProxyConstants.HTTP_1_1) { sb.append("Host: ").append(getHost()).append( HttpProxyConstants.CRLF);
Map<String, List<String>> headers = req.getHeaders() != null ? req .getHeaders() : new HashMap<>(); map.put("username", req.getProperties().get( HttpProxyConstants.USER_PROPERTY)); StringUtilities.copyDirective(directives, map, "realm"); map.put("uri", req.getHttpURI()); map.put("response", DigestUtilities .computeResponseValue(proxyIoSession.getSession(), map, req.getHttpVerb().toUpperCase(), req.getProperties().get( HttpProxyConstants.PWD_PROPERTY), proxyIoSession.getCharsetName(), response req.setHeaders(headers);
/** * {@inheritDoc} */ @Override public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException { logger.debug(" doHandshake()"); if (step > 0) { throw new ProxyAuthException("Authentication request already sent"); } // Send request HttpProxyRequest req = (HttpProxyRequest) request; Map<String, List<String>> headers = req.getHeaders() != null ? req .getHeaders() : new HashMap<>(); String username = req.getProperties().get( HttpProxyConstants.USER_PROPERTY); String password = req.getProperties().get( HttpProxyConstants.PWD_PROPERTY); StringUtilities.addValueToHeader(headers, "Proxy-Authorization", "Basic " + createAuthorization(username, password), true); addKeepAliveHeaders(headers); req.setHeaders(headers); writeRequest(nextFilter, req); step++; }
private static ProxyRequest createHttpProxyRequest(InetSocketAddress address, String proxyVersion, String proxyUser, String proxyPassword, String proxyDomain, String proxyWorkstation) { HashMap<String, String> props = new HashMap<>(); props.put(HttpProxyConstants.USER_PROPERTY, proxyUser); props.put(HttpProxyConstants.PWD_PROPERTY, proxyPassword); if (proxyDomain != null && proxyWorkstation != null) { props.put(HttpProxyConstants.DOMAIN_PROPERTY, proxyDomain); props.put(HttpProxyConstants.WORKSTATION_PROPERTY, proxyWorkstation); } HttpProxyRequest req = new HttpProxyRequest(address); req.setProperties(props); if (proxyVersion != null && proxyVersion.equalsIgnoreCase("1.1")) { req.setHttpVersion(HttpProxyConstants.HTTP_1_1); } else { req.setHttpVersion(HttpProxyConstants.HTTP_1_0); } return req; }
/** * Performs the handshake processing. * * @param nextFilter the next filter */ public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException { logger.debug(" doHandshake()"); if (authHandler != null) { authHandler.doHandshake(nextFilter); } else { if (requestSent) { // Safety check throw new ProxyAuthException( "Authentication request already sent"); } logger.debug(" sending HTTP request"); // Compute request headers HttpProxyRequest req = (HttpProxyRequest) getProxyIoSession() .getRequest(); Map<String, List<String>> headers = req.getHeaders() != null ? req .getHeaders() : new HashMap<>(); AbstractAuthLogicHandler.addKeepAliveHeaders(headers); req.setHeaders(headers); // Write request to the proxy writeRequest(nextFilter, req); requestSent = true; } }
/** * Build an HttpNTLMAuthLogicHandler * * @param proxyIoSession The original session * @throws ProxyAuthException If we get an error during the proxy authentication */ public HttpNTLMAuthLogicHandler(final ProxyIoSession proxyIoSession) throws ProxyAuthException { super(proxyIoSession); ((HttpProxyRequest) request).checkRequiredProperties(HttpProxyConstants.USER_PROPERTY, HttpProxyConstants.PWD_PROPERTY, HttpProxyConstants.DOMAIN_PROPERTY, HttpProxyConstants.WORKSTATION_PROPERTY); }
/** * Returns the host to which we are connecting. */ public synchronized final String getHost() { if (host == null) { if (getEndpointAddress() != null && !getEndpointAddress().isUnresolved()) { host = getEndpointAddress().getHostName(); } if (host == null && httpURI != null) { try { host = (new URL(httpURI)).getHost(); } catch (MalformedURLException e) { logger.debug("Malformed URL", e); } } } return host; }