-
Notifications
You must be signed in to change notification settings - Fork 18
Remove usage of response intents from retrieve BBQ flow #132
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.BadParcelableException; | ||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.util.Log; | ||
import android.view.WindowManager.LayoutParams; | ||
|
@@ -36,7 +36,7 @@ | |
import org.openyolo.protocol.CredentialRetrieveResult; | ||
import org.openyolo.protocol.Protobufs; | ||
import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse; | ||
import org.openyolo.protocol.internal.IntentUtil; | ||
import org.openyolo.protocol.ProtocolConstants; | ||
|
||
/** | ||
* An invisible Activity that forwards a given {@link CredentialRetrieveRequest} based on the | ||
|
@@ -79,7 +79,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { | |
.queryFor( | ||
CREDENTIAL_DATA_TYPE, | ||
request.toProtocolBuffer(), | ||
new CredentialRetrieveQueryCallback()); | ||
new CredentialRetrieveQueryCallback(request)); | ||
} | ||
|
||
@Override | ||
|
@@ -90,6 +90,13 @@ protected void onDestroy() { | |
|
||
|
||
private class CredentialRetrieveQueryCallback implements QueryCallback { | ||
|
||
private CredentialRetrieveRequest mRetrieveRequest; | ||
|
||
CredentialRetrieveQueryCallback(@NonNull CredentialRetrieveRequest retrieveRequest) { | ||
mRetrieveRequest = retrieveRequest; | ||
} | ||
|
||
@Override | ||
public void onResponse(long queryId, List<QueryResponse> queryResponses) { | ||
ArrayList<Intent> retrieveIntents = new ArrayList<>(); | ||
|
@@ -106,23 +113,27 @@ public void onResponse(long queryId, List<QueryResponse> queryResponses) { | |
|
||
protoResponses.put(queryResponse.responderPackage, response); | ||
|
||
if (response.getRetrieveIntent().isEmpty()) { | ||
continue; | ||
} | ||
|
||
Intent retrieveIntent; | ||
try { | ||
retrieveIntent = | ||
IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray()); | ||
} catch (BadParcelableException ex) { | ||
Log.w(LOG_TAG, "Failed to parse intent from bytes"); | ||
// a provider indicates that it has credentials via the credentials_available field | ||
// on the response proto. Prior 0.3.0, the provider would directly return an intent. | ||
// For backwards compatibility this is currently inspected as a fallback for the | ||
// absence of the credentials_available field, but the Intent itself is no longer | ||
// used. | ||
// TODO: remove backwards compatibility with retrieve_intent after 0.3.0 | ||
if (!response.getCredentialsAvailable() | ||
&& !response.getRetrieveIntent().isEmpty()) { | ||
continue; | ||
} | ||
|
||
if (!queryResponse.responderPackage.equals( | ||
retrieveIntent.getComponent().getPackageName())) { | ||
Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent"); | ||
continue; | ||
Intent retrieveIntent = new Intent(ProtocolConstants.RETRIEVE_CREDENTIAL_ACTION); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are deprecating retrieve intent, but here it will be just ignored. So we are breaking the compatibility if a provider don't have the action I think we should have both, and prefer the action There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, we'll support the old intent for 0.3.0 but please do add support for direct invocation of the retrieve flow ASAP. It's actually required in the spec: http://openid.net/specs/openyolo-android-ID1.html#retrieving-credentials There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes you're right, I've made the change on my side. It will be live in ~ 2 weeks. |
||
retrieveIntent.setPackage(queryResponse.responderPackage); | ||
retrieveIntent.putExtra( | ||
ProtocolConstants.EXTRA_RETRIEVE_REQUEST, | ||
mRetrieveRequest.toProtocolBuffer().toByteArray()); | ||
|
||
if (!response.getPreloadedData().isEmpty()) { | ||
retrieveIntent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_PRELOADED_DATA, | ||
response.getPreloadedData().toByteArray()); | ||
} | ||
|
||
retrieveIntents.add(retrieveIntent); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,13 +20,11 @@ | |
import android.util.Log; | ||
import com.google.bbq.Protobufs.BroadcastQuery; | ||
import com.google.bbq.QueryResponseSender; | ||
import com.google.protobuf.ByteString; | ||
import java.util.Set; | ||
import org.openyolo.protocol.AuthenticationDomain; | ||
import org.openyolo.protocol.AuthenticationMethods; | ||
import org.openyolo.protocol.CredentialRetrieveRequest; | ||
import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse; | ||
import org.openyolo.protocol.internal.IntentUtil; | ||
import org.openyolo.spi.BaseCredentialQueryReceiver; | ||
|
||
/** | ||
|
@@ -67,7 +65,7 @@ protected void processCredentialRequest( | |
|
||
Intent retrieveIntent = RetrieveActivity.createIntent(applicationContext); | ||
CredentialRetrieveBbqResponse response = CredentialRetrieveBbqResponse.newBuilder() | ||
.setRetrieveIntent(ByteString.copyFrom(IntentUtil.toBytes(retrieveIntent))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd ignore the trapdoor code for now, I'm actually going to delete this provider as it's not a good example any more (it treats retrieve() like hint()). |
||
.setCredentialsAvailable(true) | ||
.build(); | ||
|
||
Log.i(LOG_TAG, "Accepting credential request for claimed caller: " | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& !response.getRetrieveIntent().isEmpty()
=>
&& response.getRetrieveIntent().isEmpty()
, no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed as the code has been reordered to fit your request for using the old intent as a fallback.