本文整理汇总了Java中org.apache.http.impl.client.SystemDefaultCredentialsProvider类的典型用法代码示例。如果您正苦于以下问题:Java SystemDefaultCredentialsProvider类的具体用法?Java SystemDefaultCredentialsProvider怎么用?Java SystemDefaultCredentialsProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SystemDefaultCredentialsProvider类属于org.apache.http.impl.client包,在下文中一共展示了SystemDefaultCredentialsProvider类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createContextForServer
import org.apache.http.impl.client.SystemDefaultCredentialsProvider; //导入依赖的package包/类
private HttpContext createContextForServer(ServerInfo serverInfo)
{
HttpContext httpContext = null;
if (serverInfo.credentials != null || serverInfo.ntCredentials != null)
{
HttpClientContext context = HttpClientContext.create();
CredentialsProvider credsProvider = (useBuiltinWindowsAuthentication(serverInfo)) ? credsProvider = new WindowsCredentialsProvider(new SystemDefaultCredentialsProvider()) :
new HttpClientCredentialsProvider(serverInfo.credentials, serverInfo.ntCredentials);
if (serverInfo.credentials != null)
{
credsProvider.setCredentials(serverInfo.authscope, serverInfo.credentials);
}
if (serverInfo.ntCredentials != null)
{
credsProvider.setCredentials(serverInfo.authscope, serverInfo.ntCredentials);
}
context.setCredentialsProvider(credsProvider);
httpContext = context;
}
return httpContext;
}
开发者ID:Esri,项目名称:geoevent-datastore-proxy,代码行数:22,代码来源:GeoEventDataStoreProxy.java
示例2: configure
import org.apache.http.impl.client.SystemDefaultCredentialsProvider; //导入依赖的package包/类
public void configure(HttpClientBuilder builder) {
SystemDefaultCredentialsProvider credentialsProvider = new SystemDefaultCredentialsProvider();
configureSslSocketConnectionFactory(builder, httpSettings.getSslContextFactory());
configureAuthSchemeRegistry(builder);
configureCredentials(builder, credentialsProvider, httpSettings.getAuthenticationSettings());
configureProxy(builder, credentialsProvider, httpSettings);
configureUserAgent(builder);
builder.setDefaultCredentialsProvider(credentialsProvider);
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:HttpClientConfigurer.java
示例3: timeout
import org.apache.http.impl.client.SystemDefaultCredentialsProvider; //导入依赖的package包/类
@Test(timeout=30000) // this timeout (in ms) needs to be extended if you're actively debugging the code
public void testNoInfiniteLoopOnSPNOutsideDomain() throws Exception {
Assume.assumeTrue("Test can only be run on Windows", WinHttpClients.isWinAuthAvailable());
// HTTPCLIENT-1545
// If a service principal name (SPN) from outside your Windows domain tree (e.g., HTTP/example.com) is used,
// InitializeSecurityContext will return SEC_E_DOWNGRADE_DETECTED (decimal: -2146892976, hex: 0x80090350).
// Because WindowsNegotiateScheme wasn't setting the completed state correctly when authentication fails,
// HttpClient goes into an infinite loop, constantly retrying the negotiate authentication to kingdom
// come. This error message, "The system detected a possible attempt to compromise security. Please ensure that
// you can contact the server that authenticated you." is associated with SEC_E_DOWNGRADE_DETECTED.
final Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
.register(AuthSchemes.SPNEGO, new AuthSchemeProvider() {
@Override
public AuthScheme create(final HttpContext context) {
return new WindowsNegotiateSchemeGetTokenFail(AuthSchemes.SPNEGO, "HTTP/example.com");
}
}).build();
final CredentialsProvider credsProvider =
new WindowsCredentialsProvider(new SystemDefaultCredentialsProvider());
final CloseableHttpClient customClient = HttpClientBuilder.create()
.setDefaultCredentialsProvider(credsProvider)
.setDefaultAuthSchemeRegistry(authSchemeRegistry).build();
final HttpHost target = start();
final HttpGet httpGet = new HttpGet("/");
final CloseableHttpResponse response = customClient.execute(target, httpGet);
try {
EntityUtils.consume(response.getEntity());
} finally {
response.close();
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:35,代码来源:TestWindowsNegotiateScheme.java
示例4: internalCreateSSOContext
import org.apache.http.impl.client.SystemDefaultCredentialsProvider; //导入依赖的package包/类
private static HttpClientContext internalCreateSSOContext() {
if (log.isDebugEnabled()) log.debug("internalCreateSSOContext(");
//System.setProperty("java.security.krb5.conf", "C:\\Windows\\krb5.ini");
//System.setProperty("sun.security.krb5.debug", "true");
System.setProperty("javax.security.auth.useSubjectCredsOnly","false");
HttpClientContext context = HttpClientContext.create();
if (isNTLMAuthenticationEnabled()) {
if (log.isDebugEnabled()) log.debug("set WindowsCredentialsProvider");
final CredentialsProvider credsProvider = new WindowsCredentialsProvider(new SystemDefaultCredentialsProvider());
context.setCredentialsProvider(credsProvider);
}
else {
if (log.isDebugEnabled()) log.debug("set JAAS credential provider");
// This may seem odd, but specifying 'null' as principal tells java to use the logged in user's credentials
Credentials useJaasCreds = new Credentials() {
public String getPassword() { return null; }
public Principal getUserPrincipal() { return null; }
};
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials( new AuthScope(null, -1, null), useJaasCreds );
context.setCredentialsProvider(credentialsProvider);
}
if (log.isDebugEnabled()) log.debug(")internalCreateSSOContext");
return context;
}
开发者ID:wolfgangimig,项目名称:byps,代码行数:34,代码来源:AsfClient.java
注:本文中的org.apache.http.impl.client.SystemDefaultCredentialsProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论