• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DefaultHttpParams类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

import org.apache.commons.httpclient.params.DefaultHttpParams; //导入依赖的package包/类
public static void main(String[] args) {
    
    // register the auth scheme
    AuthPolicy.registerAuthScheme(SecretAuthScheme.NAME, SecretAuthScheme.class);

    // include the scheme in the AuthPolicy.AUTH_SCHEME_PRIORITY preference,
    // this can be done on a per-client or per-method basis but we'll do it
    // globally for this example
    HttpParams params = DefaultHttpParams.getDefaultParams();        
    ArrayList schemes = new ArrayList();
    schemes.add(SecretAuthScheme.NAME);
    schemes.addAll((Collection) params.getParameter(AuthPolicy.AUTH_SCHEME_PRIORITY));
    params.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, schemes);
    
    // now that our scheme has been registered we can execute methods against
    // servers that require "Secret" authentication... 
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:18,代码来源:CustomAuthenticationExample.java


示例2: testChallengeSelection

import org.apache.commons.httpclient.params.DefaultHttpParams; //导入依赖的package包/类
public void testChallengeSelection() throws Exception {
    List authPrefs = new ArrayList(3);
    authPrefs.add(AuthPolicy.NTLM);
    authPrefs.add(AuthPolicy.DIGEST);
    authPrefs.add(AuthPolicy.BASIC);
    HttpParams httpparams = new DefaultHttpParams(); 
    httpparams.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
    
    AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);

    Map map = new HashMap(); 
    map.put("unknown", "unknown realm=\"whatever\"");
    map.put("basic", "basic realm=\"whatever\"");
    
    AuthScheme authscheme = processor.selectAuthScheme(map);
    assertTrue(authscheme instanceof BasicScheme);
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:18,代码来源:TestChallengeProcessor.java


示例3: testInvalidChallenge

import org.apache.commons.httpclient.params.DefaultHttpParams; //导入依赖的package包/类
public void testInvalidChallenge() throws Exception {
    List authPrefs = new ArrayList(3);
    authPrefs.add("unsupported1");
    authPrefs.add("unsupported2");
    HttpParams httpparams = new DefaultHttpParams(); 
    httpparams.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
    
    AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);

    Map map = new HashMap(); 
    map.put("unsupported1", "unsupported1 realm=\"whatever\"");
    map.put("unsupported2", "unsupported2 realm=\"whatever\"");
    try {
        AuthScheme authscheme = processor.selectAuthScheme(map);
        fail("AuthChallengeException should have been thrown");
    } catch (AuthChallengeException e) {
        //ignore
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:20,代码来源:TestChallengeProcessor.java


示例4: testUnsupportedChallenge

import org.apache.commons.httpclient.params.DefaultHttpParams; //导入依赖的package包/类
public void testUnsupportedChallenge() throws Exception {
    List authPrefs = new ArrayList(3);
    authPrefs.add(AuthPolicy.NTLM);
    authPrefs.add(AuthPolicy.BASIC);
    authPrefs.add(AuthPolicy.DIGEST);
    HttpParams httpparams = new DefaultHttpParams(); 
    httpparams.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
    
    AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);

    Map map = new HashMap(); 
    map.put("unsupported1", "unsupported1 realm=\"whatever\"");
    map.put("unsupported2", "unsupported2 realm=\"whatever\"");
    
    try {
        AuthScheme authscheme = processor.selectAuthScheme(map);
        fail("AuthChallengeException should have been thrown");
    } catch (AuthChallengeException e) {
        //expected
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:22,代码来源:TestChallengeProcessor.java


示例5: testInvalidChallengeProcessing

import org.apache.commons.httpclient.params.DefaultHttpParams; //导入依赖的package包/类
public void testInvalidChallengeProcessing() throws Exception {
    HttpParams httpparams = new DefaultHttpParams(); 
    AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);

    Map map = new HashMap(); 
    map.put("basic", "basic realm=\"whatever\", param=\"value\"");
    
    AuthState authstate = new AuthState();
    
    AuthScheme authscheme = processor.processChallenge(authstate, map);
    assertTrue(authscheme instanceof BasicScheme);
    assertEquals("whatever", authscheme.getRealm());
    assertEquals(authscheme, authstate.getAuthScheme());
    assertEquals("value", authscheme.getParameter("param"));

    Map map2 = new HashMap(); 
    map2.put("ntlm", "NTLM");
    try {
        // Basic authentication scheme expected
        authscheme = processor.processChallenge(authstate, map2);
        fail("AuthenticationException should have been thrown");
    } catch (AuthenticationException e) {
        //expected
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:26,代码来源:TestChallengeProcessor.java


示例6: enableAuth

import org.apache.commons.httpclient.params.DefaultHttpParams; //导入依赖的package包/类
public static void enableAuth(HttpClient client, Keychain keychain, KeyId keyId) {
    Signer signer = new Signer(keychain, keyId);
    CredentialsProvider credProvider =
        (CredentialsProvider) client.getParams()
                .getParameter(CredentialsProvider.PROVIDER);

    CredentialsProvider newProvider;
    if (credProvider instanceof SignerCredentialsProvider) {
        newProvider = new SignerCredentialsProvider(signer,
                                                    ((SignerCredentialsProvider) credProvider).getDelegatee());
    } else {
        newProvider = new SignerCredentialsProvider(signer, credProvider);
    }

    client.getParams().setParameter(CredentialsProvider.PROVIDER, newProvider);
    AuthPolicy.registerAuthScheme(Constants.SCHEME, Http3SignatureAuthScheme.class);
    List<String> schemes = new ArrayList<String>();
    schemes.add(Constants.SCHEME);

    Collection authSchemePriority = (Collection) DefaultHttpParams.getDefaultParams().getParameter(AuthPolicy.AUTH_SCHEME_PRIORITY);
    if (authSchemePriority != null) {
        schemes.addAll(authSchemePriority);
    }
    client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, schemes);
}
 
开发者ID:adamcin,项目名称:httpsig-java,代码行数:26,代码来源:Http3Util.java


示例7: init

import org.apache.commons.httpclient.params.DefaultHttpParams; //导入依赖的package包/类
public void init()
{
    this.sslKeyStore = new AlfrescoKeyStoreImpl(sslEncryptionParameters.getKeyStoreParameters(),  keyResourceLoader);
    this.sslTrustStore = new AlfrescoKeyStoreImpl(sslEncryptionParameters.getTrustStoreParameters(), keyResourceLoader);
    this.sslSocketFactory = new AuthSSLProtocolSocketFactory(sslKeyStore, sslTrustStore, keyResourceLoader);
    
    // Setup the Apache httpclient library to use our concurrent HttpParams factory
    DefaultHttpParams.setHttpParamsFactory(new NonBlockingHttpParamsFactory());
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:10,代码来源:HttpClientFactory.java


示例8: testChallengeProcessing

import org.apache.commons.httpclient.params.DefaultHttpParams; //导入依赖的package包/类
public void testChallengeProcessing() throws Exception {
    HttpParams httpparams = new DefaultHttpParams(); 
    AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);

    Map map = new HashMap(); 
    map.put("basic", "basic realm=\"whatever\", param=\"value\"");
    
    AuthState authstate = new AuthState();
    
    AuthScheme authscheme = processor.processChallenge(authstate, map);
    assertTrue(authscheme instanceof BasicScheme);
    assertEquals("whatever", authscheme.getRealm());
    assertEquals(authscheme, authstate.getAuthScheme());
    assertEquals("value", authscheme.getParameter("param"));
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:16,代码来源:TestChallengeProcessor.java


示例9: main

import org.apache.commons.httpclient.params.DefaultHttpParams; //导入依赖的package包/类
public static void main(String[] args) {
    
    // register the auth scheme
    AuthPolicy.registerAuthScheme("Negotiate", NegotiateScheme.class);

    // include the scheme in the AuthPolicy.AUTH_SCHEME_PRIORITY preference
    ArrayList schemes = new ArrayList();
    schemes.add("Negotiate");

    HttpParams params = DefaultHttpParams.getDefaultParams();        
    params.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, schemes);
    
    // now that our scheme has been registered we can execute methods against
    // servers that require "Negotiate" authentication... 
    HttpClient client = new HttpClient();
    
    // The Negotiate scheme uses JAAS as credential provider but the
    // httpclient api require us to supply cred anyway.
    // a work around is to provide an empty set of creds.
    Credentials use_jaas_creds = new Credentials() {};
    client.getState().setCredentials(
        new AuthScope(null, -1, null),
        use_jaas_creds);
    GetMethod httpget = new GetMethod(args[0]);

    try {
        client.executeMethod(httpget);
        //System.out.println(httpget.getStatusLine());
        //System.out.println(httpget.getResponseBodyAsString());
    } catch (Exception e) {
        e.printStackTrace();            
    } finally {
        // release any connection resources used by the method
        httpget.releaseConnection();
    }            
    
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:38,代码来源:CustomAuthenticationNegotiateExample.java


示例10: setup

import org.apache.commons.httpclient.params.DefaultHttpParams; //导入依赖的package包/类
@Override
public void setup(OperatorContext context)
{
  url = prepareURL();
  client = new HttpClient();
  method = new GetMethod(url);
  DefaultHttpParams.getDefaultParams().setParameter("http.protocol.cookie-policy", CookiePolicy.BROWSER_COMPATIBILITY);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:9,代码来源:StockTickInput.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AnnotationPipeline类代码示例发布时间:2022-05-23
下一篇:
Java Token类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap