private void addHttpAuth(Settings settings, SecureSettings secureSettings, Object[] authSettings) { if (StringUtils.hasText(settings.getNetworkHttpAuthUser())) { HttpState state = (authSettings[1] != null ? (HttpState) authSettings[1] : new HttpState()); authSettings[1] = state; state.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getNetworkHttpAuthUser(), secureSettings.getSecureProperty(ConfigurationOptions.ES_NET_HTTP_AUTH_PASS))); if (log.isDebugEnabled()) { log.info("Using detected HTTP Auth credentials..."); } } }
log.warn(String.format("HTTPS proxy user specified but no/empty password defined - double check the [%s] property", ConfigurationOptions.ES_NET_PROXY_HTTPS_PASS)); HttpState state = new HttpState(); state.setProxyCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getNetworkProxyHttpsUser(), secureSettings.getSecureProperty(ConfigurationOptions.ES_NET_PROXY_HTTPS_PASS))); log.warn(String.format("HTTP proxy user specified but no/empty password defined - double check the [%s] property", ConfigurationOptions.ES_NET_PROXY_HTTP_PASS)); HttpState state = new HttpState(); state.setProxyCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getNetworkProxyHttpUser(), secureSettings.getSecureProperty(ConfigurationOptions.ES_NET_PROXY_HTTP_PASS)));
state = new HttpState(); client.setState(state);
state = new HttpState(); client.setState(state);
/** * Create a new instance with a default instance of an Apache HTTP state. */ public ApacheHttpClientState() { this(new HttpState()); }
private void setHttpStateEnabledImpl(boolean httpStateEnabled) { this.httpStateEnabled = httpStateEnabled; if (this.httpStateEnabled) { httpState = new HttpState(); } else { httpState = null; } }
public HttpAuthSession() { super("Http Auth Session " + generatedNameIndex++, new HttpState()); } }
public CookieBasedSession() { super("Cookie Based Session " + generatedNameIndex++, new HttpState()); }
HttpClient client = new HttpClient(); HttpMethod method = new PostMethod(url.toURI()); HttpState state = new HttpState(); client.executeMethod(HttpConfiguration.ANY_HOST_CONFIGURATION, method, state);
/** * Resets the http client state between requests, * this is not necessarily required but might be a good idea */ public void resetState() { if (initialHttpState != null) { httpClient.setState(initialHttpState); } else { httpClient.setState( new HttpState() ); } } /**
@Override public void activateObject(final PooledObject<ServiceClient> pooledServiceClient) throws Exception { final ServiceClient serviceClient = pooledServiceClient.getObject(); // to avoid overriding settings that could impact other calls to this service client // we extend the option and will restore them after final Options originalOptions = serviceClient.getOptions(); final Options options = new Options(originalOptions); options.setProperty(ORIGINAL_OPTIONS_TO_RESTORE_ON_RETURN, originalOptions); // HttpClient is cached (in ServiceClientPoolObjectFactory.createOptions()) so we need to // add our own HttpState so that the one from HttpClient is not reused!! options.setProperty(HTTPConstants.CACHED_HTTP_STATE, new HttpState()); serviceClient.setOptions(options); }
HttpState state = new HttpState(); state.addCookie(new Cookie(".example.com", "name", "value")); HttpClient client = new HttpClient(); client.setState(state); // ...
protected void fireEvent(EventMethod eventMethod, Credentials credentials) throws IOException { eventMethod.setDoAuthentication(true); HttpState httpState = new HttpState(); httpState.setCredentials(null, repositoryHost, credentials); int state = eventMethod.execute(httpState, new HttpConnection(repositoryHost, repositoryPort, protocol)); if ( state == HttpStatus.SC_OK ) { } else { logger.log(Level.SEVERE, "Event failed. State: "+state); } }
private void addHttpAuth(Settings settings, SecureSettings secureSettings, Object[] authSettings) { if (StringUtils.hasText(settings.getNetworkHttpAuthUser())) { HttpState state = (authSettings[1] != null ? (HttpState) authSettings[1] : new HttpState()); authSettings[1] = state; state.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getNetworkHttpAuthUser(), secureSettings.getSecureProperty(ConfigurationOptions.ES_NET_HTTP_AUTH_PASS))); if (log.isDebugEnabled()) { log.info("Using detected HTTP Auth credentials..."); } } }
private void addHttpAuth(Settings settings, SecureSettings secureSettings, Object[] authSettings) { if (StringUtils.hasText(settings.getNetworkHttpAuthUser())) { HttpState state = (authSettings[1] != null ? (HttpState) authSettings[1] : new HttpState()); authSettings[1] = state; state.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getNetworkHttpAuthUser(), secureSettings.getSecureProperty(ConfigurationOptions.ES_NET_HTTP_AUTH_PASS))); if (log.isDebugEnabled()) { log.info("Using detected HTTP Auth credentials..."); } } }
private void addHttpAuth(Settings settings, Object[] authSettings) { if (StringUtils.hasText(settings.getNetworkHttpAuthUser())) { HttpState state = (authSettings[1] != null ? (HttpState) authSettings[1] : new HttpState()); authSettings[1] = state; state.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getNetworkHttpAuthUser(), settings.getNetworkHttpAuthPass())); if (log.isDebugEnabled()) { log.info("Using detected HTTP Auth credentials..."); } } }
private void addHttpAuth(Settings settings, SecureSettings secureSettings, Object[] authSettings) { if (StringUtils.hasText(settings.getNetworkHttpAuthUser())) { HttpState state = (authSettings[1] != null ? (HttpState) authSettings[1] : new HttpState()); authSettings[1] = state; state.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getNetworkHttpAuthUser(), secureSettings.getSecureProperty(ConfigurationOptions.ES_NET_HTTP_AUTH_PASS))); if (log.isDebugEnabled()) { log.info("Using detected HTTP Auth credentials..."); } } }
HttpClient http = new HttpClient(); http.setParams(new HttpClientParams()); http.setState(new HttpState()); //For Get GetMethod get = new GetMethod("http://www.something.com/myscript?param="+paramVar); http.executeMethod(get); // For Post PostMethod post = new PostMethod("http://www.something.com/myscript"); post.addParameter("param", paramVar); http.executeMethod(post);
@Override public void sessionChanged(Session session) { getModel().getOptionsParam().getConnectionParam().setHttpState(new HttpState()); }
public HttpState getHttpState() { HttpState state = (HttpState) ((HttpChannel) getMessage().getChannel()).getProperty(HTTP_STATE); if (state == null) { state = new HttpState(); ((HttpChannel) getMessage().getChannel()).setProperty(HTTP_STATE, state); } return state; }