本文整理匯總了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());
}
示例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.");
}
示例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());
}
示例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);
}
}
示例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);
}
});
}
示例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();
}
示例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();
}
示例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);
}
}
});
}
示例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));
}