当前位置: 首页>>代码示例>>Java>>正文


Java AuthPolicy类代码示例

本文整理汇总了Java中org.apache.http.client.params.AuthPolicy的典型用法代码示例。如果您正苦于以下问题:Java AuthPolicy类的具体用法?Java AuthPolicy怎么用?Java AuthPolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AuthPolicy类属于org.apache.http.client.params包,在下文中一共展示了AuthPolicy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
public static void main(String... args) throws IOException {
    DefaultHttpClient httpclient = new DefaultHttpClient();
    List<String> authpref = new ArrayList<String>();
    authpref.add(AuthPolicy.NTLM);
    httpclient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authpref);
    NTCredentials creds = new NTCredentials("abhisheks", "abhiProJul17", "", "");
    httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
    HttpHost target = new HttpHost("apps.prorigo.com", 80, "http");

    // Make sure the same context is used to execute logically related requests
    HttpContext localContext = new BasicHttpContext();
    // Execute a cheap method first. This will trigger NTLM authentication
    HttpGet httpget = new HttpGet("/conference/Booking");
    HttpResponse response = httpclient.execute(target, httpget, localContext);
    HttpEntity entity = response.getEntity();
    System.out.println(EntityUtils.toString(entity));
}
 
开发者ID:Vedang18,项目名称:ProBOT,代码行数:18,代码来源:ClientAuthentication2.java

示例2: ProxyClient

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
public ProxyClient(final HttpParams params) {
    super();
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    this.httpProcessor = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
            new RequestContent(),
            new RequestTargetHost(),
            new RequestClientConnControl(),
            new RequestUserAgent(),
            new RequestProxyAuthentication()
    } );
    this.requestExec = new HttpRequestExecutor();
    this.proxyAuthStrategy = new ProxyAuthenticationStrategy();
    this.authenticator = new HttpAuthenticator();
    this.proxyAuthState = new AuthState();
    this.authSchemeRegistry = new AuthSchemeRegistry();
    this.authSchemeRegistry.register(AuthPolicy.BASIC, new BasicSchemeFactory());
    this.authSchemeRegistry.register(AuthPolicy.DIGEST, new DigestSchemeFactory());
    this.authSchemeRegistry.register(AuthPolicy.NTLM, new NTLMSchemeFactory());
    this.authSchemeRegistry.register(AuthPolicy.SPNEGO, new SPNegoSchemeFactory());
    this.authSchemeRegistry.register(AuthPolicy.KERBEROS, new KerberosSchemeFactory());
    this.reuseStrategy = new DefaultConnectionReuseStrategy();
    this.params = params;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:ProxyClient.java

示例3: createAuthSchemeRegistry

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
protected AuthSchemeRegistry createAuthSchemeRegistry() {
    AuthSchemeRegistry registry = new AuthSchemeRegistry();
    registry.register(
            AuthPolicy.BASIC,
            new BasicSchemeFactory());
    registry.register(
            AuthPolicy.DIGEST,
            new DigestSchemeFactory());
    registry.register(
            AuthPolicy.NTLM,
            new NTLMSchemeFactory());
    registry.register(
            AuthPolicy.SPNEGO,
            new SPNegoSchemeFactory());
    registry.register(
            AuthPolicy.KERBEROS,
            new KerberosSchemeFactory());
    return registry;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:AbstractHttpClient.java

示例4: getHttpClient

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
private SystemDefaultHttpClient getHttpClient() {
  final SystemDefaultHttpClient httpClient = new SystemDefaultHttpClient();
  httpClient.getAuthSchemes().register(AuthPolicy.SPNEGO, new SPNegoSchemeFactory(true));
   Credentials use_jaas_creds = new Credentials() {
     public String getPassword() {
       return null;
     }

     public Principal getUserPrincipal() {
       return null;
     }
   };

   httpClient.getCredentialsProvider().setCredentials(
     AuthScope.ANY, use_jaas_creds);
   return httpClient;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:AuthenticatorTestCase.java

示例5: getHttpClient

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
private SystemDefaultHttpClient getHttpClient() {
    final SystemDefaultHttpClient httpClient = new SystemDefaultHttpClient();
    httpClient.getAuthSchemes().register(AuthPolicy.SPNEGO, new SPNegoSchemeFactory(true));
    Credentials use_jaas_creds = new Credentials() {
        public String getPassword() {
            return null;
        }

        public Principal getUserPrincipal() {
            return null;
        }
    };

    httpClient.getCredentialsProvider().setCredentials(
            AuthScope.ANY, use_jaas_creds);
    return httpClient;
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:18,代码来源:AuthenticatorTestCase.java

示例6: createAuthSchemeRegistry

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
protected AuthSchemeRegistry createAuthSchemeRegistry() {
    final AuthSchemeRegistry registry = new AuthSchemeRegistry();
    registry.register(
            AuthPolicy.BASIC,
            new BasicSchemeFactory());
    registry.register(
            AuthPolicy.DIGEST,
            new DigestSchemeFactory());
    registry.register(
            AuthPolicy.NTLM,
            new NTLMSchemeFactory());
    registry.register(
            AuthPolicy.SPNEGO,
            new SPNegoSchemeFactory());
    registry.register(
            AuthPolicy.KERBEROS,
            new KerberosSchemeFactory());
    return registry;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:AbstractHttpClient.java

示例7: _createTwilioRESTClient

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
@SuppressWarnings({ "resource"})
private TwilioRestClient _createTwilioRESTClient() {
       TwilioRestClient outClient = new TwilioRestClient(_apiData.getAccountSID().asString(),
       											      _apiData.getAccountToken().asString());
	if (_proxySettings != null && _proxySettings.isEnabled()) {
		UrlComponents proxyUrlComps = _proxySettings.getProxyUrl().getComponents();
		log.info("Connecting to twilio through {}:{}",proxyUrlComps.getHost(), 
													  proxyUrlComps.getPort());
		// Get the twilio api underlying http client
		DefaultHttpClient httpClient = (DefaultHttpClient)outClient.getHttpClient();
		
		// Set proxy details
		HttpHost proxy = new HttpHost(proxyUrlComps.getHost().asString(),proxyUrlComps.getPort(),
									  "http");
		httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
											proxy);
		httpClient.getCredentialsProvider().setCredentials(new AuthScope(proxyUrlComps.getHost().asString(), 
														 				 proxyUrlComps.getPort()),
														   new UsernamePasswordCredentials(_proxySettings.getUserCode().asString(),
																   						   _proxySettings.getPassword().asString()));
		httpClient.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF,
											Lists.newArrayList(AuthPolicy.BASIC));
											
	} 
	return outClient;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:27,代码来源:TwilioService.java

示例8: setUp

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
    if (getDataService() == null || getDataServiceForFilteredEntity() == null) {
        clearEntities();
        prepareEntity();
        prepareFilteredEntity();

        SchemaHolder schemaHolder = entityService.getSchema();
        jarGeneratorService.regenerateMdsDataBundle(schemaHolder);
    }

    getDataService().deleteAll();
    getDataServiceForFilteredEntity().deleteAll();

    if (!userService.hasActiveMotechAdmin()) {
        userService.registerMotechAdmin("motech", "motech", "[email protected]", Locale.ENGLISH);
    }

    getHttpClient().getCredentialsProvider().setCredentials(
            new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, AuthPolicy.BASIC),
            new UsernamePasswordCredentials("motech", "motech")
    );
}
 
开发者ID:motech,项目名称:motech,代码行数:24,代码来源:MdsRestBundleIT.java

示例9: isCachable

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
private boolean isCachable(final AuthState authState) {
    AuthScheme authScheme = authState.getAuthScheme();
    if (authScheme == null || !authScheme.isComplete()) {
        return false;
    }
    String schemeName = authScheme.getSchemeName();
    return schemeName.equalsIgnoreCase(AuthPolicy.BASIC) ||
            schemeName.equalsIgnoreCase(AuthPolicy.DIGEST);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:ResponseAuthCache.java

示例10: isCachable

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
private boolean isCachable(final AuthScheme authScheme) {
    if (authScheme == null || !authScheme.isComplete()) {
        return false;
    }
    String schemeName = authScheme.getSchemeName();
    return schemeName.equalsIgnoreCase(AuthPolicy.BASIC) ||
            schemeName.equalsIgnoreCase(AuthPolicy.DIGEST);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:AuthenticationStrategyAdaptor.java

示例11: isCachable

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
protected boolean isCachable(final AuthScheme authScheme) {
    if (authScheme == null || !authScheme.isComplete()) {
        return false;
    }
    String schemeName = authScheme.getSchemeName();
    return schemeName.equalsIgnoreCase(AuthPolicy.BASIC) ||
            schemeName.equalsIgnoreCase(AuthPolicy.DIGEST);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:AuthenticationStrategyImpl.java

示例12: isCachable

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
private boolean isCachable(final AuthState authState) {
    final AuthScheme authScheme = authState.getAuthScheme();
    if (authScheme == null || !authScheme.isComplete()) {
        return false;
    }
    final String schemeName = authScheme.getSchemeName();
    return schemeName.equalsIgnoreCase(AuthPolicy.BASIC) ||
            schemeName.equalsIgnoreCase(AuthPolicy.DIGEST);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:10,代码来源:ResponseAuthCache.java

示例13: isCachable

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
private boolean isCachable(final AuthScheme authScheme) {
    if (authScheme == null || !authScheme.isComplete()) {
        return false;
    }
    final String schemeName = authScheme.getSchemeName();
    return schemeName.equalsIgnoreCase(AuthPolicy.BASIC) ||
            schemeName.equalsIgnoreCase(AuthPolicy.DIGEST);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:9,代码来源:AuthenticationStrategyAdaptor.java

示例14: HttpClientForProxy

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
/**
 * 認証プロキシを通過するためのHttpClient。
 */
public HttpClientForProxy() {
    super();
    String proxyUser = System.getProperty("http.proxyUser");
    if (proxyUser != null) {
        String proxyHost = System.getProperty("http.proxyHost");
        String proxyPortStr = System.getProperty("http.proxyPort");
        int proxyPort = 0;
        if (proxyPortStr != null) {
            proxyPort = Integer.parseInt(proxyPortStr);
        }
        String proxyPassword = System.getProperty("http.proxyPassword");
        List<String> authpref = new ArrayList<String>();
        authpref.add(AuthPolicy.BASIC);
        this.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref);
        CredentialsProvider credsProvider = this.getCredentialsProvider();
        credsProvider.setCredentials(new AuthScope(proxyHost, proxyPort), new UsernamePasswordCredentials(
                        proxyUser, proxyPassword));
        this.setCredentialsProvider(credsProvider);
        String protocol = "";
        if (proxyHost.indexOf("https") != 0) {
            protocol = "http";
        } else {
            protocol = "https";
        }
        HttpHost proxy = new HttpHost(proxyHost, proxyPort, protocol);
        this.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
    }
}
 
开发者ID:codefornamie,项目名称:namie-crawler,代码行数:32,代码来源:HttpClientForProxy.java

示例15: useCredentials

import org.apache.http.client.params.AuthPolicy; //导入依赖的package包/类
private void useCredentials(DefaultHttpClient httpClient, PasswordCredentials credentials, String host, int port) {
    Credentials basicCredentials = new UsernamePasswordCredentials(credentials.getUsername(), credentials.getPassword());
    httpClient.getCredentialsProvider().setCredentials(new AuthScope(host, port), basicCredentials);

    NTLMCredentials ntlmCredentials = new NTLMCredentials(credentials);
    Credentials ntCredentials = new NTCredentials(ntlmCredentials.getUsername(), ntlmCredentials.getPassword(), ntlmCredentials.getWorkstation(), ntlmCredentials.getDomain());
    httpClient.getCredentialsProvider().setCredentials(new AuthScope(host, port, AuthScope.ANY_REALM, AuthPolicy.NTLM), ntCredentials);

    LOGGER.debug("Using {} and {} for authenticating against '{}:{}'", new Object[]{credentials, ntlmCredentials, host, port});
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:11,代码来源:HttpClientConfigurer.java


注:本文中的org.apache.http.client.params.AuthPolicy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。