本文整理汇总了Java中org.apache.http.impl.auth.NTLMScheme类的典型用法代码示例。如果您正苦于以下问题:Java NTLMScheme类的具体用法?Java NTLMScheme怎么用?Java NTLMScheme使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NTLMScheme类属于org.apache.http.impl.auth包,在下文中一共展示了NTLMScheme类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testStoreNonserializable
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
@Test
public void testStoreNonserializable() throws Exception {
final BasicAuthCache cache = new BasicAuthCache();
final AuthScheme authScheme = new NTLMScheme();
cache.put(new HttpHost("localhost", 80), authScheme);
Assert.assertNull(cache.get(new HttpHost("localhost", 80)));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:8,代码来源:TestBasicAuthCache.java
示例2: process
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
CredentialsProvider credentialsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
// If not auth scheme has been initialized yet
if (authState.getAuthScheme() == null) {
AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
// Obtain credentials matching the target host
Credentials credentials = credentialsProvider.getCredentials(authScope);
// If found, generate BasicScheme preemptively
if (credentials != null) {
authState.setAuthScheme(credentials instanceof NTCredentials ? new NTLMScheme(new JCIFSEngine()) : new BasicScheme());
authState.setCredentials(credentials);
}
}
}
开发者ID:evlist,项目名称:orbeon-forms,代码行数:18,代码来源:PreemptiveAuthHttpRequestInterceptor.java
示例3: invalidAuthSchemeWithUserAndPass
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
/**
* Make sure the plugin rejects an invalid authentication scheme if
* username and password are set
* @throws Exception if anything goes wrong
*/
@Test(expected = TaskExecutionException.class)
public void invalidAuthSchemeWithUserAndPass() throws Exception {
Download t = makeProjectAndTask();
t.src(makeSrc(AUTHENTICATE));
File dst = folder.newFile();
t.dest(dst);
t.username(USERNAME);
t.password(PASSWORD);
t.authScheme(new NTLMScheme());
t.execute();
}
开发者ID:michel-kraemer,项目名称:gradle-download-task,代码行数:17,代码来源:AuthenticationTest.java
示例4: create
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
@Override
public AuthScheme create(HttpContext context) {
return new NTLMScheme(new JCIFSEngine());
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:5,代码来源:NTLMSchemeFactory.java
示例5: testExecEntityEnclosingRequestRetryOnAuthChallenge
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
@Test
public void testExecEntityEnclosingRequestRetryOnAuthChallenge() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
final HttpResponse response1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 401, "Huh?");
final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
response1.setEntity(EntityBuilder.create()
.setStream(instream1)
.build());
final HttpResponse response2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
final InputStream instream2 = Mockito.spy(new ByteArrayInputStream(new byte[] {2, 3, 4}));
response2.setEntity(EntityBuilder.create()
.setStream(instream2)
.build());
final AuthState proxyAuthState = new AuthState();
proxyAuthState.setState(AuthProtocolState.SUCCESS);
proxyAuthState.update(new NTLMScheme(), new NTCredentials("user:pass"));
final HttpClientContext context = new HttpClientContext();
context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, proxyAuthState);
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
Mockito.when(managedConn.isStale()).thenReturn(Boolean.FALSE);
Mockito.when(requestExecutor.execute(
Mockito.same(request),
Mockito.<HttpClientConnection>any(),
Mockito.<HttpClientContext>any())).thenReturn(response1, response2);
Mockito.when(reuseStrategy.keepAlive(
Mockito.<HttpResponse>any(),
Mockito.<HttpClientContext>any())).thenReturn(Boolean.FALSE);
Mockito.when(targetAuthStrategy.isAuthenticationRequested(
Mockito.eq(target),
Mockito.same(response1),
Mockito.<HttpClientContext>any())).thenReturn(Boolean.TRUE);
final CloseableHttpResponse finalResponse = mainClientExec.execute(
route, request, context, execAware);
Mockito.verify(requestExecutor, Mockito.times(2)).execute(request, managedConn, context);
Mockito.verify(managedConn).close();
Mockito.verify(instream2, Mockito.never()).close();
Assert.assertNotNull(finalResponse);
Assert.assertEquals(200, finalResponse.getStatusLine().getStatusCode());
Assert.assertNull(proxyAuthState.getAuthScheme());
Assert.assertNull(proxyAuthState.getCredentials());
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:48,代码来源:TestMainClientExec.java
示例6: testCrossSiteRedirect
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
@Test
public void testCrossSiteRedirect() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpGet get = new HttpGet("/test");
final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
final HttpClientContext context = HttpClientContext.create();
final AuthState targetAuthState = new AuthState();
targetAuthState.setState(AuthProtocolState.SUCCESS);
targetAuthState.update(new BasicScheme(), new UsernamePasswordCredentials("user", "pass"));
final AuthState proxyAuthState = new AuthState();
proxyAuthState.setState(AuthProtocolState.SUCCESS);
proxyAuthState.update(new NTLMScheme(), new NTCredentials("user", "pass", null, null));
context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, targetAuthState);
context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, proxyAuthState);
final CloseableHttpResponse response1 = Mockito.mock(CloseableHttpResponse.class);
final CloseableHttpResponse response2 = Mockito.mock(CloseableHttpResponse.class);
final HttpGet redirect = new HttpGet("http://otherhost/redirect");
Mockito.when(requestExecutor.execute(
Mockito.eq(route),
Mockito.same(request),
Mockito.<HttpClientContext>any(),
Mockito.<HttpExecutionAware>any())).thenReturn(response1);
Mockito.when(requestExecutor.execute(
Mockito.eq(route),
HttpRequestWrapperMatcher.same(redirect),
Mockito.<HttpClientContext>any(),
Mockito.<HttpExecutionAware>any())).thenReturn(response2);
Mockito.when(redirectStrategy.isRedirected(
Mockito.same(get),
Mockito.same(response1),
Mockito.<HttpClientContext>any())).thenReturn(Boolean.TRUE);
Mockito.when(redirectStrategy.getRedirect(
Mockito.same(get),
Mockito.same(response1),
Mockito.<HttpClientContext>any())).thenReturn(redirect);
Mockito.when(httpRoutePlanner.determineRoute(
Mockito.eq(target),
Mockito.<HttpRequestWrapper>any(),
Mockito.<HttpClientContext>any())).thenReturn(new HttpRoute(new HttpHost("otherhost", 80)));
redirectExec.execute(route, request, context, execAware);
Assert.assertNotNull(context.getTargetAuthState());
Assert.assertEquals(AuthProtocolState.UNCHALLENGED, context.getTargetAuthState().getState());
Assert.assertEquals(null, context.getTargetAuthState().getAuthScheme());
Assert.assertNotNull(context.getProxyAuthState());
Assert.assertEquals(AuthProtocolState.UNCHALLENGED, context.getProxyAuthState().getState());
Assert.assertEquals(null, context.getProxyAuthState().getAuthScheme());
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:52,代码来源:TestRedirectExec.java
示例7: newInstance
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
public AuthScheme newInstance(HttpParams params) {
return new NTLMScheme(new JCIFSEngine());
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:4,代码来源:NTLMSchemeFactory.java
示例8: newInstance
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
@Override
public AuthScheme newInstance(final HttpParams params) {
return new NTLMScheme(new JCIFSEngine());
}
开发者ID:brunocvcunha,项目名称:taskerbox,代码行数:5,代码来源:NTLMSchemeFactory.java
示例9: create
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
@Override
public AuthScheme create(HttpContext httpContext) {
return new NTLMScheme(new JCIFSEngine());
}
开发者ID:integram,项目名称:cleverbus,代码行数:5,代码来源:NTLMSchemeFactory.java
示例10: create
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
public AuthScheme create(HttpContext context) {
return new NTLMScheme(new SSONTLMEngine());
}
开发者ID:wdekker,项目名称:jntlm,代码行数:4,代码来源:NTLMSchemeProvider.java
示例11: newInstance
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
public AuthScheme newInstance(final HttpParams params) {
return new NTLMScheme(new JCIFSEngine());
}
开发者ID:ibissource,项目名称:iaf,代码行数:4,代码来源:WebServiceNtlmSender.java
示例12: create
import org.apache.http.impl.auth.NTLMScheme; //导入依赖的package包/类
@Override
public AuthScheme create(final HttpContext context) {
return new NTLMScheme(new JCIFSEngine());
}
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:5,代码来源:NTLMSchemeFactory.java
注:本文中的org.apache.http.impl.auth.NTLMScheme类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论