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

Java AuthScheme类代码示例

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

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



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

示例1: URLCheckerService

import com.ning.http.client.Realm.AuthScheme; //导入依赖的package包/类
public URLCheckerService()
{
	Builder bc = new AsyncHttpClientConfig.Builder();
	bc.setAllowPoolingConnections(false); // Avoid keep-alive
	bc.setCompressionEnforced(true);
	bc.setUseProxyProperties(true);
	bc.setFollowRedirect(true);
	bc.setMaxConnectionsPerHost(2);
	bc.setMaxConnections(200);
	bc.setMaxRedirects(25);
	bc.setUserAgent("Mozilla/5.0 (compatible; equellaurlbot/1.0; +http://support.equella.com/)");

	// These are actually the defaults, but let's specify in case they
	// change
	bc.setConnectTimeout(60000);
	bc.setRequestTimeout(60000);
	// ^^ note the massive request timeout, this not a per-request timeout,
	// it's the whole redirection round trip

	// Just because a URL uses a self-signed certificate doesn't mean it's
	// not a working URL. We also don't care about MITM attacks since we're
	// just checking the URL.
	bc.setSSLContext(BlindSSLSocketFactory.createBlindSSLContext());

	// Configure a fake authentication in case some the URLs are using it.
	// http://jira.pearsoncmg.com/jira/browse/EQ-411
	Realm realm = new Realm.RealmBuilder().setPrincipal("").setPassword("").setUsePreemptiveAuth(true)
		.setScheme(AuthScheme.BASIC).build();
	bc.setRealm(realm);

	client = new AsyncHttpClient(bc.build());
}
 
开发者ID:equella,项目名称:Equella,代码行数:33,代码来源:URLCheckerService.java


示例2: auth

import com.ning.http.client.Realm.AuthScheme; //导入依赖的package包/类
private WSRequest auth(String username, String password, AuthScheme scheme) {
    this.setRealm((new RealmBuilder())
            .setScheme(scheme)
            .setPrincipal(username)
            .setPassword(password)
            .setUsePreemptiveAuth(true)
            .build());
    return this;
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:10,代码来源:WS.java


示例3: setAuth

import com.ning.http.client.Realm.AuthScheme; //导入依赖的package包/类
/**
 * Sets the authentication header for the current request using BASIC authentication.
 *
 * @param username
 * @param password
 */
public WSRequestHolder setAuth(String username, String password) {
    this.username = username;
    this.password = password;
    this.scheme = AuthScheme.BASIC;
    return this;
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:13,代码来源:WS.java


示例4: createRealm

import com.ning.http.client.Realm.AuthScheme; //导入依赖的package包/类
private Realm createRealm() {
	Realm.RealmBuilder builder = new Realm.RealmBuilder();
	builder.setPrincipal(xbmc.getUsername());
	builder.setPassword(xbmc.getPassword());
	builder.setUsePreemptiveAuth(true);
	builder.setScheme(AuthScheme.BASIC);
	return builder.build();
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:9,代码来源:XbmcConnector.java


示例5: prepare

import com.ning.http.client.Realm.AuthScheme; //导入依赖的package包/类
private BoundRequestBuilder prepare(BoundRequestBuilder builder) {
    if (this.username != null && this.password != null && this.scheme != null) {
        AuthScheme authScheme;
        switch (this.scheme) {
        case DIGEST: authScheme = AuthScheme.DIGEST; break;
        case NTLM: authScheme = AuthScheme.NTLM; break;
        case KERBEROS: authScheme = AuthScheme.KERBEROS; break;
        case SPNEGO: authScheme = AuthScheme.SPNEGO; break;
        case BASIC: authScheme = AuthScheme.BASIC; break;
        default: throw new RuntimeException("Scheme " + this.scheme + " not supported by the UrlFetch WS backend.");
        }
        builder.setRealm(
                (new RealmBuilder())
                .setScheme(authScheme)
                .setPrincipal(this.username)
                .setPassword(this.password)
                .setUsePreemptiveAuth(true)
                .build()
        );
    }
    for (String key: this.headers.keySet()) {
        builder.addHeader(key, headers.get(key));
    }
    builder.setFollowRedirects(this.followRedirects);
    PerRequestConfig perRequestConfig = new PerRequestConfig();
    perRequestConfig.setRequestTimeoutInMs(this.timeout * 1000);
    builder.setPerRequestConfig(perRequestConfig);
    return builder;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:30,代码来源:WSAsync.java


示例6: createRealm

import com.ning.http.client.Realm.AuthScheme; //导入依赖的package包/类
private Realm createRealm() {
    Realm.RealmBuilder builder = new Realm.RealmBuilder();
    builder.setPrincipal(xbmc.getUsername());
    builder.setPassword(xbmc.getPassword());
    builder.setUsePreemptiveAuth(true);
    builder.setScheme(AuthScheme.BASIC);
    return builder.build();
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:9,代码来源:XbmcConnector.java


示例7: getScheme

import com.ning.http.client.Realm.AuthScheme; //导入依赖的package包/类
/**
 * @return the auth scheme, null if not an authenticated request
 */
public AuthScheme getScheme() {
    return this.scheme;
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:7,代码来源:WS.java


示例8: exchangeCodeForToken

import com.ning.http.client.Realm.AuthScheme; //导入依赖的package包/类
public static Promise<Result> exchangeCodeForToken(String code) {
    String clientId = Play.application().configuration()
            .getString("audienceManager.clientId");
    String clientSecret = Play.application().configuration()
            .getString("audienceManager.clientSecret");
    String tokenUrl = Play.application().configuration()
            .getString("audienceManager.tokenUrl");

    // Sets the Authorization header to Basic
    // Base64Encoded(clientId:clientSecret) (includes colon)
    Promise<Result> promiseResult = WS
            .url(tokenUrl)
            .setAuth(clientId, clientSecret, AuthScheme.BASIC)
            .setContentType("application/x-www-form-urlencoded")
            .setHeader("Accept", "application/json")
            .post(String.format(TOKEN_TEMPLATE, clientId, clientSecret,
                    code)).map(new Function<Response, Result>() {

                @Override
                public Result apply(Response response) throws Throwable {
                    if (response.getStatus() == 200) {
                        AudienceManagerAuthentication aamAuth = new AudienceManagerAuthentication();
                        JsonNode responseJson = response.asJson();
                        aamAuth.accessToken = responseJson.get(
                                "access_token").asText();
                        aamAuth.refreshToken = responseJson.get(
                                "refresh_token").asText();
                        aamAuth.email = Application.getLoggedInUser().email;
                        AudienceManagerAuthentication.create(aamAuth);
                        Logger.info(String
                                .format("Got access token %s and refresh token %s for %s",
                                        aamAuth.accessToken,
                                        aamAuth.refreshToken, aamAuth.email));
                    } else {
                        Logger.error(String.format(
                                "Eror getting tokens for %s:\n %d\n %s",
                                Application.getLoggedInUser(),
                                response.getStatus(), response.getBody()));
                    }
                    return redirect(routes.Application.index());
                }

            });

    return promiseResult;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:audiencemanager-api-sample-app,代码行数:47,代码来源:OAuth2AudienceManager.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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