Java Realm类代码示例

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


Java Realm类代码示例

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

示例1: customize

import com.ning.http.client.Realm; //导入依赖的package包/类
@Override
public AsyncHttpClientConfig.Builder customize(
    Client client, Configuration config, AsyncHttpClientConfig.Builder configBuilder
) {
  if (useProxy && !StringUtils.isEmpty(username)) {
    Realm realm = new Realm.RealmBuilder().setScheme(Realm.AuthScheme.BASIC)
        .setUsePreemptiveAuth(true)
        .setTargetProxy(true)
        .setPrincipal(username)
        .setPassword(password)
        .build();

    configBuilder.setRealm(realm);
  }
  return configBuilder;
} 
开发者ID:streamsets,项目名称:datacollector,代码行数:17,代码来源:GrizzlyClientCustomizer.java

示例2: obtainBearerToken

import com.ning.http.client.Realm; //导入依赖的package包/类
public F.Promise<String> obtainBearerToken(final String consumerKey, final String consumerToken) {
    final F.Promise<WS.Response> responsePromise = WS.url(TwitterClientFactory.TWITTER_API_BASE + "/oauth2/token")
            .setAuth(consumerKey, consumerToken, Realm.AuthScheme.BASIC)
            .setContentType("application/x-www-form-urlencoded;charset=UTF-8")
            .post("grant_type=client_credentials");
    return responsePromise.map(new F.Function<WS.Response, String>() {
        @Override
        public String apply(WS.Response response) throws Throwable {
            final JsonNode jsonNode = response.asJson();
            if("bearer".equals(jsonNode.findPath("token_type").getTextValue())) {
                return jsonNode.findPath("access_token").getTextValue();
            } else {
                throw new RuntimeException(String.format("Illegal response from the Twitter API. Data returned: %1$s", response.getBody()));
            }
        }
    });
} 
开发者ID:Sonat-Consulting,项目名称:javabin-play-public,代码行数:18,代码来源:TwitterApplicationAuthenticator.java

示例3: URLCheckerService

import com.ning.http.client.Realm; //导入依赖的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

示例4: createRealm

import com.ning.http.client.Realm; //导入依赖的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: getBuilderWithHeaderAndQuery

import com.ning.http.client.Realm; //导入依赖的package包/类
private AsyncHttpClient.BoundRequestBuilder getBuilderWithHeaderAndQuery(final String verb, final String url, final String username, final Map<String, String> options) {
    AsyncHttpClient.BoundRequestBuilder builder;

    if (verb.equals("GET")) {
        builder = httpClient.prepareGet(url);
    } else if (verb.equals("POST")) {
        builder = httpClient.preparePost(url);
    } else if (verb.equals("PUT")) {
        builder = httpClient.preparePut(url);
    } else if (verb.equals("DELETE")) {
        builder = httpClient.prepareDelete(url);
    } else if (verb.equals("HEAD")) {
        builder = httpClient.prepareHead(url);
    } else if (verb.equals("OPTIONS")) {
        builder = httpClient.prepareOptions(url);
    } else {
        throw new IllegalArgumentException("Unrecognized verb: " + verb);
    }

    if (username != null) {
        final Realm realm = new Realm.RealmBuilder().setPrincipal(username).build();
        builder.setRealm(realm);
    }

    builder.addHeader("Content-Type", "application/json; charset=utf-8");

    for (final String key : options.keySet()) {
        if (options.get(key) != null) {
            builder.addQueryParameter(key, options.get(key));
        }
    }
    return builder;
} 
开发者ID:killbill,项目名称:feedzai-client,代码行数:34,代码来源:DefaultFeedzaiClient.java

示例6: withBasicAuth

import com.ning.http.client.Realm; //导入依赖的package包/类
@Override
public RequestBuilder withBasicAuth(final String username, final String password) {

  final Realm realm = new Realm.RealmBuilder().
    setPrincipal(username).
    setPassword(password).
    setUsePreemptiveAuth(true).
    setScheme(Realm.AuthScheme.BASIC).
    build();

  ningRequestBuilder.setRealm(realm);
  return this;
} 
开发者ID:outbrain,项目名称:ob1k,代码行数:14,代码来源:NingRequestBuilder.java

示例7: createRealm

import com.ning.http.client.Realm; //导入依赖的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

示例8: createEndpoint

import com.ning.http.client.Realm; //导入依赖的package包/类
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    String addressUri = createAddressUri(uri, remaining);

    // Do not set the HTTP URI because we still have all of the Camel internal
    // parameters in the URI at this point.
    AhcEndpoint endpoint = createAhcEndpoint(uri, this, null);
    setEndpointHeaderFilterStrategy(endpoint);
    endpoint.setClient(getClient());
    endpoint.setClientConfig(getClientConfig());
    endpoint.setBinding(getBinding());
    endpoint.setSslContextParameters(getSslContextParameters());
    
    setProperties(endpoint, parameters);

    if (IntrospectionSupport.hasProperties(parameters, CLIENT_CONFIG_PREFIX)) {
        AsyncHttpClientConfig.Builder builder = endpoint.getClientConfig() == null 
                ? new AsyncHttpClientConfig.Builder() : AhcComponent.cloneConfig(endpoint.getClientConfig());
        
        if (endpoint.getClient() != null) {
            LOG.warn("The user explicitly set an AsyncHttpClient instance on the component or "
                     + "endpoint, but this endpoint URI contains client configuration parameters.  "
                     + "Are you sure that this is what was intended?  The AsyncHttpClient will be used"
                     + " and the URI parameters will be ignored.");
        } else if (endpoint.getClientConfig() != null) {
            LOG.warn("The user explicitly set an AsyncHttpClientConfig instance on the component or "
                     + "endpoint, but this endpoint URI contains client configuration parameters.  "
                     + "Are you sure that this is what was intended?  The URI parameters will be applied"
                     + " to a clone of the supplied AsyncHttpClientConfig in order to prevent unintended modification"
                     + " of the explicitly configured AsyncHttpClientConfig.  That is, the URI parameters override the"
                     + " settings on the explicitly configured AsyncHttpClientConfig for this endpoint.");
        }

        // special for realm builder
        Realm.RealmBuilder realmBuilder = null;
        if (IntrospectionSupport.hasProperties(parameters, CLIENT_REALM_CONFIG_PREFIX)) {
            realmBuilder = new Realm.RealmBuilder();

            // set and validate additional parameters on client config
            Map<String, Object> realmParams = IntrospectionSupport.extractProperties(parameters, CLIENT_REALM_CONFIG_PREFIX);
            setProperties(realmBuilder, realmParams);
            validateParameters(uri, realmParams, null);
        }

        // set and validate additional parameters on client config
        Map<String, Object> clientParams = IntrospectionSupport.extractProperties(parameters, CLIENT_CONFIG_PREFIX);
        setProperties(builder, clientParams);
        validateParameters(uri, clientParams, null);

        if (realmBuilder != null) {
            builder.setRealm(realmBuilder.build());
        }
        endpoint.setClientConfig(builder.build());
    }

    // restructure uri to be based on the parameters left as we dont want to include the Camel internal options
    addressUri = UnsafeUriCharactersEncoder.encodeHttpURI(addressUri);
    URI httpUri = URISupport.createRemainingURI(new URI(addressUri), parameters);
    endpoint.setHttpUri(httpUri);
    
    return endpoint;
} 
开发者ID:HydAu,项目名称:Camel,代码行数:63,代码来源:AhcComponent.java

示例9: getRealm

import com.ning.http.client.Realm; //导入依赖的package包/类
@Override
public Realm getRealm() {
  return config.getRealm();
} 
开发者ID:MachinePublishers,项目名称:ScreenSlicer,代码行数:5,代码来源:LenientHttpsConfig.java

示例10: setRealm

import com.ning.http.client.Realm; //导入依赖的package包/类
public void setRealm(Realm realm) {
    this.realm = realm;
} 
开发者ID:adamcin,项目名称:net.adamcin.granite.client,代码行数:4,代码来源:AsyncPackageManagerClient.java

示例11: getRealm

import com.ning.http.client.Realm; //导入依赖的package包/类
public Realm getRealm() {
    return this.realm;
} 
开发者ID:adamcin,项目名称:net.adamcin.granite.client,代码行数:4,代码来源:AsyncPackageManagerClient.java

本文标签属性:

示例:示例图

代码:代码编程

java:java面试题

Realm:Realm

上一篇:闹剧[nào jù]什么意思?近义词和反义词是什么?英文翻译是什么?(闹剧是什么意思)
下一篇:Java UltrasonicSensor类代码示例(javaultrasonicsensor类典型用法代码示例汇总)

为您推荐