List of usage examples for org.apache.http.impl.auth NTLMScheme NTLMScheme
public NTLMScheme(final NTLMEngine engine)
From source file:com.anaplan.client.transport.ApacheHttpProvider.java
protected ApacheHttpProvider() { super();// w ww . j a v a 2 s . c om httpClient = new DefaultHttpClient(); httpClient.getParams().setParameter(ClientPNames.HANDLE_AUTHENTICATION, Boolean.TRUE); httpClient.setCredentialsProvider(new ApacheCredentialsProvider()); try { Class<?> engineClass = Class.forName("com.anaplan.client.transport.JCIFSEngine"); final NTLMEngine ntlmEngine = (NTLMEngine) engineClass.newInstance(); httpClient.getAuthSchemes().register("ntlm", new AuthSchemeFactory() { public AuthScheme newInstance(final HttpParams params) { return new NTLMScheme(ntlmEngine); } }); } catch (InstantiationException instantiationException) { // Normal - the jcifs jar file is not present in the lib folder. } catch (Throwable thrown) { // Abnormal thrown.printStackTrace(); } routePlanner = new ProxySelectorRoutePlanner(httpClient.getConnectionManager().getSchemeRegistry(), getProxySelector()) { private boolean suppressed; @Override public HttpRoute determineRoute(HttpHost target, HttpRequest request, HttpContext context) throws HttpException { HttpRoute httpRoute = super.determineRoute(target, request, context); if (getDebugLevel() >= 1 && !suppressed) { System.err.println( httpRoute.toString() + " (" + getProxySelector().getClass().getSimpleName() + ")"); if (getDebugLevel() == 1) suppressed = true; } return httpRoute; } }; httpClient.setRoutePlanner(routePlanner); }
From source file:org.codelibs.fess.es.config.exentity.DataConfig.java
private AuthScheme getAuthScheme(final Map<String, String> paramMap, final String webAuthName, final String scheme) { AuthScheme authScheme = null;//from w w w .j av a 2s . co m if (Constants.BASIC.equals(scheme)) { authScheme = new BasicScheme(); } else if (Constants.DIGEST.equals(scheme)) { authScheme = new DigestScheme(); } else if (Constants.NTLM.equals(scheme)) { final Properties props = new Properties(); paramMap.entrySet().stream().filter(e -> e.getKey().startsWith("jcifs.")).forEach(e -> { props.setProperty(e.getKey(), e.getValue()); }); authScheme = new NTLMScheme(new JcifsEngine(props)); } else if (Constants.FORM.equals(scheme)) { final String prefix = CRAWLER_WEB_AUTH + "." + webAuthName + "."; final Map<String, String> parameterMap = paramMap.entrySet().stream() .filter(e -> e.getKey().startsWith(prefix)) .collect(Collectors.toMap(e -> e.getKey().substring(prefix.length()), e -> e.getValue())); authScheme = new FormScheme(parameterMap); } return authScheme; }