本文整理汇总了Java中com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants类的典型用法代码示例。如果您正苦于以下问题:Java AuthTokenConstants类的具体用法?Java AuthTokenConstants怎么用?Java AuthTokenConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthTokenConstants类属于com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants包,在下文中一共展示了AuthTokenConstants类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onHandleIntent
import com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
if (intent == null) {
return;
}
if (intent.hasExtra(ProtocolIntents.OUTBOUND_MESSAGE_KEY)) {
// Request from the Ticl service to send a message.
handleOutboundMessage(intent.getByteArrayExtra(ProtocolIntents.OUTBOUND_MESSAGE_KEY));
} else if (intent.hasExtra(AndroidChannelConstants.AuthTokenConstants.EXTRA_AUTH_TOKEN)) {
// Reply from the app with an auth token and a message to send.
handleAuthTokenResponse(intent);
} else if (intent.hasExtra(AndroidChannelConstants.MESSAGE_SENDER_SVC_GCM_REGID_CHANGE)) {
handleGcmRegIdChange();
} else {
logger.warning("Ignoring intent: %s", intent);
}
}
开发者ID:mogoweb,项目名称:365browser,代码行数:19,代码来源:AndroidMessageSenderService.java
示例2: handleAuthTokenResponse
import com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants; //导入依赖的package包/类
/**
* Handles an intent received from the application that contains both a message to send and
* an auth token and type to use when sending it. This is called when the reply to the intent
* sent in {@link #requestAuthTokenForMessage(byte[], String)} is received.
*/
private void handleAuthTokenResponse(Intent intent) {
if (!(intent.hasExtra(AuthTokenConstants.EXTRA_STORED_MESSAGE)
&& intent.hasExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN)
&& intent.hasExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN_TYPE)
&& intent.hasExtra(AuthTokenConstants.EXTRA_IS_RETRY))) {
logger.warning(
"auth-token-response intent missing fields: %s, %s", intent, intent.getExtras());
return;
}
boolean isRetryForInvalidAuthToken =
intent.getBooleanExtra(AuthTokenConstants.EXTRA_IS_RETRY, false);
deliverOutboundMessage(
intent.getByteArrayExtra(AuthTokenConstants.EXTRA_STORED_MESSAGE),
intent.getStringExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN),
intent.getStringExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN_TYPE),
isRetryForInvalidAuthToken);
}
开发者ID:mogoweb,项目名称:365browser,代码行数:23,代码来源:AndroidMessageSenderService.java
示例3: tryHandleAuthTokenRequestIntent
import com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants; //导入依赖的package包/类
/**
* Tries to handle a request for an authorization token. Returns {@code true} iff the intent is
* an auth token request.
*/
private boolean tryHandleAuthTokenRequestIntent(Intent intent) {
if (!AndroidListenerIntents.isAuthTokenRequest(intent)) {
return false;
}
// Check for invalid auth token. Subclass may have to invalidate it if it exists in the call
// to getNewAuthToken.
String invalidAuthToken = intent.getStringExtra(
AuthTokenConstants.EXTRA_INVALIDATE_AUTH_TOKEN);
// Intent also includes a pending intent that we can use to pass back our response.
PendingIntent pendingIntent = intent.getParcelableExtra(
AuthTokenConstants.EXTRA_PENDING_INTENT);
if (pendingIntent == null) {
logger.warning("Authorization request without pending intent extra.");
} else {
// Delegate to client application to figure out what the new token should be and the auth
// type.
requestAuthToken(pendingIntent, invalidAuthToken);
}
return true;
}
开发者ID:mogoweb,项目名称:365browser,代码行数:26,代码来源:AndroidListener.java
示例4: handleAuthTokenResponse
import com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants; //导入依赖的package包/类
/**
* Handles an intent received from the application that contains both a message to send and
* an auth token and type to use when sending it. This is called when the reply to the intent
* sent in {@link #requestAuthTokenForMessage(byte[], String)} is received.
*/
private void handleAuthTokenResponse(Intent intent) {
if (!(intent.hasExtra(AuthTokenConstants.EXTRA_STORED_MESSAGE)
&& intent.hasExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN)
&& intent.hasExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN_TYPE)
&& intent.hasExtra(AuthTokenConstants.EXTRA_IS_RETRY))) {
logger.warning("auth-token-response intent missing fields: %s, %s",
intent, intent.getExtras());
return;
}
boolean isRetryForInvalidAuthToken =
intent.getBooleanExtra(AuthTokenConstants.EXTRA_IS_RETRY, false);
deliverOutboundMessage(
intent.getByteArrayExtra(AuthTokenConstants.EXTRA_STORED_MESSAGE),
intent.getStringExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN),
intent.getStringExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN_TYPE),
isRetryForInvalidAuthToken);
}
开发者ID:morristech,项目名称:android-chromium,代码行数:23,代码来源:AndroidMessageSenderService.java
示例5: tryHandleAuthTokenRequestIntent
import com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants; //导入依赖的package包/类
/**
* Tries to handle a request for an authorization token. Returns {@code true} iff the intent is
* an auth token request.
*/
private boolean tryHandleAuthTokenRequestIntent(Intent intent) {
if (!AndroidListenerIntents.isAuthTokenRequest(intent)) {
return false;
}
Context context = getApplicationContext();
// Check for invalid auth token. Subclass may have to invalidate it if it exists in the call
// to getNewAuthToken.
String invalidAuthToken = intent.getStringExtra(
AuthTokenConstants.EXTRA_INVALIDATE_AUTH_TOKEN);
// Intent also includes a pending intent that we can use to pass back our response.
PendingIntent pendingIntent = intent.getParcelableExtra(
AuthTokenConstants.EXTRA_PENDING_INTENT);
if (pendingIntent == null) {
logger.warning("Authorization request without pending intent extra.");
} else {
// Delegate to client application to figure out what the new token should be and the auth
// type.
requestAuthToken(pendingIntent, invalidAuthToken);
}
return true;
}
开发者ID:morristech,项目名称:android-chromium,代码行数:27,代码来源:AndroidListener.java
示例6: issueAuthTokenResponse
import com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants; //导入依赖的package包/类
/**
* Given an authorization token request intent and authorization information ({@code authToken}
* and {@code authType}) issues a response.
*/
static void issueAuthTokenResponse(Context context, PendingIntent pendingIntent, String authToken,
String authType) {
Intent responseIntent = new Intent()
.putExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN, authToken)
.putExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN_TYPE, authType);
try {
pendingIntent.send(context, 0, responseIntent);
} catch (CanceledException exception) {
logger.warning("Canceled auth request: %s", exception);
}
}
开发者ID:mogoweb,项目名称:365browser,代码行数:16,代码来源:AndroidListenerIntents.java
示例7: onHandleIntent
import com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
if (intent.hasExtra(ProtocolIntents.OUTBOUND_MESSAGE_KEY)) {
// Request from the Ticl service to send a message.
handleOutboundMessage(intent.getByteArrayExtra(ProtocolIntents.OUTBOUND_MESSAGE_KEY));
} else if (intent.hasExtra(AndroidChannelConstants.AuthTokenConstants.EXTRA_AUTH_TOKEN)) {
// Reply from the app with an auth token and a message to send.
handleAuthTokenResponse(intent);
} else if (intent.hasExtra(AndroidChannelConstants.MESSAGE_SENDER_SVC_GCM_REGID_CHANGE)) {
handleGcmRegIdChange();
} else {
logger.warning("Ignoring intent: %s", intent);
}
}
开发者ID:morristech,项目名称:android-chromium,代码行数:15,代码来源:AndroidMessageSenderService.java
示例8: requestAuthTokenForMessage
import com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants; //导入依赖的package包/类
/**
* Requests an auth token from the application to use to send {@code message} to the data
* center.
* <p>
* If not {@code null}, {@code invalidAuthToken} is an auth token that was previously
* found to be invalid. The intent sent to the application to request the new token will include
* the invalid token so that the application can invalidate it in the {@code AccountManager}.
*/
private void requestAuthTokenForMessage(byte[] message, String invalidAuthToken) {
/*
* Send an intent requesting an auth token. This intent will contain a pending intent
* that the recipient can use to send back the token (by attaching the token as a string
* extra). That pending intent will also contain the message that we were just asked to send,
* so that it will be echoed back to us with the token. This avoids our having to persist
* the message while waiting for the token.
*/
// This is the intent that the application will send back to us (the pending intent allows
// it to send the intent). It contains the stored message. We require that it be delivered to
// this class only, as a security check.
Intent tokenResponseIntent = new Intent(this, getClass());
tokenResponseIntent.putExtra(AuthTokenConstants.EXTRA_STORED_MESSAGE, message);
// If we have an invalid auth token, set a bit in the intent that the application will send
// back to us. This will let us know that it is a retry; if sending subsequently fails again,
// we will not do any further retries.
tokenResponseIntent.putExtra(AuthTokenConstants.EXTRA_IS_RETRY, invalidAuthToken != null);
// The pending intent allows the application to send us the tokenResponseIntent.
PendingIntent pendingIntent = PendingIntent.getService(
this, message.hashCode(), tokenResponseIntent, PendingIntent.FLAG_ONE_SHOT);
// We send the pending intent as an extra in a normal intent to the application. We require that
// the intent be delivered only within this package, as a security check. The application must
// define a service with an intent filter that matches the ACTION_REQUEST_AUTH_TOKEN in order
// to receive this intent.
Intent requestTokenIntent = new Intent(AuthTokenConstants.ACTION_REQUEST_AUTH_TOKEN);
requestTokenIntent.setPackage(getPackageName());
requestTokenIntent.putExtra(AuthTokenConstants.EXTRA_PENDING_INTENT, pendingIntent);
if (invalidAuthToken != null) {
requestTokenIntent.putExtra(AuthTokenConstants.EXTRA_INVALIDATE_AUTH_TOKEN, invalidAuthToken);
}
startService(requestTokenIntent);
}
开发者ID:morristech,项目名称:android-chromium,代码行数:45,代码来源:AndroidMessageSenderService.java
示例9: requestAuthTokenForMessage
import com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants; //导入依赖的package包/类
/**
* Requests an auth token from the application to use to send {@code message} to the data
* center.
* <p>
* If not {@code null}, {@code invalidAuthToken} is an auth token that was previously
* found to be invalid. The intent sent to the application to request the new token will include
* the invalid token so that the application can invalidate it in the {@code AccountManager}.
*/
private void requestAuthTokenForMessage(byte[] message, String invalidAuthToken) {
/*
* Send an intent requesting an auth token. This intent will contain a pending intent
* that the recipient can use to send back the token (by attaching the token as a string
* extra). That pending intent will also contain the message that we were just asked to send,
* so that it will be echoed back to us with the token. This avoids our having to persist
* the message while waiting for the token.
*/
// This is the intent that the application will send back to us (the pending intent allows
// it to send the intent). It contains the stored message. We require that it be delivered to
// this class only, as a security check.
Intent tokenResponseIntent = new Intent(this, getClass());
tokenResponseIntent.putExtra(AuthTokenConstants.EXTRA_STORED_MESSAGE, message);
// If we have an invalid auth token, set a bit in the intent that the application will send
// back to us. This will let us know that it is a retry; if sending subsequently fails again,
// we will not do any further retries.
tokenResponseIntent.putExtra(AuthTokenConstants.EXTRA_IS_RETRY, invalidAuthToken != null);
// The pending intent allows the application to send us the tokenResponseIntent.
PendingIntent pendingIntent = PendingIntent.getService(
this, Arrays.hashCode(message), tokenResponseIntent, PendingIntent.FLAG_ONE_SHOT);
// We send the pending intent as an extra in a normal intent to the application. The
// invalidation listener service must handle AUTH_TOKEN_REQUEST intents.
Intent requestTokenIntent = new Intent(AuthTokenConstants.ACTION_REQUEST_AUTH_TOKEN);
requestTokenIntent.putExtra(AuthTokenConstants.EXTRA_PENDING_INTENT, pendingIntent);
if (invalidAuthToken != null) {
requestTokenIntent.putExtra(AuthTokenConstants.EXTRA_INVALIDATE_AUTH_TOKEN, invalidAuthToken);
}
String simpleListenerClass =
new AndroidTiclManifest(getApplicationContext()).getListenerServiceClass();
requestTokenIntent.setClassName(getApplicationContext(), simpleListenerClass);
try {
startService(requestTokenIntent);
} catch (SecurityException | IllegalStateException exception) {
logger.warning("unable to request auth token: %s", exception);
}
}
开发者ID:mogoweb,项目名称:365browser,代码行数:49,代码来源:AndroidMessageSenderService.java
示例10: isAuthTokenRequest
import com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants; //导入依赖的package包/类
/** Returns {@code true} iff the given intent is an authorization token request. */
static boolean isAuthTokenRequest(Intent intent) {
return AuthTokenConstants.ACTION_REQUEST_AUTH_TOKEN.equals(intent.getAction());
}
开发者ID:mogoweb,项目名称:365browser,代码行数:5,代码来源:AndroidListenerIntents.java
注:本文中的com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.AuthTokenConstants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论