本文整理汇总了Java中io.grpc.auth.MoreCallCredentials类的典型用法代码示例。如果您正苦于以下问题:Java MoreCallCredentials类的具体用法?Java MoreCallCredentials怎么用?Java MoreCallCredentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MoreCallCredentials类属于io.grpc.auth包,在下文中一共展示了MoreCallCredentials类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getUserDetails
import io.grpc.auth.MoreCallCredentials; //导入依赖的package包/类
private AppsCodeUserDetails getUserDetails(String teamId, String username, String token)
throws Exception {
String email = emailCache.getIfPresent(new UserId(teamId, username));
if (email != null && !email.isEmpty()) {
logger.info(String
.format("Returning user details from cache. username: %s, email: %s", username, email));
return AppsCodeUserDetails.fromUsernameAndEmail(username, email);
}
ConduitGrpc.ConduitBlockingStub conduitBlockingStub = ConduitGrpc.newBlockingStub(channel).
withCallCredentials(
MoreCallCredentials.from(new TokenCredential(teamId, token)));
ConduitWhoAmIResponse response = conduitBlockingStub.whoAmI(VoidRequest.newBuilder().build());
emailCache.put(new UserId(teamId, response.getUser().getUserName()),
response.getUser().getPrimaryEmail());
return AppsCodeUserDetails.fromUsernameAndEmail(response.getUser().getUserName(),
response.getUser().getPrimaryEmail());
}
开发者ID:appscode-ci,项目名称:appscode-login-plugin,代码行数:19,代码来源:AppsCodeSecurityRealm.java
示例2: fetchAccessToken
import io.grpc.auth.MoreCallCredentials; //导入依赖的package包/类
private void fetchAccessToken() {
ManagedChannel channel = ManagedChannelBuilder.forTarget(HOSTNAME).build();
try {
mApi = EmbeddedAssistantGrpc.newStub(channel)
.withCallCredentials(MoreCallCredentials.from(
Credentials_.fromResource(getApplicationContext(), R.raw.credentials)
));
} catch (IOException|JSONException e) {
Log.e(TAG, "error creating assistant service:", e);
}
for (Listener listener : mListeners) {
listener. onCredentioalSuccess();
}
}
开发者ID:hsavaliya,项目名称:GoogleAssistantSDK,代码行数:20,代码来源:SpeechService.java
示例3: jwtTokenCreds
import io.grpc.auth.MoreCallCredentials; //导入依赖的package包/类
/** Test JWT-based auth. */
public void jwtTokenCreds(InputStream serviceAccountJson) throws Exception {
final SimpleRequest request = SimpleRequest.newBuilder()
.setResponseType(PayloadType.COMPRESSABLE)
.setResponseSize(314159)
.setPayload(Payload.newBuilder()
.setBody(ByteString.copyFrom(new byte[271828])))
.setFillUsername(true)
.build();
ServiceAccountCredentials credentials = (ServiceAccountCredentials)
GoogleCredentials.fromStream(serviceAccountJson);
TestServiceGrpc.TestServiceBlockingStub stub = blockingStub
.withCallCredentials(MoreCallCredentials.from(credentials));
SimpleResponse response = stub.unaryCall(request);
assertEquals(credentials.getClientEmail(), response.getUsername());
assertEquals(314159, response.getPayload().getBody().size());
}
开发者ID:grpc,项目名称:grpc-java,代码行数:19,代码来源:AbstractInteropTest.java
示例4: oauth2AuthToken
import io.grpc.auth.MoreCallCredentials; //导入依赖的package包/类
/** Sends a unary rpc with raw oauth2 access token credentials. */
public void oauth2AuthToken(String jsonKey, InputStream credentialsStream, String authScope)
throws Exception {
GoogleCredentials utilCredentials =
GoogleCredentials.fromStream(credentialsStream);
utilCredentials = utilCredentials.createScoped(Arrays.<String>asList(authScope));
AccessToken accessToken = utilCredentials.refreshAccessToken();
OAuth2Credentials credentials = OAuth2Credentials.create(accessToken);
TestServiceGrpc.TestServiceBlockingStub stub = blockingStub
.withCallCredentials(MoreCallCredentials.from(credentials));
final SimpleRequest request = SimpleRequest.newBuilder()
.setFillUsername(true)
.setFillOauthScope(true)
.build();
final SimpleResponse response = stub.unaryCall(request);
assertFalse(response.getUsername().isEmpty());
assertTrue("Received username: " + response.getUsername(),
jsonKey.contains(response.getUsername()));
assertFalse(response.getOauthScope().isEmpty());
assertTrue("Received oauth scope: " + response.getOauthScope(),
authScope.contains(response.getOauthScope()));
}
开发者ID:grpc,项目名称:grpc-java,代码行数:26,代码来源:AbstractInteropTest.java
示例5: connect
import io.grpc.auth.MoreCallCredentials; //导入依赖的package包/类
/**
* Initializes the Assistant.
*/
public void connect() {
mAssistantThread = new HandlerThread("assistantThread");
mAssistantThread.start();
mAssistantHandler = new Handler(mAssistantThread.getLooper());
ManagedChannel channel = ManagedChannelBuilder.forTarget(ASSISTANT_API_ENDPOINT).build();
mAssistantService = EmbeddedAssistantGrpc.newStub(channel)
.withCallCredentials(MoreCallCredentials.from(mUserCredentials));
}
开发者ID:androidthings,项目名称:sample-googleassistant,代码行数:13,代码来源:EmbeddedAssistant.java
示例6: getCallCredentials
import io.grpc.auth.MoreCallCredentials; //导入依赖的package包/类
/**
* Get CallCredentials from OAuthCredentials
*
* @param oAuthCredentials the credentials from the AuthenticationHelper
* @return the CallCredentials for the GRPC requests
*/
private CallCredentials getCallCredentials(OAuthCredentials oAuthCredentials) {
AccessToken accessToken = new AccessToken(
oAuthCredentials.getAccessToken(),
new Date(oAuthCredentials.getExpirationTime())
);
OAuth2Credentials oAuth2Credentials = new OAuth2Credentials(accessToken);
// Create an instance of {@link io.grpc.CallCredentials}
return MoreCallCredentials.from(oAuth2Credentials);
}
开发者ID:mautini,项目名称:google-assistant-java-demo,代码行数:19,代码来源:AssistantClient.java
示例7: newCallCredentials
import io.grpc.auth.MoreCallCredentials; //导入依赖的package包/类
/**
* Create a new {@link CallCredentials} object.
*
* @throws IOException in case the call credentials can't be constructed.
*/
public static CallCredentials newCallCredentials(AuthAndTLSOptions options) throws IOException {
Credentials creds = newCredentials(options);
if (creds != null) {
return MoreCallCredentials.from(creds);
}
return null;
}
开发者ID:bazelbuild,项目名称:bazel,代码行数:13,代码来源:GoogleAuthUtils.java
示例8: serviceAccountCreds
import io.grpc.auth.MoreCallCredentials; //导入依赖的package包/类
/** Sends a large unary rpc with service account credentials. */
public void serviceAccountCreds(String jsonKey, InputStream credentialsStream, String authScope)
throws Exception {
// cast to ServiceAccountCredentials to double-check the right type of object was created.
GoogleCredentials credentials =
ServiceAccountCredentials.class.cast(GoogleCredentials.fromStream(credentialsStream));
credentials = credentials.createScoped(Arrays.<String>asList(authScope));
TestServiceGrpc.TestServiceBlockingStub stub = blockingStub
.withCallCredentials(MoreCallCredentials.from(credentials));
final SimpleRequest request = SimpleRequest.newBuilder()
.setFillUsername(true)
.setFillOauthScope(true)
.setResponseSize(314159)
.setResponseType(PayloadType.COMPRESSABLE)
.setPayload(Payload.newBuilder()
.setBody(ByteString.copyFrom(new byte[271828])))
.build();
final SimpleResponse response = stub.unaryCall(request);
assertFalse(response.getUsername().isEmpty());
assertTrue("Received username: " + response.getUsername(),
jsonKey.contains(response.getUsername()));
assertFalse(response.getOauthScope().isEmpty());
assertTrue("Received oauth scope: " + response.getOauthScope(),
authScope.contains(response.getOauthScope()));
final SimpleResponse goldenResponse = SimpleResponse.newBuilder()
.setOauthScope(response.getOauthScope())
.setUsername(response.getUsername())
.setPayload(Payload.newBuilder()
.setType(PayloadType.COMPRESSABLE)
.setBody(ByteString.copyFrom(new byte[314159])))
.build();
assertEquals(goldenResponse, response);
}
开发者ID:grpc,项目名称:grpc-java,代码行数:36,代码来源:AbstractInteropTest.java
示例9: computeEngineCreds
import io.grpc.auth.MoreCallCredentials; //导入依赖的package包/类
/** Sends a large unary rpc with compute engine credentials. */
public void computeEngineCreds(String serviceAccount, String oauthScope) throws Exception {
ComputeEngineCredentials credentials = ComputeEngineCredentials.create();
TestServiceGrpc.TestServiceBlockingStub stub = blockingStub
.withCallCredentials(MoreCallCredentials.from(credentials));
final SimpleRequest request = SimpleRequest.newBuilder()
.setFillUsername(true)
.setFillOauthScope(true)
.setResponseSize(314159)
.setResponseType(PayloadType.COMPRESSABLE)
.setPayload(Payload.newBuilder()
.setBody(ByteString.copyFrom(new byte[271828])))
.build();
final SimpleResponse response = stub.unaryCall(request);
assertEquals(serviceAccount, response.getUsername());
assertFalse(response.getOauthScope().isEmpty());
assertTrue("Received oauth scope: " + response.getOauthScope(),
oauthScope.contains(response.getOauthScope()));
final SimpleResponse goldenResponse = SimpleResponse.newBuilder()
.setOauthScope(response.getOauthScope())
.setUsername(response.getUsername())
.setPayload(Payload.newBuilder()
.setType(PayloadType.COMPRESSABLE)
.setBody(ByteString.copyFrom(new byte[314159])))
.build();
assertEquals(goldenResponse, response);
}
开发者ID:grpc,项目名称:grpc-java,代码行数:30,代码来源:AbstractInteropTest.java
注:本文中的io.grpc.auth.MoreCallCredentials类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论