當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpTransport.createRequestFactory方法代碼示例

本文整理匯總了Java中com.google.api.client.http.HttpTransport.createRequestFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpTransport.createRequestFactory方法的具體用法?Java HttpTransport.createRequestFactory怎麽用?Java HttpTransport.createRequestFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.api.client.http.HttpTransport的用法示例。


在下文中一共展示了HttpTransport.createRequestFactory方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSupplyJwksFromX509Certificate

import com.google.api.client.http.HttpTransport; //導入方法依賴的package包/類
@Test
public void testSupplyJwksFromX509Certificate() throws
    NoSuchAlgorithmException, JsonProcessingException {
  RsaJsonWebKey rsaJsonWebKey = TestUtils.generateRsaJsonWebKey("key-id");
  String cert = TestUtils.generateX509Cert(rsaJsonWebKey);
  String keyId = "key-id";
  String json = OBJECT_WRITER.writeValueAsString(ImmutableMap.of(keyId, cert));

  HttpTransport httpTransport = new TestingHttpTransport(json, null);
  DefaultJwksSupplier jwksSupplier =
      new DefaultJwksSupplier(httpTransport.createRequestFactory(), keyUriSupplier);
  JsonWebKeySet jsonWebKeySet = jwksSupplier.supply(ISSUER);
  JsonWebKey jsonWebKey = Iterables.getOnlyElement(jsonWebKeySet.getJsonWebKeys());

  assertEquals(keyId, jsonWebKey.getKeyId());
  assertKeysEqual(rsaJsonWebKey.getPublicKey(), jsonWebKey.getKey());
}
 
開發者ID:cloudendpoints,項目名稱:endpoints-management-java,代碼行數:18,代碼來源:DefaultJwksSupplierTest.java

示例2: FirebaseInstanceId

import com.google.api.client.http.HttpTransport; //導入方法依賴的package包/類
private FirebaseInstanceId(FirebaseApp app) {
  HttpTransport httpTransport = app.getOptions().getHttpTransport();
  GoogleCredentials credentials = ImplFirebaseTrampolines.getCredentials(app);
  this.app = app;
  this.requestFactory = httpTransport.createRequestFactory(
      new HttpCredentialsAdapter(credentials));
  this.jsonFactory = app.getOptions().getJsonFactory();
  this.projectId = ImplFirebaseTrampolines.getProjectId(app);
  checkArgument(!Strings.isNullOrEmpty(projectId),
      "Project ID is required to access instance ID service. Use a service account credential or "
          + "set the project ID explicitly via FirebaseOptions. Alternatively you can also "
          + "set the project ID via the GCLOUD_PROJECT environment variable.");
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:14,代碼來源:FirebaseInstanceId.java

示例3: testSupplyJwks

import com.google.api.client.http.HttpTransport; //導入方法依賴的package包/類
@Test
public void testSupplyJwks() throws JoseException {
  RsaJsonWebKey rsaJwk = RsaJwkGenerator.generateJwk(2048);
  JsonWebKeySet jsonWebKeySet = new JsonWebKeySet(rsaJwk);
  HttpTransport httpTransport = new TestingHttpTransport(jsonWebKeySet.toJson(), null);
  DefaultJwksSupplier jwksSupplier =
      new DefaultJwksSupplier(httpTransport.createRequestFactory(), keyUriSupplier);
  List<JsonWebKey> jsonWebKeys = jwksSupplier.supply(ISSUER).getJsonWebKeys();
  JsonWebKey jsonWebKey = Iterables.getOnlyElement(jsonWebKeys);

  assertKeysEqual(rsaJwk.getKey(), jsonWebKey.getKey());
}
 
開發者ID:cloudendpoints,項目名稱:endpoints-management-java,代碼行數:13,代碼來源:DefaultJwksSupplierTest.java

示例4: testSupplyWithIoException

import com.google.api.client.http.HttpTransport; //導入方法依賴的package包/類
@Test
public void testSupplyWithIoException() {
  HttpTransport httpTransport = new TestingHttpTransport(null, new IOException());
  DefaultJwksSupplier jwksSupplier =
      new DefaultJwksSupplier(httpTransport.createRequestFactory(), keyUriSupplier);
  try {
    jwksSupplier.supply(ISSUER);
  } catch (UnauthenticatedException exception) {
    assertTrue(exception.getCause() instanceof IOException);
  }
}
 
開發者ID:cloudendpoints,項目名稱:endpoints-management-java,代碼行數:12,代碼來源:DefaultJwksSupplierTest.java

示例5: createRequestFactory

import com.google.api.client.http.HttpTransport; //導入方法依賴的package包/類
/**
 * Creating http request Factory
 * */
public static HttpRequestFactory createRequestFactory(
		final HttpTransport transport) {
	return transport.createRequestFactory(new HttpRequestInitializer() {
		public void initialize(HttpRequest request) {
			GoogleHeaders headers = new GoogleHeaders();
			request.setHeaders(headers);
		}
	});
}
 
開發者ID:Gaso-UFS,項目名稱:gaso,代碼行數:13,代碼來源:GooglePlaces.java

示例6: wolfReq

import com.google.api.client.http.HttpTransport; //導入方法依賴的package包/類
public void wolfReq(String s)throws Exception
{
    String appid="JHG2AQ-KEUPARWGKH";
    HttpTransport httpTransport = new NetHttpTransport();
    HttpRequestFactory requestFactory =
            httpTransport.createRequestFactory();
    GenericUrl url1 = new
            GenericUrl("http://api.wolframalpha.com/v2/query");
    url1.put("input",s);
    url1.put("output","JSON");
    url1.put("appid",appid);
    final HttpRequest request = requestFactory.buildGetRequest(url1);

    new AsyncTask<Void, Void, String>() {
        @Override
        protected String doInBackground(Void... params) {
            HttpResponse httpResponse;

            try {
                httpResponse = request.execute();
                InputStream inputStream = httpResponse.getContent();
                int ch;
                String result = "";
                while ((ch = inputStream.read()) != -1) {
                    result+=(char)ch;
                }

                httpResponse.disconnect();
                JSONObject data = new JSONObject(result);
                result = data.getJSONObject("queryresult").getJSONArray("pods").getJSONObject(1).getJSONArray("subpods").getJSONObject(0).getJSONObject("img").getString ("src");
                URL urlConnection = new URL(result);
                HttpURLConnection connection =
                        (HttpURLConnection) urlConnection
                                .openConnection();
                connection.setDoInput(true);
                connection.setConnectTimeout(20000);
                connection.connect();
                InputStream input =
                        connection.getInputStream();
                Bitmap myBitmap =
                        BitmapFactory.decodeStream(input);
                bmp=myBitmap;
                connection.disconnect();
                Log.d("result",bmp.toString());

                final Message message2 = new Message.Builder()
                        .setUser(you)
                        .setRightMessage(false)
                        .setPicture(myBitmap)
                        .hideIcon(true)
                        .setType(Message.Type.PICTURE)
                        .build();
                //Set to chat view
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        chatView.send(message2);
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            }

            return null;
        }
    }.execute();
}
 
開發者ID:akshah1997,項目名稱:KJSCE-Hackathon,代碼行數:68,代碼來源:MainActivity.java

示例7: wolfReq

import com.google.api.client.http.HttpTransport; //導入方法依賴的package包/類
public static void wolfReq(String s)throws Exception
{
    String appid="JHG2AQ-KEUPARWGKH";
    HttpTransport httpTransport = new NetHttpTransport();
    HttpRequestFactory requestFactory =
            httpTransport.createRequestFactory();
    GenericUrl url1 = new
            GenericUrl("http://api.wolframalpha.com/v2/query");
url1.put("input",s);
    url1.put("output","JSON");
    url1.put("appid",appid);
    final HttpRequest request = requestFactory.buildGetRequest(url1);
    String resultPassed = "";
    new AsyncTask<Void, Void, String>() {
        @Override
        protected String doInBackground(Void... params) {
            HttpResponse httpResponse = null;

            try {
                httpResponse = request.execute();
                InputStream inputStream = httpResponse.getContent();
                int ch;
                String result = "";
                while ((ch = inputStream.read()) != -1) {
                    result+=(char)ch;
                }

                httpResponse.disconnect();
                JSONObject data = new JSONObject(result);
                result = data.getJSONObject("queryresult").getJSONArray("pods").getJSONObject(1).getJSONArray("subpods").getJSONObject(0).getString("plaintext");
                Log.d("result",result);
                setResult(result);
                return result;
            } catch (Exception e) {
                e.printStackTrace();
            }

            return null;
        }
    }.execute();
}
 
開發者ID:akshah1997,項目名稱:KJSCE-Hackathon,代碼行數:42,代碼來源:AndroidUtils.java

示例8: SalesforceRestClientImpl

import com.google.api.client.http.HttpTransport; //導入方法依賴的package包/類
public SalesforceRestClientImpl(final SalesforceSourceConnectorConfig config, HttpTransport httpTransport) {
  this.config = config;
  this.httpTransport = httpTransport;
  java.util.logging.Logger transportLogger = java.util.logging.Logger.getLogger(HttpTransport.class.getName());
  transportLogger.setLevel(Level.ALL);
  transportLogger.addHandler(new Handler() {
    @Override
    public void publish(LogRecord record) {
      if (Level.INFO.equals(record.getLevel())) {
        log.info(record.getMessage());
      } else if (Level.WARNING.equals(record.getLevel())) {
        log.warn(record.getMessage());
      } else if (Level.SEVERE.equals(record.getLevel())) {
        log.error(record.getMessage());
      }
      log.debug(record.getMessage());
    }

    @Override
    public void flush() {

    }

    @Override
    public void close() throws SecurityException {

    }
  });
  this.requestFactory = httpTransport.createRequestFactory(new HttpRequestInitializer() {
    @Override
    public void initialize(HttpRequest request) throws IOException {
      if (config.curlLogging) {
        request.setCurlLoggingEnabled(true);
        request.setLoggingEnabled(true);
      }

      request.setParser(new JsonObjectParser(JSON_FACTORY));
      if (null != authentication) {
        String headerValue = String.format("%s %s", authentication.tokenType(), authentication.accessToken());
        request.getHeaders().setAuthorization(headerValue);
      }
    }
  });
}
 
開發者ID:jcustenborder,項目名稱:kafka-connect-salesforce,代碼行數:45,代碼來源:SalesforceRestClientImpl.java

示例9: FirebaseUserManager

import com.google.api.client.http.HttpTransport; //導入方法依賴的package包/類
/**
 * Creates a new FirebaseUserManager instance.
 *
 * @param jsonFactory JsonFactory instance used to transform Java objects into JSON and back.
 * @param transport HttpTransport used to make REST API calls.
 */
FirebaseUserManager(JsonFactory jsonFactory, HttpTransport transport,
    GoogleCredentials credentials) {
  this.jsonFactory = checkNotNull(jsonFactory, "jsonFactory must not be null");
  this.requestFactory = transport.createRequestFactory(new HttpCredentialsAdapter(credentials));
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:12,代碼來源:FirebaseUserManager.java


注:本文中的com.google.api.client.http.HttpTransport.createRequestFactory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。